Skip to content

Commit 17f3bde

Browse files
committed
Revert "Make overload pruning based on result types less aggressive (scala#21744)"
This reverts commit 93af7b8, reversing changes made to 7d79c56.
1 parent 5298be0 commit 17f3bde

File tree

4 files changed

+2
-47
lines changed

4 files changed

+2
-47
lines changed

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,27 +2169,16 @@ trait Applications extends Compatibility {
21692169
def resolveOverloaded(alts: List[TermRef], pt: Type)(using Context): List[TermRef] =
21702170
record("resolveOverloaded")
21712171

2172-
/** Is `alt` a method or polytype whose approximated result type after the first value parameter
2172+
/** Is `alt` a method or polytype whose result type after the first value parameter
21732173
* section conforms to the expected type `resultType`? If `resultType`
21742174
* is a `IgnoredProto`, pick the underlying type instead.
2175-
*
2176-
* Using an approximated result type is necessary to avoid false negatives
2177-
* due to incomplete type inference such as in tests/pos/i21410.scala and tests/pos/i21410b.scala.
21782175
*/
21792176
def resultConforms(altSym: Symbol, altType: Type, resultType: Type)(using Context): Boolean =
21802177
resultType.revealIgnored match {
21812178
case resultType: ValueType =>
21822179
altType.widen match {
21832180
case tp: PolyType => resultConforms(altSym, instantiateWithTypeVars(tp), resultType)
2184-
case tp: MethodType =>
2185-
val wildRes = wildApprox(tp.resultType)
2186-
2187-
class ResultApprox extends AvoidWildcardsMap:
2188-
// Avoid false negatives by approximating to a lower bound
2189-
variance = -1
2190-
2191-
val approx = ResultApprox()(wildRes)
2192-
constrainResult(altSym, approx, resultType)
2181+
case tp: MethodType => constrainResult(altSym, tp.resultType, resultType)
21932182
case _ => true
21942183
}
21952184
case _ => true
@@ -2561,7 +2550,6 @@ trait Applications extends Compatibility {
25612550
if t.exists && alt.symbol.exists then
25622551
val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss)
25632552
val mappedSym = alt.symbol.asTerm.copy(info = t)
2564-
mappedSym.annotations = alt.symbol.annotations
25652553
mappedSym.rawParamss = trimmed
25662554
val (pre, totalSkipped) = mappedAltInfo(alt.symbol) match
25672555
case Some((pre, prevSkipped)) =>

tests/pos/i21410.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/pos/i21410b.scala

Lines changed: 0 additions & 10 deletions
This file was deleted.

tests/pos/i21410c.scala

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)