Skip to content

Commit

Permalink
Set default source version to 3.5 (#20435)
Browse files Browse the repository at this point in the history
The main part of this branch was superseded by #20441, but there were a
couple of tests to add, and also a change
in the treatment of looping implicits in 3.6
  • Loading branch information
hamzaremmal authored May 27, 2024
2 parents d3268c2 + 345c1e8 commit 5187735
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions tests/neg/i20415.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Foo:
given ord: Ordering[Int] = summon[Ordering[Int]] // error
19 changes: 19 additions & 0 deletions tests/neg/i6716-source-3.4.scala
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 14 additions & 0 deletions tests/pos/given-loop-prevention.scala
Original file line number Diff line number Diff line change
@@ -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 {}
}

0 comments on commit 5187735

Please sign in to comment.