Skip to content

Commit de46c7d

Browse files
committed
Adapt the tests to Scala 3.5
1 parent c796bcf commit de46c7d

26 files changed

+188
-101
lines changed

library/src/scala/quoted/ToExpr.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ object ToExpr {
9797
/** Default implementation of `ToExpr[Array[T]]` */
9898
given ArrayToExpr[T: Type: ToExpr: ClassTag]: ToExpr[Array[T]] with {
9999
def apply(arr: Array[T])(using Quotes): Expr[Array[T]] =
100-
'{ Array[T](${Expr(arr.toSeq)}*)(${Expr(summon[ClassTag[T]])}) }
100+
'{ Array[T](${Expr(arr.toSeq)}*)(using ${Expr(summon[ClassTag[T]])}) }
101101
}
102102

103103
/** Default implementation of `ToExpr[Array[Boolean]]` */

tests/neg/given-loop-prevention.check

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
-- Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------------------
2+
10 | given List[Foo] = List(summon[Foo]) // error
3+
| ^
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.

tests/neg/given-loop-prevention.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
class Foo
3+
4+
object Bar {
5+
given Foo with {}
6+
given List[Foo] = List(summon[Foo]) // ok
7+
}
8+
9+
object Baz {
10+
given List[Foo] = List(summon[Foo]) // error
11+
given Foo with {}
12+
}

tests/neg/i6716.check

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- Warning: tests/neg/i6716.scala:12:39 --------------------------------------------------------------------------------
2-
12 | given Monad[Bar] = summon[Monad[Foo]] // warn
1+
-- Error: tests/neg/i6716.scala:11:39 ----------------------------------------------------------------------------------
2+
11 | given Monad[Bar] = summon[Monad[Foo]] // error
33
| ^
44
| Result of implicit search for Monad[Foo] will change.
55
| Current result Bar.given_Monad_Bar will be no longer eligible
@@ -12,5 +12,3 @@
1212
| - use a `given ... with` clause as the enclosing given,
1313
| - rearrange definitions so that Bar.given_Monad_Bar comes earlier,
1414
| - use an explicit argument.
15-
| This will be an error in Scala 3.5 and later.
16-
No warnings can be incurred under -Werror (or -Xfatal-warnings)

tests/neg/i6716.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//> using options -Xfatal-warnings
21

32
trait Monad[T]:
43
def id: String
@@ -9,11 +8,10 @@ object Foo {
98

109
opaque type Bar = Foo
1110
object Bar {
12-
given Monad[Bar] = summon[Monad[Foo]] // warn
11+
given Monad[Bar] = summon[Monad[Foo]] // error
1312
}
1413

1514
object Test extends App {
1615
println(summon[Monad[Foo]].id)
1716
println(summon[Monad[Bar]].id)
1817
}
19-
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)

tests/neg/i7294-a.check

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/neg/i7294-a.scala

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/neg/i7294-b.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/neg/i7294.check

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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
24+
|
25+
| longer explanation available when compiling with `-explain`

tests/neg/i7294.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
package foo
3+
4+
trait Foo { def g(x: Any): Any }
5+
6+
inline given f[T <: Foo]: T = ??? match {
7+
case x: T => x.g(10) // error // error
8+
}
9+
10+
@main def Test = f

0 commit comments

Comments
 (0)