Skip to content

Commit 1f4a5de

Browse files
committed
Add some more tests for version-specific behavior
1 parent a594958 commit 1f4a5de

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

tests/neg/i20415.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Foo:
2+
given ord: Ordering[Int] = summon[Ordering[Int]] // error

tests/neg/i6716-source-3.4.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//> using options -Xfatal-warnings -source 3.4
2+
3+
trait Monad[T]:
4+
def id: String
5+
class Foo
6+
object Foo {
7+
given Monad[Foo] with { def id = "Foo" }
8+
}
9+
10+
opaque type Bar = Foo
11+
object Bar {
12+
given Monad[Bar] = summon[Monad[Foo]] // warn
13+
}
14+
15+
object Test extends App {
16+
println(summon[Monad[Foo]].id)
17+
println(summon[Monad[Bar]].id)
18+
}
19+
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)

tests/pos/given-loop-prevention.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//> using options -Xfatal-warnings -source 3.4
2+
3+
class Foo
4+
5+
object Bar {
6+
given Foo with {}
7+
given List[Foo] = List(summon[Foo]) // ok
8+
}
9+
10+
object Baz {
11+
@annotation.nowarn
12+
given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed
13+
given Foo with {}
14+
}

0 commit comments

Comments
 (0)