diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 54821444aed6..3fe8d6fae8a3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -1718,7 +1718,7 @@ trait Implicits: SearchSuccess(tpd.ref(ref).withSpan(span.startPos), ref, 0)(ctx.typerState, ctx.gadt) case _ => searchImplicit(ctx.implicits, - if sourceVersion.isAtLeast(SourceVersion.future) then SearchMode.New + if sourceVersion.isAtLeast(SourceVersion.`3.6`) then SearchMode.New else if sourceVersion.isAtLeast(SourceVersion.`3.5`) then SearchMode.CompareErr else if sourceVersion.isAtLeast(SourceVersion.`3.4`) then SearchMode.CompareWarn else SearchMode.Old) diff --git a/tests/neg/i20415.scala b/tests/neg/i20415.scala new file mode 100644 index 000000000000..14582e40aa9d --- /dev/null +++ b/tests/neg/i20415.scala @@ -0,0 +1,2 @@ +class Foo: + given ord: Ordering[Int] = summon[Ordering[Int]] // error diff --git a/tests/neg/i6716-source-3.4.scala b/tests/neg/i6716-source-3.4.scala new file mode 100644 index 000000000000..f6f1961b67a4 --- /dev/null +++ b/tests/neg/i6716-source-3.4.scala @@ -0,0 +1,19 @@ +//> using options -Xfatal-warnings -source 3.4 + +trait Monad[T]: + def id: String +class Foo +object Foo { + given Monad[Foo] with { def id = "Foo" } +} + +opaque type Bar = Foo +object Bar { + given Monad[Bar] = summon[Monad[Foo]] // warn +} + +object Test extends App { + println(summon[Monad[Foo]].id) + println(summon[Monad[Bar]].id) +} +// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings) \ No newline at end of file diff --git a/tests/pos/given-loop-prevention.scala b/tests/pos/given-loop-prevention.scala new file mode 100644 index 000000000000..f02559af1e82 --- /dev/null +++ b/tests/pos/given-loop-prevention.scala @@ -0,0 +1,14 @@ +//> using options -Xfatal-warnings -source 3.4 + +class Foo + +object Bar { + given Foo with {} + given List[Foo] = List(summon[Foo]) // ok +} + +object Baz { + @annotation.nowarn + given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed + given Foo with {} +}