@@ -1830,10 +1830,8 @@ trait Applications extends Compatibility {
1830
1830
isAsGood(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2)
1831
1831
}
1832
1832
case _ => // (3)
1833
- def isGiven (alt : TermRef ) =
1834
- alt1.symbol.is(Given ) && alt.symbol != defn.NotGivenClass
1835
1833
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 ))
1837
1835
tp2 match
1838
1836
case tp2 : MethodType => true // (3a)
1839
1837
case tp2 : PolyType if tp2.resultType.isInstanceOf [MethodType ] => true // (3a)
@@ -1851,7 +1849,7 @@ trait Applications extends Compatibility {
1851
1849
* available in 3.0-migration if mode `Mode.OldImplicitResolution` is turned on as well.
1852
1850
* It is used to highlight differences between Scala 2 and 3 behavior.
1853
1851
*
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
1855
1853
* from `T` to `U`, or
1856
1854
*
1857
1855
* flip(T) <: flip(U)
@@ -1870,15 +1868,15 @@ trait Applications extends Compatibility {
1870
1868
* for overloading resolution (when `preferGeneral is false), and the opposite relation
1871
1869
* `U <: T` or `U convertible to `T` for implicit disambiguation between givens
1872
1870
* (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 .
1874
1872
*
1875
1873
* - In Scala 3.5 and Scala 3.6-migration, we issue a warning if the result under
1876
1874
* Scala 3.6 differ wrt to the old behavior up to 3.5.
1877
1875
*
1878
1876
* Also and only for given resolution: If a compared type refers to a given or its module class, use
1879
1877
* the intersection of its parent classes instead.
1880
1878
*/
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 =
1882
1880
val oldResolution = ctx.mode.is(Mode .OldImplicitResolution )
1883
1881
if ! preferGeneral || Feature .migrateTo3 && oldResolution then
1884
1882
// Normal specificity test for overloading resolution (where `preferGeneral` is false)
@@ -1896,7 +1894,7 @@ trait Applications extends Compatibility {
1896
1894
1897
1895
if Feature .sourceVersion.isAtMost(SourceVersion .`3.4`)
1898
1896
|| oldResolution
1899
- || ! alt1isGiven && ! alt2isGiven
1897
+ || alt1IsImplicit && alt2IsImplicit
1900
1898
then
1901
1899
// Intermediate rules: better means specialize, but map all type arguments downwards
1902
1900
// These are enabled for 3.0-3.5, and for all comparisons between old-style implicits,
@@ -1911,8 +1909,8 @@ trait Applications extends Compatibility {
1911
1909
case _ => mapOver(t)
1912
1910
(flip(tp1p) relaxed_<:< flip(tp2p)) || viewExists(tp1, tp2)
1913
1911
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
1916
1914
else (tp2p relaxed_<:< tp1p) || viewExists(tp2, tp1)
1917
1915
end isAsGoodValueType
1918
1916
0 commit comments