diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 71fc250d0710..058cd2de332c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -2119,27 +2119,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, tp.resultType, 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: PolyType => resultConforms(altSym, instantiateWithTypeVars(tp), resultType) + case tp: MethodType => constrainResult(altSym, tp.resultType, resultType) case _ => true } case _ => true @@ -2511,7 +2500,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)) => diff --git a/tests/pos/i21410.scala b/tests/pos/i21410.scala deleted file mode 100644 index c3ba3ea862bc..000000000000 --- a/tests/pos/i21410.scala +++ /dev/null @@ -1,12 +0,0 @@ -class A -object Test: - type F[X] <: Any = X match - case A => Int - - def foo[T](x: String): T = ??? - def foo[U](x: U): F[U] = ??? - - val x1 = foo(A()) - val y: Int = x1 - - val x2: Int = foo(A()) // error diff --git a/tests/pos/i21410b.scala b/tests/pos/i21410b.scala deleted file mode 100644 index a17ad59bc59e..000000000000 --- a/tests/pos/i21410b.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test: - def foo[T](x: Option[T]): T = ??? - def foo[T <: Tuple](x: T): Tuple.Map[T, List] = ??? - - val tup: (Int, String) = (1, "") - - val x = foo(tup) - val y: (List[Int], List[String]) = x - - val x2: (List[Int], List[String]) = foo(tup) // error diff --git a/tests/pos/i21410c.scala b/tests/pos/i21410c.scala deleted file mode 100644 index 21f69fec20fa..000000000000 --- a/tests/pos/i21410c.scala +++ /dev/null @@ -1,11 +0,0 @@ -class AppliedPIso[A, B]() -case class User(age: Int) - -object Test: - extension [From, To](from: From) - def focus(): AppliedPIso[From, From] = ??? - transparent inline def focus(inline lambda: (From => To)): Any = ??? - - - val u = User(1) - val ap: AppliedPIso[User, User] = u.focus(_.age) // error