Implicit resolution for TypeTag involves ClassDefs
Closed this issue · 2 comments
DataBag(jabberwocky)
After fixing some other problem with Meta
[1], reifying the above code looks like this:
DataBag.apply(BaseCodegenTest.jabberwocky)(`package`.meta(Predef.this.implicitly, Predef.this.implicitly))
(The first implicitly
is for ClassTag
, and the second one is for TypeTag
.) So far so good.
However, after typechecking, it looks like this:
DataBag.apply[String](BaseCodegenTest.jabberwocky)(`package`.meta[String](Predef.this.implicitly[scala.reflect.ClassTag[String]](((ClassTag.apply[String](classOf[java.lang.String])): scala.reflect.ClassTag[String])), Predef.this.implicitly[reflect.runtime.universe.TypeTag[String]]((({
val $u: scala.reflect.runtime.`package`.universe.type = scala.reflect.runtime.`package`.universe;
val $m: $u.Mirror = scala.reflect.runtime.`package`.universe.runtimeMirror(({
final class $anon {
()
};
new $anon()
}).getClass().getClassLoader());
$u.TypeTag.apply[String]($m, {
final class $typecreator1 extends TypeCreator {
def apply[U <: Universe with Singleton]($m$untyped: Mirror[U]): (U)#Type = {
val $u: U = $m$untyped.universe;
val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
$u.internal.reificationSupport.TypeRef($u.internal.reificationSupport.SingleType($u.internal.reificationSupport.ThisType($m.staticPackage("scala").asModule.moduleClass), $m.staticModule("scala.Predef")), $u.internal.reificationSupport.selectType($m.staticModule("scala.Predef").asModule.moduleClass, "String"), scala.collection.immutable.Nil)
}
};
new $typecreator1()
})
}): reflect.runtime.universe.TypeTag[String]))))
The problem with this is that it has ClassDefs. This causes trouble later in the compiler pipeline, because we thought that we don't have to handle ClassDefs in Emma's compiler pipeline (since ClassDefs are not valid in the source language). Specifically, the first problem that I ran into is that the constructors of these classes, which are named <init>
, are renamed to <init>$1
, <init>$2
, ... by resolveNameClashes.
[1] b83b056
This is fixed with #250 which removes the Meta
implicits in the compiler pre-pass.
Aha, OK, cool!