Skip to content

Commit 9e33c4b

Browse files
authored
Merge pull request #455 from scala/backport-lts-3.3-23331
Backport "Revert "Make overload pruning based on result types less aggressive (scala#21744)" in main" to 3.3 LTS
2 parents 5fdd554 + 0a55772 commit 9e33c4b

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
@@ -1942,27 +1942,16 @@ trait Applications extends Compatibility {
19421942
def resolveOverloaded(alts: List[TermRef], pt: Type)(using Context): List[TermRef] =
19431943
record("resolveOverloaded")
19441944

1945-
/** Is `alt` a method or polytype whose approximated result type after the first value parameter
1945+
/** Is `alt` a method or polytype whose result type after the first value parameter
19461946
* section conforms to the expected type `resultType`? If `resultType`
19471947
* is a `IgnoredProto`, pick the underlying type instead.
1948-
*
1949-
* Using an approximated result type is necessary to avoid false negatives
1950-
* due to incomplete type inference such as in tests/pos/i21410.scala and tests/pos/i21410b.scala.
19511948
*/
19521949
def resultConforms(altSym: Symbol, altType: Type, resultType: Type)(using Context): Boolean =
19531950
resultType.revealIgnored match {
19541951
case resultType: ValueType =>
19551952
altType.widen match {
19561953
case tp: PolyType => resultConforms(altSym, instantiateWithTypeVars(tp), resultType)
1957-
case tp: MethodType =>
1958-
val wildRes = wildApprox(tp.resultType)
1959-
1960-
class ResultApprox extends AvoidWildcardsMap:
1961-
// Avoid false negatives by approximating to a lower bound
1962-
variance = -1
1963-
1964-
val approx = ResultApprox()(wildRes)
1965-
constrainResult(altSym, approx, resultType)
1954+
case tp: MethodType => constrainResult(altSym, tp.resultType, resultType)
19661955
case _ => true
19671956
}
19681957
case _ => true
@@ -2308,7 +2297,6 @@ trait Applications extends Compatibility {
23082297
if t.exists && alt.symbol.exists then
23092298
val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss)
23102299
val mappedSym = alt.symbol.asTerm.copy(info = t)
2311-
mappedSym.annotations = alt.symbol.annotations
23122300
mappedSym.rawParamss = trimmed
23132301
val (pre, totalSkipped) = mappedAltInfo(alt.symbol) match
23142302
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)