@@ -1821,10 +1821,8 @@ trait Applications extends Compatibility {
1821
1821
isAsGood(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2)
1822
1822
}
1823
1823
case _ => // (3)
1824
- def isGiven (alt : TermRef ) =
1825
- alt.symbol.is(Given ) && alt.symbol != defn.NotGivenClass
1826
1824
def compareValues (tp1 : Type , tp2 : Type )(using Context ) =
1827
- isAsGoodValueType(tp1, tp2, isGiven( alt1), isGiven( alt2))
1825
+ isAsGoodValueType(tp1, tp2, alt1.symbol.is( Implicit ), alt2.symbol.is( Implicit ))
1828
1826
tp2 match
1829
1827
case tp2 : MethodType => true // (3a)
1830
1828
case tp2 : PolyType if tp2.resultType.isInstanceOf [MethodType ] => true // (3a)
@@ -1861,15 +1859,15 @@ trait Applications extends Compatibility {
1861
1859
* for overloading resolution (when `preferGeneral is false), and the opposite relation
1862
1860
* `U <: T` or `U convertible to `T` for implicit disambiguation between givens
1863
1861
* (when `preferGeneral` is true). For old-style implicit values, the 3.4 behavior is kept.
1864
- * If one of the alternatives is a given and the other is an implicit , the given wins .
1862
+ * If one of the alternatives is an implicit and the other is a given (or an extension) , the implicit loses .
1865
1863
*
1866
1864
* - In Scala 3.5 and Scala 3.6-migration, we issue a warning if the result under
1867
1865
* Scala 3.6 differ wrt to the old behavior up to 3.5.
1868
1866
*
1869
1867
* Also and only for given resolution: If a compared type refers to a given or its module class, use
1870
1868
* the intersection of its parent classes instead.
1871
1869
*/
1872
- def isAsGoodValueType (tp1 : Type , tp2 : Type , alt1isGiven : Boolean , alt2isGiven : Boolean )(using Context ): Boolean =
1870
+ def isAsGoodValueType (tp1 : Type , tp2 : Type , alt1IsImplicit : Boolean , alt2IsImplicit : Boolean )(using Context ): Boolean =
1873
1871
val oldResolution = ctx.mode.is(Mode .OldImplicitResolution )
1874
1872
if ! preferGeneral || Feature .migrateTo3 && oldResolution then
1875
1873
// Normal specificity test for overloading resolution (where `preferGeneral` is false)
@@ -1887,7 +1885,7 @@ trait Applications extends Compatibility {
1887
1885
1888
1886
if Feature .sourceVersion.isAtMost(SourceVersion .`3.4`)
1889
1887
|| oldResolution
1890
- || ! alt1isGiven && ! alt2isGiven
1888
+ || alt1IsImplicit && alt2IsImplicit
1891
1889
then
1892
1890
// Intermediate rules: better means specialize, but map all type arguments downwards
1893
1891
// These are enabled for 3.0-3.5, and for all comparisons between old-style implicits,
@@ -1902,8 +1900,8 @@ trait Applications extends Compatibility {
1902
1900
case _ => mapOver(t)
1903
1901
(flip(tp1p) relaxed_<:< flip(tp2p)) || viewExists(tp1, tp2)
1904
1902
else
1905
- // New rules: better means generalize, givens always beat implicits
1906
- if alt1isGiven != alt2isGiven then alt1isGiven
1903
+ // New rules: better means generalize, givens (and extensions) always beat implicits
1904
+ if alt1IsImplicit != alt2IsImplicit then alt2IsImplicit
1907
1905
else (tp2p relaxed_<:< tp1p) || viewExists(tp2, tp1)
1908
1906
end isAsGoodValueType
1909
1907
0 commit comments