Skip to content

Commit 9ff72d4

Browse files
committed
Fix i14451
1 parent c11f5cb commit 9ff72d4

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,17 @@ trait Applications extends Compatibility {
14731473
}
14741474
}
14751475

1476-
/** Drop any implicit parameter section */
1476+
/** Drop any leading type or implicit parameter sections */
1477+
def stripInferrable(tp: Type)(using Context): Type = tp match {
1478+
case mt: MethodType if mt.isImplicitMethod =>
1479+
stripInferrable(resultTypeApprox(mt))
1480+
case pt: PolyType =>
1481+
stripInferrable(pt.resType)
1482+
case _ =>
1483+
tp
1484+
}
1485+
1486+
/** Drop any leading implicit parameter sections */
14771487
def stripImplicit(tp: Type)(using Context): Type = tp match {
14781488
case mt: MethodType if mt.isImplicitMethod =>
14791489
stripImplicit(resultTypeApprox(mt))
@@ -2042,7 +2052,7 @@ trait Applications extends Compatibility {
20422052
skip(alt.widen)
20432053

20442054
def resultIsMethod(tp: Type): Boolean = tp.widen.stripPoly match
2045-
case tp: MethodType => stripImplicit(tp.resultType).isInstanceOf[MethodType]
2055+
case tp: MethodType => stripInferrable(tp.resultType).isInstanceOf[MethodType]
20462056
case _ => false
20472057

20482058
record("resolveOverloaded.narrowedApplicable", candidates.length)

tests/pos/i14451.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
class Foo
3+
4+
extension (dfVal: Foo)
5+
def prevErr[T](step: Int): Foo = ???
6+
def prevErr[T]: Foo = ???
7+
val err = (new Foo).prevErr

0 commit comments

Comments
 (0)