Skip to content

Reuse typed prefix for applyDynamic and applyDynamicNamed #16552

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 1 commit into from
Dec 20, 2022
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
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 49 additions & 0 deletions tests/pos/i16544a.scala
Original file line number Diff line number Diff line change
@@ -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()
49 changes: 49 additions & 0 deletions tests/pos/i16544b.scala
Original file line number Diff line number Diff line change
@@ -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)
49 changes: 49 additions & 0 deletions tests/pos/i16544c.scala
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions tests/pos/i16544d.scala
Original file line number Diff line number Diff line change
@@ -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