Created
December 27, 2019 15:24
-
-
Save gzoller/db172f04ceabd3536cb034fb74493827 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package co.blocke.reflect | |
import scala.tasty.file._ | |
import scala.tasty.Reflection | |
object Main extends App { | |
val p = Person("Fred", 53) | |
ReflectClass.showInfo(p) | |
} | |
case class Person(name:String, age:Int) | |
object ReflectClass { | |
def showInfo[T](instance: T): Unit = { | |
val consumer = new Consumer() | |
ConsumeTasty(".", List("co.blocke.reflect.Person"), consumer) | |
} | |
} | |
class Consumer extends TastyConsumer { | |
final def apply(reflect: Reflection)(root: reflect.Tree): Unit = { | |
import reflect._ | |
// Do something with the tree | |
println("HERE!") | |
} | |
} | |
/* When run, this produces this exception: | |
[info] running co.blocke.reflect.Main | |
cannot take signature of (): Object | |
java.lang.ClassCastException: class dotty.tools.dotc.core.Symbols$NoSymbol$ cannot be cast to class dotty.tools.dotc.core.Symbols$ClassSymbol (dotty.tools.dotc.core.Symbols$NoSymbol$ and dotty.tools.dotc.core.Symbols$ClassSymbol are in unnamed module of loader sbt.internal.LayeredClassLoader @6a67569d) while compiling co.blocke.reflect.Person | |
[error] (run-main-2) java.lang.ExceptionInInitializerError | |
[error] java.lang.ExceptionInInitializerError | |
[error] at co.blocke.reflect.Main.main(ReflectClass.scala) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:567) | |
[error] Caused by: java.lang.reflect.InvocationTargetException | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:567) | |
[error] at scala.tasty.file.ConsumeTasty$.apply(ConsumeTasty.scala:16) | |
[error] at co.blocke.reflect.ReflectClass$.showInfo(ReflectClass.scala:19) | |
[error] at co.blocke.reflect.Main$.<init>(ReflectClass.scala:10) | |
[error] at co.blocke.reflect.Main$.<clinit>(ReflectClass.scala) | |
[error] at co.blocke.reflect.Main.main(ReflectClass.scala) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:567) | |
[error] Caused by: java.lang.ClassCastException: class dotty.tools.dotc.core.Symbols$NoSymbol$ cannot be cast to class dotty.tools.dotc.core.Symbols$ClassSymbol (dotty.tools.dotc.core.Symbols$NoSymbol$ and dotty.tools.dotc.core.Symbols$ClassSymbol are in unnamed module of loader sbt.internal.LayeredClassLoader @6a67569d) | |
[error] at dotty.tools.dotc.core.Symbols$Symbol.asClass(Symbols.scala:539) | |
[error] at dotty.tools.dotc.core.Definitions.UnitClass(Definitions.scala:453) | |
[error] at dotty.tools.dotc.core.Types$MethodicType.resultSignature(Types.scala:3006) | |
[error] at dotty.tools.dotc.core.Types$MethodOrPoly.resultSignature(Types.scala:3147) | |
[error] at dotty.tools.dotc.core.Types$MethodType.computeSignature(Types.scala:3306) | |
[error] at dotty.tools.dotc.core.Types$SignatureCachingType.signature(Types.scala:2995) | |
[error] at dotty.tools.dotc.core.Types$MethodOrPoly.signature(Types.scala:3147) | |
[error] at dotty.tools.dotc.core.Denotations$SingleDenotation.signature(Denotations.scala:739) | |
[error] at dotty.tools.dotc.core.Denotations$SingleDenotation.atSignature(Denotations.scala:771) | |
[error] at dotty.tools.dotc.core.Denotations$SingleDenotation.atSignature(Denotations.scala:769) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler.dotty$tools$dotc$core$tasty$TreeUnpickler$TreeReader$$_$accessibleDenot$1(TreeUnpickler.scala:1044) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.completeSelect$1(TreeUnpickler.scala:1026) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readSimpleTerm$1(TreeUnpickler.scala:1058) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1212) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readLengthTerm$1(TreeUnpickler.scala:1090) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTerm(TreeUnpickler.scala:1212) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.$anonfun$3(TreeUnpickler.scala:889) | |
[error] at dotty.tools.tasty.TastyReader.collectWhile(TastyReader.scala:137) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readTemplate(TreeUnpickler.scala:892) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readNewDef(TreeUnpickler.scala:818) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$TreeReader.readIndexedDef(TreeUnpickler.scala:743) | |
[error] at dotty.tools.dotc.core.tasty.TreeUnpickler$Completer.complete(TreeUnpickler.scala:119) | |
[error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:258) | |
[error] at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:185) | |
[error] at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:187) | |
[error] at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:398) | |
[error] at dotty.tools.dotc.core.Symbols$ClassSymbol.rootTreeContaining(Symbols.scala:751) | |
[error] at dotty.tools.dotc.core.Symbols$ClassSymbol.rootTree(Symbols.scala:742) | |
[error] at dotty.tools.dotc.fromtasty.ReadTasty.compilationUnit$1(ReadTasty.scala:44) | |
[error] at dotty.tools.dotc.fromtasty.ReadTasty.readTASTY(ReadTasty.scala:71) | |
[error] at dotty.tools.dotc.fromtasty.ReadTasty.runOn$$anonfun$1(ReadTasty.scala:24) | |
[error] at scala.collection.immutable.List.flatMap(List.scala:265) | |
[error] at dotty.tools.dotc.fromtasty.ReadTasty.runOn(ReadTasty.scala:24) | |
[error] at dotty.tools.dotc.Run.runPhases$4$$anonfun$4(Run.scala:161) | |
[error] at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15) | |
[error] at dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10) | |
[error] at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323) | |
[error] at dotty.tools.dotc.Run.runPhases$5(Run.scala:171) | |
[error] at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:179) | |
[error] at dotty.runtime.function.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12) | |
[error] at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:65) | |
[error] at dotty.tools.dotc.Run.compileUnits(Run.scala:186) | |
[error] at dotty.tools.dotc.Run.compileUnits(Run.scala:128) | |
[error] at dotty.tools.dotc.fromtasty.TASTYRun.compile(TASTYRun.scala:10) | |
[error] at dotty.tools.dotc.Driver.doCompile(Driver.scala:36) | |
[error] at dotty.tools.dotc.Driver.process(Driver.scala:189) | |
[error] at dotty.tools.dotc.Driver.process(Driver.scala:158) | |
[error] at dotty.tools.dotc.Driver.process(Driver.scala:170) | |
[error] at dotty.tools.dotc.consumetasty.ConsumeTasty$.apply(ConsumeTasty.scala:24) | |
[error] at dotty.tools.dotc.consumetasty.ConsumeTasty.apply(ConsumeTasty.scala) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:567) | |
[error] at scala.tasty.file.ConsumeTasty$.apply(ConsumeTasty.scala:16) | |
[error] at co.blocke.reflect.ReflectClass$.showInfo(ReflectClass.scala:19) | |
[error] at co.blocke.reflect.Main$.<init>(ReflectClass.scala:10) | |
[error] at co.blocke.reflect.Main$.<clinit>(ReflectClass.scala) | |
[error] at co.blocke.reflect.Main.main(ReflectClass.scala) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | |
[error] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) | |
[error] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) | |
[error] at java.base/java.lang.reflect.Method.invoke(Method.java:567) | |
[error] stack trace is suppressed; run last Compile / bgRun for the full output | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment