Skip to content

Commit 87e45fa

Browse files
committed
Swap two givens in Specs2 to satisfy new restriuction
1 parent 07c821a commit 87e45fa

File tree

3 files changed

+32
-30
lines changed

3 files changed

+32
-30
lines changed

tests/neg/i7294-a.check

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

tests/neg/i7294-a.scala

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ package foo
44

55
trait Foo { def g(x: Int): Any }
66

7-
inline given f[T <: Foo]: T = ??? match {
8-
case x: T => x.g(10) // error // error
9-
}
7+
object Test:
108

11-
@main def Test = f
9+
inline given f[T <: Foo]: T = ??? match {
10+
case x: T => x.g(10) // error // error
11+
}
12+
13+
@main def Test = f

0 commit comments

Comments
 (0)