Skip to content

Commit c76806c

Browse files
nicolasstuckiKordyjan
authored andcommitted
Add tests for context bounds migration
Improves tests of #19316
1 parent 40fab51 commit c76806c

6 files changed

+38
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Error: tests/neg/context-bounds-migration-3.5.scala:9:2 -------------------------------------------------------------
2+
9 | foo(C[Int]()) // error
3+
| ^^^
4+
| Context bounds will map to context parameters.
5+
| A `using` clause is needed to pass explicit arguments to them.
6+
| This code can be rewritten automatically under -rewrite -source 3.4-migration.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//> using options -source 3.5
2+
3+
class C[T]
4+
def foo[X: C] = ()
5+
6+
given [T]: C[T] = C[T]()
7+
8+
def Test =
9+
foo(C[Int]()) // error
10+
foo(using C[Int]()) // ok
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- [E050] Type Error: tests/neg/context-bounds-migration-future.scala:9:2 ----------------------------------------------
2+
9 | foo(C[Int]()) // error
3+
| ^^^
4+
| method foo does not take more parameters
5+
|
6+
| longer explanation available when compiling with `-explain`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//> using options -source future
2+
3+
class C[T]
4+
def foo[X: C] = ()
5+
6+
given [T]: C[T] = C[T]()
7+
8+
def Test =
9+
foo(C[Int]()) // error
10+
foo(using C[Int]()) // ok
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Warning: tests/warn/context-bounds-migration-3.4.scala:9:2 ----------------------------------------------------------
2+
9 | foo(C[Int]()) // warn
3+
| ^^^
4+
| Context bounds will map to context parameters.
5+
| A `using` clause is needed to pass explicit arguments to them.
6+
| This code can be rewritten automatically under -rewrite -source 3.4-migration.

0 commit comments

Comments
 (0)