Skip to content

Commit 8585994

Browse files
committed
Fix #7070: Allow for inserted applies when checking extension methods
1 parent c9d2f34 commit 8585994

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,12 +1883,12 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
18831883
val app =
18841884
typed(untpd.Apply(core, untpd.TypedSplice(receiver) :: Nil), pt1, ctx.typerState.ownedVars)(
18851885
ctx.addMode(Mode.SynthesizeExtMethodReceiver))
1886-
val appSym =
1887-
app match {
1888-
case Inlined(call, _, _) => call.symbol
1889-
case _ => app.symbol
1890-
}
1891-
if (!appSym.is(Extension))
1886+
def isExtension(tree: Tree): Boolean = methPart(tree) match {
1887+
case Inlined(call, _, _) => isExtension(call)
1888+
case tree @ Select(qual, nme.apply) => tree.symbol.is(Extension) || isExtension(qual)
1889+
case tree => tree.symbol.is(Extension)
1890+
}
1891+
if (!isExtension(app))
18921892
ctx.error(em"not an extension method: $methodRef", receiver.sourcePos)
18931893
app
18941894
}

tests/pos/i7070.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Test {
2+
3+
class C
4+
5+
def (str: String) foo: given C => Int = ???
6+
7+
given as C = ???
8+
9+
val strFoo = "".foo
10+
}

0 commit comments

Comments
 (0)