You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importscala.reflect.runtime.universe._importscala.tools.reflect.ToolBox//case class Foo() // Works if Foo is defined here insteadobjectHelloWorld {
caseclassFoo()
defmain(args: Array[String]) {
valtb= runtimeMirror(getClass.getClassLoader).mkToolBox()
tb.compile(tb.parse("()")) // It works, if we comment this out//tb.typecheck(reify{()}.tree) // It works, if we uncomment thisvalfoo=Foo()
valexp= reify {foo: Foo}
tb.typecheck(exp.tree)
}
}
The typecheck in the last line fails with
Exception in thread "main" scala.tools.reflect.ToolBoxError: reflective typecheck has failed: typemismatch;
found : HelloWorld.(some other)Foo(in objectHelloWorld)
required: HelloWorld.Foo(in objectHelloWorld)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.$anonfun$typecheck$1(ToolBoxFactory.scala:182)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.$anonfun$transformDuringTyper$4(ToolBoxFactory.scala:150)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.$anonfun$transformDuringTyper$3(ToolBoxFactory.scala:150)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.$anonfun$transformDuringTyper$1(ToolBoxFactory.scala:149)
at scala.reflect.internal.Trees.wrappingIntoTerm(Trees.scala:1710)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.withWrapping$1(ToolBoxFactory.scala:119)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.transformDuringTyper(ToolBoxFactory.scala:120)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$ToolBoxGlobal.typecheck(ToolBoxFactory.scala:174)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.$anonfun$typecheck$6(ToolBoxFactory.scala:379)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl$withCompilerApi$.apply(ToolBoxFactory.scala:359)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.typecheck(ToolBoxFactory.scala:371)
at scala.tools.reflect.ToolBoxFactory$ToolBoxImpl.typecheck(ToolBoxFactory.scala:26)
at HelloWorld$.main(HelloWorld.scala:18)
at HelloWorld.main(HelloWorld.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
A workaround is to call tb.typecheck on a very simple tree after every call to tb.compile.
Note that this is a similar bug to #8637, but it is different.
The text was updated successfully, but these errors were encountered:
The typecheck in the last line fails with
A workaround is to call
tb.typecheck
on a very simple tree after every call totb.compile
.Note that this is a similar bug to #8637, but it is different.
The text was updated successfully, but these errors were encountered: