Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2140,27 +2140,16 @@ trait Applications extends Compatibility {
def resolveOverloaded(alts: List[TermRef], pt: Type)(using Context): List[TermRef] =
record("resolveOverloaded")

/** Is `alt` a method or polytype whose approximated result type after the first value parameter
/** Is `alt` a method or polytype whose result type after the first value parameter
* section conforms to the expected type `resultType`? If `resultType`
* is a `IgnoredProto`, pick the underlying type instead.
*
* Using an approximated result type is necessary to avoid false negatives
* due to incomplete type inference such as in tests/pos/i21410.scala and tests/pos/i21410b.scala.
*/
def resultConforms(altSym: Symbol, altType: Type, resultType: Type)(using Context): Boolean =
resultType.revealIgnored match {
case resultType: ValueType =>
altType.widen match {
case tp: PolyType => resultConforms(altSym, instantiateWithTypeVars(tp), resultType)
case tp: MethodType =>
val wildRes = wildApprox(tp.resultType)

class ResultApprox extends AvoidWildcardsMap:
// Avoid false negatives by approximating to a lower bound
variance = -1

val approx = ResultApprox()(wildRes)
constrainResult(altSym, approx, resultType)
case tp: MethodType => constrainResult(altSym, tp.resultType, resultType)
case _ => true
}
case _ => true
Expand Down Expand Up @@ -2532,7 +2521,6 @@ trait Applications extends Compatibility {
if t.exists && alt.symbol.exists then
val (trimmed, skipped) = trimParamss(t.stripPoly, alt.symbol.rawParamss)
val mappedSym = alt.symbol.asTerm.copy(info = t)
mappedSym.annotations = alt.symbol.annotations
mappedSym.rawParamss = trimmed
val (pre, totalSkipped) = mappedAltInfo(alt.symbol) match
case Some((pre, prevSkipped)) =>
Expand Down
12 changes: 0 additions & 12 deletions tests/pos/i21410.scala

This file was deleted.

10 changes: 0 additions & 10 deletions tests/pos/i21410b.scala

This file was deleted.

11 changes: 0 additions & 11 deletions tests/pos/i21410c.scala

This file was deleted.

Loading