Skip to content

Commit 7895b54

Browse files
committed
Cleanup: Drop isNotGivenClass check
This check was always false since a TermRef cannot have the NotGiven class as a symbol.
1 parent 43bf127 commit 7895b54

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

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

+5-10
Original file line numberDiff line numberDiff line change
@@ -1830,16 +1830,13 @@ trait Applications extends Compatibility {
18301830
isAsGood(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2)
18311831
}
18321832
case _ => // (3)
1833-
def compareValues(tp1: Type, tp2: Type)(using Context) =
1834-
extension (alt: TermRef) def isNotGivenClass: Boolean = alt.symbol == defn.NotGivenClass
1835-
isAsGoodValueType(tp1, tp2, alt1.isNotGivenClass, alt2.isNotGivenClass)
18361833
tp2 match
18371834
case tp2: MethodType => true // (3a)
18381835
case tp2: PolyType if tp2.resultType.isInstanceOf[MethodType] => true // (3a)
18391836
case tp2: PolyType => // (3b)
1840-
explore(compareValues(tp1, instantiateWithTypeVars(tp2)))
1837+
explore(isAsGoodValueType(tp1, instantiateWithTypeVars(tp2)))
18411838
case _ => // 3b)
1842-
compareValues(tp1, tp2)
1839+
isAsGoodValueType(tp1, tp2)
18431840
}
18441841

18451842
/** Test whether value type `tp1` is as good as value type `tp2`.
@@ -1869,15 +1866,14 @@ trait Applications extends Compatibility {
18691866
* for overloading resolution (when `preferGeneral is false), and the opposite relation
18701867
* `U <: T` or `U convertible to `T` for implicit disambiguation between givens
18711868
* (when `preferGeneral` is true). For old-style implicit values, the 3.4 behavior is kept.
1872-
* If one of the alternatives is a NotGivenClass, and the other is not, then the NotGivenClass loses.
18731869
*
18741870
* - In Scala 3.5 and Scala 3.6-migration, we issue a warning if the result under
18751871
* Scala 3.6 differ wrt to the old behavior up to 3.5.
18761872
*
18771873
* Also and only for given resolution: If a compared type refers to a given or its module class, use
18781874
* the intersection of its parent classes instead.
18791875
*/
1880-
def isAsGoodValueType(tp1: Type, tp2: Type, alt1IsNotGivenClass: Boolean, alt2IsNotGivenClass: Boolean)(using Context): Boolean =
1876+
def isAsGoodValueType(tp1: Type, tp2: Type)(using Context): Boolean =
18811877
val oldResolution = ctx.mode.is(Mode.OldImplicitResolution)
18821878
if !preferGeneral || Feature.migrateTo3 && oldResolution then
18831879
// Normal specificity test for overloading resolution (where `preferGeneral` is false)
@@ -1907,9 +1903,8 @@ trait Applications extends Compatibility {
19071903
case _ => mapOver(t)
19081904
(flip(tp1p) relaxed_<:< flip(tp2p)) || viewExists(tp1, tp2)
19091905
else
1910-
// New rules: better means generalize, except `NotGivenClass` which is given lower priority
1911-
if alt1IsNotGivenClass != alt2IsNotGivenClass then alt2IsNotGivenClass
1912-
else (tp2p relaxed_<:< tp1p) || viewExists(tp2, tp1)
1906+
// New rules: better means generalize
1907+
(tp2p relaxed_<:< tp1p) || viewExists(tp2, tp1)
19131908
end isAsGoodValueType
19141909

19151910
/** Widen the result type of synthetic given methods from the implementation class to the

0 commit comments

Comments
 (0)