Skip to content
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

paramClasses is empty in inline applyDynamic #17761

Closed
andrzejressel opened this issue Jun 3, 2023 · 1 comment · Fixed by #18766
Closed

paramClasses is empty in inline applyDynamic #17761

andrzejressel opened this issue Jun 3, 2023 · 1 comment · Fixed by #18766

Comments

@andrzejressel
Copy link
Contributor

Compiler version

3.3.0

Minimized code

https://scastie.scala-lang.org/wUWQ0uNJRkqyLAz19jO8xw

class MyRecord extends Selectable:
  def applyDynamic(name: String, paramClasses: Class[_]*)(args: Any*): Any = {
    println(name)
    println(paramClasses)
    println(args)
    ()
  }

class MyRecordTransparent extends Selectable:
  inline transparent def applyDynamic(name: String, paramClasses: Class[_]*)(args: Any*): Any = {
    println(name)
    println(paramClasses)
    println(args)
    ()
  }

type Person = MyRecord {
  def test(a: String, b: Int): Unit
}


type PersonTransparent = MyRecordTransparent {
  def test(a: String, b: Int): Unit
}

val person = MyRecord().asInstanceOf[Person]
val personTransparent = MyRecordTransparent().asInstanceOf[PersonTransparent]

println("Normal")
person.test("test", 42)
println("Transparent")
personTransparent.test("test", 42)

Output

Normal
test
ArraySeq(class java.lang.String, int)
ArraySeq(test, 42)
Transparent
test
ArraySeq()
ArraySeq(test, 42)

Expectation

Normal
test
ArraySeq(class java.lang.String, int)
ArraySeq(test, 42)
Transparent
test
ArraySeq(class java.lang.String, int)
ArraySeq(test, 42)
@andrzejressel andrzejressel added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 3, 2023
@jchyb jchyb added area:inline and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 4, 2023
@nicolasstucki nicolasstucki changed the title paramClasses is empty in transparent applyDynamic paramClasses is empty in inline applyDynamic Oct 26, 2023
@nicolasstucki
Copy link
Contributor

The issue is that we first type the tree and then add the Class parameters. In the case of inlining, the call does not exist anymore. See addClassOfs(typed(scall)) bellow.

https://github.com/lampepfl/dotty/blob/94f5cdb880bf04d4c2dcd106efad5629db31b137/compiler/src/dotty/tools/dotc/typer/Dynamic.scala#L198-L213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants