Skip to content

Fix i14451 #16010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
14 changes: 12 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1473,7 +1473,17 @@ trait Applications extends Compatibility {
}
}

/** Drop any implicit parameter section */
/** Drop any leading type or implicit parameter sections */
def stripInferrable(tp: Type)(using Context): Type = tp match {
case mt: MethodType if mt.isImplicitMethod =>
stripInferrable(resultTypeApprox(mt))
case pt: PolyType =>
stripInferrable(pt.resType)
case _ =>
tp
}

/** Drop any leading implicit parameter sections */
def stripImplicit(tp: Type)(using Context): Type = tp match {
case mt: MethodType if mt.isImplicitMethod =>
stripImplicit(resultTypeApprox(mt))
Expand Down Expand Up @@ -2042,7 +2052,7 @@ trait Applications extends Compatibility {
skip(alt.widen)

def resultIsMethod(tp: Type): Boolean = tp.widen.stripPoly match
case tp: MethodType => stripImplicit(tp.resultType).isInstanceOf[MethodType]
case tp: MethodType => stripInferrable(tp.resultType).isInstanceOf[MethodType]
case _ => false

record("resolveOverloaded.narrowedApplicable", candidates.length)
Expand Down
27 changes: 27 additions & 0 deletions tests/pos/i14451.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

class Foo

extension (dfVal: Foo)
def f0(step: Int): Foo = ???
def f0: Foo = ???
val v0 = (new Foo).f0

extension (dfVal: Foo)
def f1[T](step: Int): Foo = ???
def f1: Foo = ???
val v1 = (new Foo).f1

extension (dfVal: Foo)
def f2[T](step: Int): Foo = ???
def f2[T]: Foo = ???
val v2 = (new Foo).f2

extension [A](dfVal: Foo)
def f3[T](step: Int): Foo = ???
def f3: Foo = ???
val v3 = (new Foo).f3

extension [A](dfVal: Foo)
def f4[T](step: Int): Foo = ???
def f4[T]: Foo = ???
val v4 = (new Foo).f4