Skip to content

Commit

Permalink
Adapt the test suite to scala 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzaremmal committed Jul 3, 2024
1 parent abf795c commit aad6f7d
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 135 deletions.
14 changes: 2 additions & 12 deletions tests/neg/given-loop-prevention.check
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
-- Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------------------
-- [E172] Type Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------
10 | given List[Foo] = List(summon[Foo]) // error
| ^
| Result of implicit search for Foo will change.
| Current result Baz.given_Foo will be no longer eligible
| because it is not defined before the search position.
| Result with new rules: No Matching Implicit.
| To opt into the new rules, compile with `-source future` or use
| the `scala.language.future` language import.
|
| To fix the problem without the language import, you could try one of the following:
| - use a `given ... with` clause as the enclosing given,
| - rearrange definitions so that Baz.given_Foo comes earlier,
| - use an explicit argument.
| No given instance of type Foo was found for parameter x of method summon in object Predef
2 changes: 0 additions & 2 deletions tests/neg/i20415.scala

This file was deleted.

14 changes: 0 additions & 14 deletions tests/neg/i6716.check

This file was deleted.

17 changes: 6 additions & 11 deletions tests/neg/i6716.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@

trait Monad[T]:
def id: String
class Foo
object Foo {
given Monad[Foo] with { def id = "Foo" }
}

opaque type Bar = Foo
object Bar {
given Monad[Bar] = summon[Monad[Foo]] // error
given Foo with {}
given List[Foo] = List(summon[Foo]) // ok
}

object Test extends App {
println(summon[Monad[Foo]].id)
println(summon[Monad[Bar]].id)
object Baz {
@annotation.nowarn
given List[Foo] = List(summon[Foo]) // error
given Foo with {}
}
30 changes: 7 additions & 23 deletions tests/neg/i7294.check
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
-- Error: tests/neg/i7294.scala:7:10 -----------------------------------------------------------------------------------
7 | case x: T => x.g(10) // error // error
| ^
| Result of implicit search for scala.reflect.TypeTest[Nothing, T] will change.
| Current result foo.f will be no longer eligible
| because it is not defined before the search position.
| Result with new rules: No Matching Implicit.
| To opt into the new rules, compile with `-source future` or use
| the `scala.language.future` language import.
|
| To fix the problem without the language import, you could try one of the following:
| - use a `given ... with` clause as the enclosing given,
| - rearrange definitions so that foo.f comes earlier,
| - use an explicit argument.
|
| where: T is a type in given instance f with bounds <: foo.Foo
-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:18 --------------------------------------------------------------
7 | case x: T => x.g(10) // error // error
| ^^^^^^^
| Found: Any
| Required: T
|
| where: T is a type in given instance f with bounds <: foo.Foo
-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:15 --------------------------------------------------------------
7 | case x: T => x.g(10) // error
| ^
| Found: (x : Nothing)
| Required: ?{ g: ? }
| Note that implicit conversions were not tried because the result of an implicit conversion
| must be more specific than ?{ g: [applied to (10) returning T] }
|
| longer explanation available when compiling with `-explain`
2 changes: 1 addition & 1 deletion tests/neg/i7294.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package foo
trait Foo { def g(x: Any): Any }

inline given f[T <: Foo]: T = ??? match {
case x: T => x.g(10) // error // error
case x: T => x.g(10) // error
}

@main def Test = f
48 changes: 0 additions & 48 deletions tests/neg/looping-givens.check

This file was deleted.

11 changes: 0 additions & 11 deletions tests/neg/looping-givens.scala

This file was deleted.

2 changes: 2 additions & 0 deletions tests/pos/i20415.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Foo:
given ord: Ordering[Int] = summon[Ordering[Int]]
18 changes: 10 additions & 8 deletions tests/pos/i6716.scala
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
//> using options -Xfatal-warnings -source 3.4

trait Monad[T]:
def id: String
class Foo
object Foo {
given Monad[Foo] with { def id = "Foo" }
}

opaque type Bar = Foo
object Bar {
given Foo with {}
given List[Foo] = List(summon[Foo]) // ok
given Monad[Bar] = summon[Monad[Foo]]
}

object Baz {
@annotation.nowarn
given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed
given Foo with {}
object Test extends App {
println(summon[Monad[Foo]].id)
println(summon[Monad[Bar]].id)
}
7 changes: 3 additions & 4 deletions tests/pos/looping-givens.scala
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import language.future

class A
class B

given joint(using a: A, b: B): (A & B) = ???

def foo(using a: A, b: B) =
given aa: A = summon // error
given bb: B = summon // error
given ab: (A & B) = summon // error
given aa: A = summon // resolves to a
given bb: B = summon // resolves to b
given ab: (A & B) = summon // resolves to joint(aa, bb)
2 changes: 1 addition & 1 deletion tests/run/i6716.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//> using options -Xfatal-warnings -source future
//> using options -Xfatal-warnings

trait Monad[T]:
def id: String
Expand Down

0 comments on commit aad6f7d

Please sign in to comment.