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
18 changes: 14 additions & 4 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1837,13 +1837,23 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
* <methodRef>(<receiver>) or
* <methodRef>[<type-args>](<receiver>)
*
* where <type-args> comes from `pt` if it is a PolyProto.
* where <type-args> comes from `pt` if it is a (possibly ignored) PolyProto.
*/
def extMethodApply(methodRef: untpd.Tree, receiver: Tree, pt: Type)(implicit ctx: Context) = {
val (core, pt1) = pt.revealIgnored match {
case PolyProto(targs, restpe) => (untpd.TypeApply(methodRef, targs.map(untpd.TypedSplice(_))), restpe)
case _ => (methodRef, pt)
/** Integrate the type arguments from `currentPt` into `methodRef`, and produce
* a matching expected type.
* If `currentPt` is ignored, the new expected type will be ignored too.
*/
def integrateTypeArgs(currentPt: Type, wasIgnored: Boolean = false): (untpd.Tree, Type) = currentPt match {
case IgnoredProto(ignored) =>
integrateTypeArgs(ignored, wasIgnored = true)
case PolyProto(targs, restpe) =>
val core = untpd.TypeApply(methodRef, targs.map(untpd.TypedSplice(_)))
(core, if (wasIgnored) IgnoredProto(restpe) else restpe)
case _ =>
(methodRef, pt)
}
val (core, pt1) = integrateTypeArgs(pt)
val app =
typed(untpd.Apply(core, untpd.TypedSplice(receiver) :: Nil), pt1, ctx.typerState.ownedVars)(
ctx.addMode(Mode.SynthesizeExtMethodReceiver))
Expand Down
8 changes: 8 additions & 0 deletions tests/pos/i6900.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
object Test {
given bla[A] { def (a: A) foo[C]: C => A = _ => a }

1.foo.foo
1.foo.foo[String]
1.foo[String].foo
1.foo[String].foo[String]
}