Skip to content

Commit f62e141

Browse files
committed
Delay priority change until 3.7
Warnings from 3.6, change in 3.7. This is one version later than originally planned.
1 parent 7c4bd67 commit f62e141

16 files changed

+30
-30
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,7 +1767,7 @@ trait Applications extends Compatibility {
17671767
// and in mode Scala3-migration when we compare with the old Scala 2 rules.
17681768

17691769
case Intermediate // Intermediate rules: better means specialize, but map all type arguments downwards
1770-
// These are enabled for 3.0-3.4, or if OldImplicitResolution
1770+
// These are enabled for 3.0-3.5, or if OldImplicitResolution
17711771
// is specified, and also for all comparisons between old-style implicits,
17721772

17731773
case New // New rules: better means generalize, givens (and extensions) always beat implicits
@@ -1803,7 +1803,7 @@ trait Applications extends Compatibility {
18031803
val oldResolution = ctx.mode.is(Mode.OldImplicitResolution)
18041804
if !preferGeneral || Feature.migrateTo3 && oldResolution then
18051805
CompareScheme.Old
1806-
else if Feature.sourceVersion.isAtMost(SourceVersion.`3.4`)
1806+
else if Feature.sourceVersion.isAtMost(SourceVersion.`3.5`)
18071807
|| oldResolution
18081808
|| alt1.symbol.is(Implicit) && alt2.symbol.is(Implicit)
18091809
then CompareScheme.Intermediate
@@ -1869,7 +1869,7 @@ trait Applications extends Compatibility {
18691869
* available in 3.0-migration if mode `Mode.OldImplicitResolution` is turned on as well.
18701870
* It is used to highlight differences between Scala 2 and 3 behavior.
18711871
*
1872-
* - In Scala 3.0-3.5, the behavior is as follows: `T <:p U` iff there is an implicit conversion
1872+
* - In Scala 3.0-3.6, the behavior is as follows: `T <:p U` iff there is an implicit conversion
18731873
* from `T` to `U`, or
18741874
*
18751875
* flip(T) <: flip(U)
@@ -1884,14 +1884,14 @@ trait Applications extends Compatibility {
18841884
* of parameters are not affected. So `T <: U` would imply `Set[Cmp[U]] <:p Set[Cmp[T]]`,
18851885
* as usual, because `Set` is non-variant.
18861886
*
1887-
* - From Scala 3.6, `T <:p U` means `T <: U` or `T` convertible to `U`
1887+
* - From Scala 3.7, `T <:p U` means `T <: U` or `T` convertible to `U`
18881888
* for overloading resolution (when `preferGeneral is false), and the opposite relation
18891889
* `U <: T` or `U convertible to `T` for implicit disambiguation between givens
1890-
* (when `preferGeneral` is true). For old-style implicit values, the 3.4 behavior is kept.
1890+
* (when `preferGeneral` is true). For old-style implicit values, the 3.5 behavior is kept.
18911891
* If one of the alternatives is an implicit and the other is a given (or an extension), the implicit loses.
18921892
*
1893-
* - In Scala 3.5 and Scala 3.6-migration, we issue a warning if the result under
1894-
* Scala 3.6 differ wrt to the old behavior up to 3.5.
1893+
* - In Scala 3.6 and Scala 3.7-migration, we issue a warning if the result under
1894+
* Scala 3.7 differs wrt to the old behavior up to 3.6.
18951895
*
18961896
* Also and only for given resolution: If a compared type refers to a given or its module class, use
18971897
* the intersection of its parent classes instead.

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,26 +1305,26 @@ trait Implicits:
13051305
/** Search a list of eligible implicit references */
13061306
private def searchImplicit(eligible: List[Candidate], contextual: Boolean): SearchResult =
13071307

1308-
// A map that associates a priority change warning (between -source 3.4 and 3.6)
1308+
// A map that associates a priority change warning (between -source 3.6 and 3.7)
13091309
// with the candidate refs mentioned in the warning. We report the associated
13101310
// message if one of the critical candidates is part of the result of the implicit search.
13111311
val priorityChangeWarnings = mutable.ListBuffer[(/*critical:*/ List[TermRef], Message)]()
13121312

13131313
def isWarnPriorityChangeVersion(sv: SourceVersion): Boolean =
1314-
sv.stable == SourceVersion.`3.5` || sv == SourceVersion.`3.6-migration`
1314+
sv.stable == SourceVersion.`3.6` || sv == SourceVersion.`3.7-migration`
13151315

13161316
/** Compare `alt1` with `alt2` to determine which one should be chosen.
13171317
*
13181318
* @return a number > 0 if `alt1` is preferred over `alt2`
13191319
* a number < 0 if `alt2` is preferred over `alt1`
13201320
* 0 if neither alternative is preferred over the other
13211321
* The behavior depends on the source version
1322-
* before 3.5: compare with preferGeneral = false
1323-
* 3.5: compare twice with preferGeneral = false and true, warning if result is different,
1322+
* before 3.6: compare with preferGeneral = false
1323+
* 3.6: compare twice with preferGeneral = false and true, warning if result is different,
13241324
* return old result with preferGeneral = false
1325-
* 3.6-migration: compare twice with preferGeneral = false and true, warning if result is different,
1325+
* 3.7-migration: compare twice with preferGeneral = false and true, warning if result is different,
13261326
* return new result with preferGeneral = true
1327-
* 3.6 and higher: compare with preferGeneral = true
1327+
* 3.7 and higher: compare with preferGeneral = true
13281328
*
13291329
* @param disambiguate The call is used to disambiguate two successes, not for ranking.
13301330
* When ranking, we are always filtering out either > 0 or <= 0 results.
@@ -1348,15 +1348,15 @@ trait Implicits:
13481348
case -1 => "the second alternative"
13491349
case 1 => "the first alternative"
13501350
case _ => "none - it's ambiguous"
1351-
if sv.stable == SourceVersion.`3.5` then
1351+
if sv.stable == SourceVersion.`3.6` then
13521352
warn(
13531353
em"""Given search preference for $pt between alternatives
13541354
| ${alt1.ref}
13551355
|and
13561356
| ${alt2.ref}
13571357
|will change.
13581358
|Current choice : ${choice(prev)}
1359-
|New choice from Scala 3.6: ${choice(cmp)}""")
1359+
|New choice from Scala 3.7: ${choice(cmp)}""")
13601360
prev
13611361
else
13621362
warn(
@@ -1366,7 +1366,7 @@ trait Implicits:
13661366
| ${alt2.ref}
13671367
|has changed.
13681368
|Previous choice : ${choice(prev)}
1369-
|New choice from Scala 3.6: ${choice(cmp)}""")
1369+
|New choice from Scala 3.7: ${choice(cmp)}""")
13701370
cmp
13711371
else cmp max prev
13721372
// When ranking, we keep the better of cmp and prev, which ends up retaining a candidate

tests/neg/ctx-bounds-priority.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -source 3.6
1+
//> using options -source 3.7
22
trait Eq[A]
33
trait Order[A] extends Eq[A]:
44
def toOrdering: Ordering[A]

tests/neg/given-triangle.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@
99
| (given_B : B)
1010
|will change.
1111
|Current choice : the second alternative
12-
|New choice from Scala 3.6: the first alternative
12+
|New choice from Scala 3.7: the first alternative

tests/neg/given-triangle.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -source 3.5
1+
//> using options -source 3.6
22
class A
33
class B extends A
44
class C extends A

tests/neg/i15264.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.`3.6`
1+
import language.`3.7`
22
object priority:
33
// lower number = higher priority
44
class Prio0 extends Prio1

tests/neg/i21212.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.7
22
object Minimization:
33

44
trait A

tests/neg/i21303/Test.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -source 3.6-migration
1+
//> using options -source 3.7-migration
22
import scala.deriving.Mirror
33
import scala.compiletime.*
44
import scala.reflect.ClassTag

tests/run/given-triangle.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.`3.6`
1+
import language.`3.7`
22

33
class A
44
class B extends A

tests/run/implicit-specifity.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.`3.6`
1+
import language.`3.7`
22

33
case class Show[T](val i: Int)
44
object Show {

tests/run/implied-priority.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* These tests show various mechanisms available for implicit prioritization.
22
*/
3-
import language.`3.6`
3+
import language.`3.7`
44

55
class E[T](val str: String) // The type for which we infer terms below
66

tests/warn/i20420.scala

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

33
final class StrictEqual[V]
44
final class Less[V]

tests/warn/i21036a.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
| (a : A)
88
| will change.
99
| Current choice : the first alternative
10-
| New choice from Scala 3.6: the second alternative
10+
| New choice from Scala 3.7: the second alternative

tests/warn/i21036a.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -source 3.5
1+
//> using options -source 3.6
22
trait A
33
trait B extends A
44
given b: B = ???

tests/warn/i21036b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
| (a : A)
88
| has changed.
99
| Previous choice : the first alternative
10-
| New choice from Scala 3.6: the second alternative
10+
| New choice from Scala 3.7: the second alternative

tests/warn/i21036b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//> using options -source 3.6-migration
1+
//> using options -source 3.7-migration
22
trait A
33
trait B extends A
44
given b: B = ???

0 commit comments

Comments
 (0)