diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 35b8b1f9719d..8de3349931b6 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -1002,7 +1002,10 @@ trait Applications extends Compatibility { case TypeApply(fun, _) => !fun.isInstanceOf[Select] case _ => false } - typedDynamicApply(tree, isInsertedApply, pt) + val tree1 = fun1 match + case Select(_, nme.apply) => tree + case _ => untpd.Apply(fun1, tree.args) + typedDynamicApply(tree1, isInsertedApply, pt) case _ => if (originalProto.isDropped) fun1 else if (fun1.symbol == defn.Compiletime_summonFrom) diff --git a/tests/pos/i16544a.scala b/tests/pos/i16544a.scala new file mode 100644 index 000000000000..b5afdaec75d0 --- /dev/null +++ b/tests/pos/i16544a.scala @@ -0,0 +1,49 @@ +import scala.language.dynamics + +object Foo extends Dynamic: + def applyDynamic(name: String)(): Foo.type = this + +object Test: + def test(): Foo.type = + Foo.xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() + .xxx() diff --git a/tests/pos/i16544b.scala b/tests/pos/i16544b.scala new file mode 100644 index 000000000000..f8450e6dfa85 --- /dev/null +++ b/tests/pos/i16544b.scala @@ -0,0 +1,49 @@ +import scala.language.dynamics + +object Foo extends Dynamic: + def applyDynamicNamed(name: String)(args: (String, Int)): Foo.type = this + +object Test: + def test(): Foo.type = + Foo.xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) + .xxx(a = 1) diff --git a/tests/pos/i16544c.scala b/tests/pos/i16544c.scala new file mode 100644 index 000000000000..5467d76918c7 --- /dev/null +++ b/tests/pos/i16544c.scala @@ -0,0 +1,49 @@ +import scala.language.dynamics + +object Foo extends Dynamic: + def selectDynamic(name: String): Foo.type = this + +object Test: + def test(): Foo.type = + Foo.xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx + .xxx diff --git a/tests/pos/i16544d.scala b/tests/pos/i16544d.scala new file mode 100644 index 000000000000..1057df65e892 --- /dev/null +++ b/tests/pos/i16544d.scala @@ -0,0 +1,49 @@ +import scala.language.dynamics + +object Foo extends Dynamic: + def applyDynamic(name: String)(): Foo.type = this + def applyDynamicNamed(name: String)(args: (String, Int)): Foo.type = this + def selectDynamic(name: String): Foo.type = this + +object Test: + def test(): Foo.type = + Foo.xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx + .xxx() + .xxx(a = 1) + .xxx