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