Skip to content

Commit a183140

Browse files
Revert "Make overload pruning based on result types less aggressive (#21744)" in main (#23331)
Revert #21744 which already was reverted in 3.7.0 and 3.7.1 due to introduced bugs. Resolves #22713
1 parent baabe16 commit a183140

File tree

5 files changed

+15
-47
lines changed

5 files changed

+15
-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
@@ -2167,27 +2167,16 @@ trait Applications extends Compatibility {
21672167
def resolveOverloaded(alts: List[TermRef], pt: Type)(using Context): List[TermRef] =
21682168
record("resolveOverloaded")
21692169

2170-
/** Is `alt` a method or polytype whose approximated result type after the first value parameter
2170+
/** Is `alt` a method or polytype whose result type after the first value parameter
21712171
* section conforms to the expected type `resultType`? If `resultType`
21722172
* is a `IgnoredProto`, pick the underlying type instead.
2173-
*
2174-
* Using an approximated result type is necessary to avoid false negatives
2175-
* due to incomplete type inference such as in tests/pos/i21410.scala and tests/pos/i21410b.scala.
21762173
*/
21772174
def resultConforms(altSym: Symbol, altType: Type, resultType: Type)(using Context): Boolean =
21782175
resultType.revealIgnored match {
21792176
case resultType: ValueType =>
21802177
altType.widen match {
21812178
case tp: PolyType => resultConforms(altSym, instantiateWithTypeVars(tp), resultType)
2182-
case tp: MethodType =>
2183-
val wildRes = wildApprox(tp.resultType)
2184-
2185-
class ResultApprox extends AvoidWildcardsMap:
2186-
// Avoid false negatives by approximating to a lower bound
2187-
variance = -1
2188-
2189-
val approx = ResultApprox()(wildRes)
2190-
constrainResult(altSym, approx, resultType)
2179+
case tp: MethodType => constrainResult(altSym, tp.resultType, resultType)
21912180
case _ => true
21922181
}
21932182
case _ => true
@@ -2559,7 +2548,6 @@ trait Applications extends Compatibility {
25592548
if t.exists && alt.symbol.exists then
25602549
val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss)
25612550
val mappedSym = alt.symbol.asTerm.copy(info = t)
2562-
mappedSym.annotations = alt.symbol.annotations
25632551
mappedSym.rawParamss = trimmed
25642552
val (pre, totalSkipped) = mappedAltInfo(alt.symbol) match
25652553
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.

tests/pos/i22713.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.concurrent.ScheduledExecutorService
2+
import java.util.concurrent.TimeUnit
3+
4+
def Test = {
5+
val worker: ScheduledExecutorService = ???
6+
object Worker extends Runnable {
7+
def fails(): Either[Exception, Unit] = Right(worker.schedule(this, 5, TimeUnit.NANOSECONDS))
8+
def works(): Either[Exception, Unit] = Right {
9+
worker.schedule(this, 5, TimeUnit.NANOSECONDS); ()
10+
}
11+
def run(): Unit = ???
12+
}
13+
}

0 commit comments

Comments
 (0)