Skip to content

Commit 2c38464

Browse files
Revert "Make overload pruning based on result types less aggressive" in 3.7.0 (#22940)
This reverts #21744 in 3.7.0-RC2 as per #22713 (comment) discussion
2 parents 6089e02 + a07aacf commit 2c38464

File tree

4 files changed

+3
-48
lines changed

4 files changed

+3
-48
lines changed

Diff for: compiler/src/dotty/tools/dotc/typer/Applications.scala

+3-15
Original file line numberDiff line numberDiff line change
@@ -2119,27 +2119,16 @@ trait Applications extends Compatibility {
21192119
def resolveOverloaded(alts: List[TermRef], pt: Type)(using Context): List[TermRef] =
21202120
record("resolveOverloaded")
21212121

2122-
/** Is `alt` a method or polytype whose approximated result type after the first value parameter
2122+
/** Is `alt` a method or polytype whose result type after the first value parameter
21232123
* section conforms to the expected type `resultType`? If `resultType`
21242124
* is a `IgnoredProto`, pick the underlying type instead.
2125-
*
2126-
* Using an approximated result type is necessary to avoid false negatives
2127-
* due to incomplete type inference such as in tests/pos/i21410.scala and tests/pos/i21410b.scala.
21282125
*/
21292126
def resultConforms(altSym: Symbol, altType: Type, resultType: Type)(using Context): Boolean =
21302127
resultType.revealIgnored match {
21312128
case resultType: ValueType =>
21322129
altType.widen match {
2133-
case tp: PolyType => resultConforms(altSym, tp.resultType, resultType)
2134-
case tp: MethodType =>
2135-
val wildRes = wildApprox(tp.resultType)
2136-
2137-
class ResultApprox extends AvoidWildcardsMap:
2138-
// Avoid false negatives by approximating to a lower bound
2139-
variance = -1
2140-
2141-
val approx = ResultApprox()(wildRes)
2142-
constrainResult(altSym, approx, resultType)
2130+
case tp: PolyType => resultConforms(altSym, instantiateWithTypeVars(tp), resultType)
2131+
case tp: MethodType => constrainResult(altSym, tp.resultType, resultType)
21432132
case _ => true
21442133
}
21452134
case _ => true
@@ -2511,7 +2500,6 @@ trait Applications extends Compatibility {
25112500
if t.exists && alt.symbol.exists then
25122501
val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss)
25132502
val mappedSym = alt.symbol.asTerm.copy(info = t)
2514-
mappedSym.annotations = alt.symbol.annotations
25152503
mappedSym.rawParamss = trimmed
25162504
val (pre, totalSkipped) = mappedAltInfo(alt.symbol) match
25172505
case Some((pre, prevSkipped)) =>

Diff for: tests/pos/i21410.scala

-12
This file was deleted.

Diff for: tests/pos/i21410b.scala

-10
This file was deleted.

Diff for: tests/pos/i21410c.scala

-11
This file was deleted.

0 commit comments

Comments
 (0)