Skip to content

Commit

Permalink
Add tests for context bounds migration (#19510)
Browse files Browse the repository at this point in the history
Improves tests of #19316
  • Loading branch information
nicolasstucki authored Jan 23, 2024
2 parents ca18f4a + 5d5ce1a commit c78c6d0
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/neg/context-bounds-migration-3.5.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Error: tests/neg/context-bounds-migration-3.5.scala:9:2 -------------------------------------------------------------
9 | foo(C[Int]()) // error
| ^^^
| Context bounds will map to context parameters.
| A `using` clause is needed to pass explicit arguments to them.
| This code can be rewritten automatically under -rewrite -source 3.4-migration.
10 changes: 10 additions & 0 deletions tests/neg/context-bounds-migration-3.5.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//> using options -source 3.5

class C[T]
def foo[X: C] = ()

given [T]: C[T] = C[T]()

def Test =
foo(C[Int]()) // error
foo(using C[Int]()) // ok
6 changes: 6 additions & 0 deletions tests/neg/context-bounds-migration-future.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- [E050] Type Error: tests/neg/context-bounds-migration-future.scala:9:2 ----------------------------------------------
9 | foo(C[Int]()) // error
| ^^^
| method foo does not take more parameters
|
| longer explanation available when compiling with `-explain`
10 changes: 10 additions & 0 deletions tests/neg/context-bounds-migration-future.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//> using options -source future

class C[T]
def foo[X: C] = ()

given [T]: C[T] = C[T]()

def Test =
foo(C[Int]()) // error
foo(using C[Int]()) // ok
6 changes: 6 additions & 0 deletions tests/warn/context-bounds-migration-3.4.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- Warning: tests/warn/context-bounds-migration-3.4.scala:9:2 ----------------------------------------------------------
9 | foo(C[Int]()) // warn
| ^^^
| Context bounds will map to context parameters.
| A `using` clause is needed to pass explicit arguments to them.
| This code can be rewritten automatically under -rewrite -source 3.4-migration.
File renamed without changes.

0 comments on commit c78c6d0

Please sign in to comment.