Skip to content

Commit 4a76161

Browse files
committed
Set default source version to 3.5
Fixes #20415
1 parent a7ac03e commit 4a76161

16 files changed

+45
-52
lines changed

compiler/src/dotty/tools/dotc/config/SourceVersion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ enum SourceVersion:
2828
def isAtMost(v: SourceVersion) = stable.ordinal <= v.ordinal
2929

3030
object SourceVersion extends Property.Key[SourceVersion]:
31-
def defaultSourceVersion = `3.4`
31+
def defaultSourceVersion = `3.5`
3232

3333
/** language versions that may appear in a language import, are deprecated, but not removed from the standard library. */
3434
val illegalSourceVersionNames = List("3.1-migration").map(_.toTermName)

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/neg/i6716.check

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- Warning: tests/neg/i6716.scala:12:39 --------------------------------------------------------------------------------
2-
12 | given Monad[Bar] = summon[Monad[Foo]] // warn
1+
-- Error: tests/neg/i6716.scala:10:39 ----------------------------------------------------------------------------------
2+
10 | given Monad[Bar] = summon[Monad[Foo]] // error
33
| ^
44
| Result of implicit search for Monad[Foo] will change.
55
| Current result Bar.given_Monad_Bar will be no longer eligible
@@ -12,5 +12,3 @@
1212
| - use a `given ... with` clause as the enclosing given,
1313
| - rearrange definitions so that Bar.given_Monad_Bar comes earlier,
1414
| - use an explicit argument.
15-
| This will be an error in Scala 3.5 and later.
16-
No warnings can be incurred under -Werror (or -Xfatal-warnings)

tests/neg/i6716.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//> using options -Xfatal-warnings
2-
31
trait Monad[T]:
42
def id: String
53
class Foo
@@ -9,11 +7,10 @@ object Foo {
97

108
opaque type Bar = Foo
119
object Bar {
12-
given Monad[Bar] = summon[Monad[Foo]] // warn
10+
given Monad[Bar] = summon[Monad[Foo]] // error
1311
}
1412

1513
object Test extends App {
1614
println(summon[Monad[Foo]].id)
1715
println(summon[Monad[Bar]].id)
1816
}
19-
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)

tests/neg/i7294-a.scala

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/neg/i7294-b.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/neg/i7294.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package foo
2+
3+
trait Foo { def g(x: Int): Any }
4+
5+
object Test:
6+
7+
inline given f[T <: Foo]: T = ??? match {
8+
case x: T => x.g(10) // error // error
9+
}
10+
11+
@main def Test = f

tests/pos-deep-subtype/CollectionStrawMan6.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -754,11 +754,11 @@ object CollectionStrawMan6 extends LowPriority {
754754

755755
def elemTag: ClassTag[A] = ClassTag(xs.getClass.getComponentType)
756756

757-
protected def fromIterableWithSameElemType(coll: Iterable[A]): Array[A] = coll.toArray[A](elemTag)
757+
protected def fromIterableWithSameElemType(coll: Iterable[A]): Array[A] = coll.toArray[A](using elemTag)
758758

759759
def fromIterable[B: ClassTag](coll: Iterable[B]): Array[B] = coll.toArray[B]
760760

761-
protected[this] def newBuilder = new ArrayBuffer[A].mapResult(_.toArray(elemTag))
761+
protected[this] def newBuilder = new ArrayBuffer[A].mapResult(_.toArray(using elemTag))
762762

763763
override def knownSize = xs.length
764764

tests/pos/given-loop-prevention.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Xfatal-warnings
1+
//> using options -Xfatal-warnings -source 3.4
22

33
class Foo
44

tests/pos/i17245.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type OnChannel = Channel => Any
1414
val case1: OnChannel = Mockito.mock[OnChannel]
1515
val case2: OnChannel = Mockito.mock
1616
val case3 = Mockito.mock[OnChannel]
17-
val case4: OnChannel = Mockito.mock[OnChannel](summon[ClassTag[OnChannel]])
17+
val case4: OnChannel = Mockito.mock[OnChannel](using summon[ClassTag[OnChannel]])
1818

1919
// not a regressive case, but an added improvement with the fix for the above
2020
val case5: Channel => Any = Mockito.mock[Channel => Any]

tests/pos/t5643.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object TupledEvidenceTest {
1313

1414
def f[T : GetResult] = ""
1515

16-
f[(String,String)](getTuple[(String, String)])
16+
f[(String,String)](using getTuple[(String, String)])
1717

1818
f[(String,String)]
1919
}

tests/run/colltest6/CollectionStrawMan6_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,11 +755,11 @@ object CollectionStrawMan6 extends LowPriority {
755755

756756
def elemTag: ClassTag[A] = ClassTag(xs.getClass.getComponentType)
757757

758-
protected def fromIterableWithSameElemType(coll: Iterable[A]): Array[A] = coll.toArray[A](elemTag)
758+
protected def fromIterableWithSameElemType(coll: Iterable[A]): Array[A] = coll.toArray[A](using elemTag)
759759

760760
def fromIterable[B: ClassTag](coll: Iterable[B]): Array[B] = coll.toArray[B]
761761

762-
protected[this] def newBuilder = new ArrayBuffer[A].mapResult(_.toArray(elemTag))
762+
protected[this] def newBuilder = new ArrayBuffer[A].mapResult(_.toArray(using elemTag))
763763

764764
override def knownSize = xs.length
765765

tests/warn/context-bounds-migration.scala

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/warn/i15474.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
//> using options -source 3.4
22

33
import scala.language.implicitConversions
44

tests/warn/looping-givens.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//> using options -source 3.4
12
class A
23
class B
34

0 commit comments

Comments
 (0)