@@ -1830,10 +1830,8 @@ trait Applications extends Compatibility {
18301830 isAsGood(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2)
18311831 }
18321832 case _ => // (3)
1833- def isGiven (alt : TermRef ) =
1834- alt1.symbol.is(Given ) && alt.symbol != defn.NotGivenClass
18351833 def compareValues (tp1 : Type , tp2 : Type )(using Context ) =
1836- isAsGoodValueType(tp1, tp2, isGiven( alt1), isGiven( alt2))
1834+ isAsGoodValueType(tp1, tp2, alt1.symbol.is( Implicit ), alt2.symbol.is( Implicit ))
18371835 tp2 match
18381836 case tp2 : MethodType => true // (3a)
18391837 case tp2 : PolyType if tp2.resultType.isInstanceOf [MethodType ] => true // (3a)
@@ -1851,7 +1849,7 @@ trait Applications extends Compatibility {
18511849 * available in 3.0-migration if mode `Mode.OldImplicitResolution` is turned on as well.
18521850 * It is used to highlight differences between Scala 2 and 3 behavior.
18531851 *
1854- * - In Scala 3.0-3.5, the behavior is as follows: `T <:p U` iff there is an impliit conversion
1852+ * - In Scala 3.0-3.5, the behavior is as follows: `T <:p U` iff there is an implicit conversion
18551853 * from `T` to `U`, or
18561854 *
18571855 * flip(T) <: flip(U)
@@ -1870,15 +1868,15 @@ trait Applications extends Compatibility {
18701868 * for overloading resolution (when `preferGeneral is false), and the opposite relation
18711869 * `U <: T` or `U convertible to `T` for implicit disambiguation between givens
18721870 * (when `preferGeneral` is true). For old-style implicit values, the 3.4 behavior is kept.
1873- * If one of the alternatives is a given and the other is an implicit , the given wins .
1871+ * If one of the alternatives is an implicit and the other is a given (or an extension) , the implicit loses .
18741872 *
18751873 * - In Scala 3.5 and Scala 3.6-migration, we issue a warning if the result under
18761874 * Scala 3.6 differ wrt to the old behavior up to 3.5.
18771875 *
18781876 * Also and only for given resolution: If a compared type refers to a given or its module class, use
18791877 * the intersection of its parent classes instead.
18801878 */
1881- def isAsGoodValueType (tp1 : Type , tp2 : Type , alt1isGiven : Boolean , alt2isGiven : Boolean )(using Context ): Boolean =
1879+ def isAsGoodValueType (tp1 : Type , tp2 : Type , alt1IsImplicit : Boolean , alt2IsImplicit : Boolean )(using Context ): Boolean =
18821880 val oldResolution = ctx.mode.is(Mode .OldImplicitResolution )
18831881 if ! preferGeneral || Feature .migrateTo3 && oldResolution then
18841882 // Normal specificity test for overloading resolution (where `preferGeneral` is false)
@@ -1896,7 +1894,7 @@ trait Applications extends Compatibility {
18961894
18971895 if Feature .sourceVersion.isAtMost(SourceVersion .`3.4`)
18981896 || oldResolution
1899- || ! alt1isGiven && ! alt2isGiven
1897+ || alt1IsImplicit && alt2IsImplicit
19001898 then
19011899 // Intermediate rules: better means specialize, but map all type arguments downwards
19021900 // These are enabled for 3.0-3.5, and for all comparisons between old-style implicits,
@@ -1911,8 +1909,8 @@ trait Applications extends Compatibility {
19111909 case _ => mapOver(t)
19121910 (flip(tp1p) relaxed_<:< flip(tp2p)) || viewExists(tp1, tp2)
19131911 else
1914- // New rules: better means generalize, givens always beat implicits
1915- if alt1isGiven != alt2isGiven then alt1isGiven
1912+ // New rules: better means generalize, givens (and extensions) always beat implicits
1913+ if alt1IsImplicit != alt2IsImplicit then alt2IsImplicit
19161914 else (tp2p relaxed_<:< tp1p) || viewExists(tp2, tp1)
19171915 end isAsGoodValueType
19181916
0 commit comments