epfldata/squid

Generic arguments of inner classes disappear

Closed this issue · 2 comments

If I have a generic class that is also an inner class, then the generic arguments fall off. For example, if I have

class Foo {
  class Foo3[A]
}

And then I do

val y: Foo#Foo3[Int] = ???

Then this turns into

  val y_0 = ((scala.Predef.???): (test.Foo)#Foo3);
  ()

which fails to compile with

Error:(37, 23) class Foo3 takes type parameters

Here is a commit in the squid-examples repo demonstrating the issue:
ggevay/squid-examples@01ed744

Edit: I pasted the wrong commit

LPTK commented

Thanks for the report! The type arguments were actually correctly represented internally, but there was an omission in the Scala tree reinterpreter (the thing to outputs Scala trees from the current IR).

By the way, I highly recommend that you do this kind of testing and debugging using quasiquotes (as in the tests), which are a more normal/usual way of embedding code with Squid. Quasiquotes are more convenient, as they let you use symbols that are defined in the same compilation unit, and they also let you know exactly what code is used to do the embedding (if you write dbg_code"...").

Thank you very much!