Skip to content

Commit e7fa3f6

Browse files
Switch default source version to 3.6 (#20895)
2 parents 75a15c2 + 91bccfb commit e7fa3f6

20 files changed

+55
-136
lines changed

Diff for: compiler/src/dotty/tools/dotc/config/SourceVersion.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ enum SourceVersion:
1212
case `3.4-migration`, `3.4`
1313
case `3.5-migration`, `3.5`
1414
case `3.6-migration`, `3.6`
15+
case `3.7-migration`, `3.7`
1516
// !!! Keep in sync with scala.runtime.stdlibPatches.language !!!
1617
case `future-migration`, `future`
1718

@@ -28,7 +29,7 @@ enum SourceVersion:
2829
def isAtMost(v: SourceVersion) = stable.ordinal <= v.ordinal
2930

3031
object SourceVersion extends Property.Key[SourceVersion]:
31-
def defaultSourceVersion = `3.5`
32+
def defaultSourceVersion = `3.6`
3233

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

Diff for: library/src/scala/runtime/stdLibPatches/language.scala

+15
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,21 @@ object language:
300300
@compileTimeOnly("`3.6` can only be used at compile time in import statements")
301301
object `3.6`
302302

303+
/** Set source version to 3.7-migration.
304+
*
305+
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
306+
*/
307+
@compileTimeOnly("`3.7-migration` can only be used at compile time in import statements")
308+
object `3.7-migration`
309+
310+
/** Set source version to 3.7
311+
*
312+
* @see [[https://docs.scala-lang.org/scala3/guides/migration/compatibility-intro.html]]
313+
*/
314+
@compileTimeOnly("`3.7` can only be used at compile time in import statements")
315+
object `3.7`
316+
317+
303318
// !!! Keep in sync with dotty.tools.dotc.config.SourceVersion !!!
304319
// Also add tests in `tests/pos/source-import-3-x.scala` and `tests/pos/source-import-3-x-migration.scala`
305320

Diff for: tests/neg/given-loop-prevention.check

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
-- Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------------------
1+
-- [E172] Type Error: tests/neg/given-loop-prevention.scala:10:36 ------------------------------------------------------
22
10 | given List[Foo] = List(summon[Foo]) // error
33
| ^
4-
| Result of implicit search for Foo will change.
5-
| Current result Baz.given_Foo will be no longer eligible
6-
| because it is not defined before the search position.
7-
| Result with new rules: No Matching Implicit.
8-
| To opt into the new rules, compile with `-source future` or use
9-
| the `scala.language.future` language import.
10-
|
11-
| To fix the problem without the language import, you could try one of the following:
12-
| - use a `given ... with` clause as the enclosing given,
13-
| - rearrange definitions so that Baz.given_Foo comes earlier,
14-
| - use an explicit argument.
4+
| No given instance of type Foo was found for parameter x of method summon in object Predef

Diff for: tests/neg/i20415.scala

-2
This file was deleted.

Diff for: tests/neg/i6716.check

-14
This file was deleted.

Diff for: tests/neg/i6716.scala

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
2-
trait Monad[T]:
3-
def id: String
41
class Foo
5-
object Foo {
6-
given Monad[Foo] with { def id = "Foo" }
7-
}
82

9-
opaque type Bar = Foo
103
object Bar {
11-
given Monad[Bar] = summon[Monad[Foo]] // error
4+
given Foo with {}
5+
given List[Foo] = List(summon[Foo]) // ok
126
}
137

14-
object Test extends App {
15-
println(summon[Monad[Foo]].id)
16-
println(summon[Monad[Bar]].id)
8+
object Baz {
9+
@annotation.nowarn
10+
given List[Foo] = List(summon[Foo]) // error
11+
given Foo with {}
1712
}

Diff for: tests/neg/i7294.check

+7-23
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
1-
-- Error: tests/neg/i7294.scala:7:10 -----------------------------------------------------------------------------------
2-
7 | case x: T => x.g(10) // error // error
3-
| ^
4-
| Result of implicit search for scala.reflect.TypeTest[Nothing, T] will change.
5-
| Current result foo.f will be no longer eligible
6-
| because it is not defined before the search position.
7-
| Result with new rules: No Matching Implicit.
8-
| To opt into the new rules, compile with `-source future` or use
9-
| the `scala.language.future` language import.
10-
|
11-
| To fix the problem without the language import, you could try one of the following:
12-
| - use a `given ... with` clause as the enclosing given,
13-
| - rearrange definitions so that foo.f comes earlier,
14-
| - use an explicit argument.
15-
|
16-
| where: T is a type in given instance f with bounds <: foo.Foo
17-
-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:18 --------------------------------------------------------------
18-
7 | case x: T => x.g(10) // error // error
19-
| ^^^^^^^
20-
| Found: Any
21-
| Required: T
22-
|
23-
| where: T is a type in given instance f with bounds <: foo.Foo
1+
-- [E007] Type Mismatch Error: tests/neg/i7294.scala:7:15 --------------------------------------------------------------
2+
7 | case x: T => x.g(10) // error
3+
| ^
4+
| Found: (x : Nothing)
5+
| Required: ?{ g: ? }
6+
| Note that implicit conversions were not tried because the result of an implicit conversion
7+
| must be more specific than ?{ g: [applied to (10) returning T] }
248
|
259
| longer explanation available when compiling with `-explain`

Diff for: tests/neg/i7294.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package foo
44
trait Foo { def g(x: Any): Any }
55

66
inline given f[T <: Foo]: T = ??? match {
7-
case x: T => x.g(10) // error // error
7+
case x: T => x.g(10) // error
88
}
99

1010
@main def Test = f

Diff for: tests/neg/looping-givens.check

-48
This file was deleted.

Diff for: tests/neg/looping-givens.scala

-11
This file was deleted.

Diff for: tests/pos/i20415.scala

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Foo:
2+
given ord: Ordering[Int] = summon[Ordering[Int]]

Diff for: tests/pos/i6716.scala

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
//> using options -Xfatal-warnings -source 3.4
2-
1+
trait Monad[T]:
2+
def id: String
33
class Foo
4+
object Foo {
5+
given Monad[Foo] with { def id = "Foo" }
6+
}
47

8+
opaque type Bar = Foo
59
object Bar {
6-
given Foo with {}
7-
given List[Foo] = List(summon[Foo]) // ok
10+
given Monad[Bar] = summon[Monad[Foo]]
811
}
912

10-
object Baz {
11-
@annotation.nowarn
12-
given List[Foo] = List(summon[Foo]) // gives a warning, which is suppressed
13-
given Foo with {}
13+
object Test extends App {
14+
println(summon[Monad[Foo]].id)
15+
println(summon[Monad[Bar]].id)
1416
}

Diff for: tests/pos/looping-givens.scala

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import language.future
21

32
class A
43
class B
54

65
given joint(using a: A, b: B): (A & B) = ???
76

87
def foo(using a: A, b: B) =
9-
given aa: A = summon // error
10-
given bb: B = summon // error
11-
given ab: (A & B) = summon // error
8+
given aa: A = summon // resolves to a
9+
given bb: B = summon // resolves to b
10+
given ab: (A & B) = summon // resolves to joint(aa, bb)

Diff for: tests/pos/source-import-3-5-migration.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import language.`3.5-migration`

Diff for: tests/pos/source-import-3-5.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import language.`3.5`

Diff for: tests/pos/source-import-3-6-migration.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import language.`3.6-migration`

Diff for: tests/pos/source-import-3-6.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import language.`3.6`

Diff for: tests/pos/source-import-3-7-migration.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import language.`3.7-migration`

Diff for: tests/pos/source-import-3-7.scala

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import language.`3.7`

Diff for: tests/run/i6716.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -Xfatal-warnings -source future
1+
//> using options -Xfatal-warnings
22

33
trait Monad[T]:
44
def id: String

0 commit comments

Comments
 (0)