Skip to content

Commit aad6f7d

Browse files
committed
Adapt the test suite to scala 3.6
1 parent abf795c commit aad6f7d

12 files changed

+32
-135
lines changed

Diff for: tests/neg/given-loop-prevention.check

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
-- Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------------------
1+
-- [E172] Type Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------
22
10 | given List[Foo] = List(summon[Foo]) // error
33
| ^
4-
| Result of implicit search for Foo will change.
5-
| Current result Baz.given_Foo will be no longer eligible
6-
| because it is not defined before the search position.
7-
| Result with new rules: No Matching Implicit.
8-
| To opt into the new rules, compile with `-source future` or use
9-
| the `scala.language.future` language import.
10-
|
11-
| To fix the problem without the language import, you could try one of the following:
12-
| - use a `given ... with` clause as the enclosing given,
13-
| - rearrange definitions so that Baz.given_Foo comes earlier,
14-
| - use an explicit argument.
4+
| No given instance of type Foo was found for parameter x of method summon in object Predef

Diff for: tests/neg/i20415.scala

-2
This file was deleted.

Diff for: tests/neg/i6716.check

-14
This file was deleted.

Diff for: tests/neg/i6716.scala

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
2-
trait Monad[T]:
3-
def id: String
41
class Foo
5-
object Foo {
6-
given Monad[Foo] with { def id = "Foo" }
7-
}
82

9-
opaque type Bar = Foo
103
object Bar {
11-
given Monad[Bar] = summon[Monad[Foo]] // error
4+
given Foo with {}
5+
given List[Foo] = List(summon[Foo]) // ok
126
}
137

14-
object Test extends App {
15-
println(summon[Monad[Foo]].id)
16-
println(summon[Monad[Bar]].id)
8+
object Baz {
9+
@annotation.nowarn
10+
given List[Foo] = List(summon[Foo]) // error
11+
given Foo with {}
1712
}

Diff for: tests/neg/i7294.check

+7-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
-- Error: tests/neg/i7294.scala:7:10 -----------------------------------------------------------------------------------
2-
7 | case x: T => x.g(10) // error // error
3-
| ^
4-
| Result of implicit search for scala.reflect.TypeTest[Nothing, T] will change.
5-
| Current result foo.f will be no longer eligible
6-
| because it is not defined before the search position.
7-
| Result with new rules: No Matching Implicit.
8-
| To opt into the new rules, compile with `-source future` or use
9-
| the `scala.language.future` language import.
10-
|
11-
| To fix the problem without the language import, you could try one of the following:
12-
| - use a `given ... with` clause as the enclosing given,
13-
| - rearrange definitions so that foo.f comes earlier,
14-
| - use an explicit argument.
15-
|
16-
| where: T is a type in given instance f with bounds <: foo.Foo
17-
-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:18 --------------------------------------------------------------
18-
7 | case x: T => x.g(10) // error // error
19-
| ^^^^^^^
20-
| Found: Any
21-
| Required: T
22-
|
23-
| where: T is a type in given instance f with bounds <: foo.Foo
1+
-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:15 --------------------------------------------------------------
2+
7 | case x: T => x.g(10) // error
3+
| ^
4+
| Found: (x : Nothing)
5+
| Required: ?{ g: ? }
6+
| Note that implicit conversions were not tried because the result of an implicit conversion
7+
| must be more specific than ?{ g: [applied to (10) returning T] }
248
|
259
| longer explanation available when compiling with `-explain`

Diff for: tests/neg/i7294.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package foo
44
trait Foo { def g(x: Any): Any }
55

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

1010
@main def Test = f

Diff for: tests/neg/looping-givens.check

-48
This file was deleted.

Diff for: tests/neg/looping-givens.scala

-11
This file was deleted.

Diff for: tests/pos/i20415.scala

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Foo:
2+
given ord: Ordering[Int] = summon[Ordering[Int]]

Diff for: tests/pos/i6716.scala

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
//> using options -Xfatal-warnings -source 3.4
2-
1+
trait Monad[T]:
2+
def id: String
33
class Foo
4+
object Foo {
5+
given Monad[Foo] with { def id = "Foo" }
6+
}
47

8+
opaque type Bar = Foo
59
object Bar {
6-
given Foo with {}
7-
given List[Foo] = List(summon[Foo]) // ok
10+
given Monad[Bar] = summon[Monad[Foo]]
811
}
912

10-
object Baz {
11-
@annotation.nowarn
12-
given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed
13-
given Foo with {}
13+
object Test extends App {
14+
println(summon[Monad[Foo]].id)
15+
println(summon[Monad[Bar]].id)
1416
}

Diff for: tests/pos/looping-givens.scala

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import language.future
21

32
class A
43
class B
54

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

87
def foo(using a: A, b: B) =
9-
given aa: A = summon // error
10-
given bb: B = summon // error
11-
given ab: (A & B) = summon // error
8+
given aa: A = summon // resolves to a
9+
given bb: B = summon // resolves to b
10+
given ab: (A & B) = summon // resolves to joint(aa, bb)

Diff for: tests/run/i6716.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Xfatal-warnings -source future
1+
//> using options -Xfatal-warnings
22

33
trait Monad[T]:
44
def id: String

0 commit comments

Comments
 (0)