Skip to content

Instantly share code, notes, and snippets.

@lihaoyi
Created October 3, 2015 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lihaoyi/9adfc198cf1b9539bc5f to your computer and use it in GitHub Desktop.
Save lihaoyi/9adfc198cf1b9539bc5f to your computer and use it in GitHub Desktop.
Welcome to Scala version 2.11.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_25).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scala.reflect.macros.blackbox.Context; import scala.language.experimental.macros
import scala.reflect.macros.blackbox.Context
import scala.language.experimental.macros
scala> def applyImpl(c: Context)(expr: c.Expr[Unit]): c.Expr[Nothing] = {
| import c.universe._
|
| c.Expr[Nothing](q"""{..${expr.tree.children}; ???}""")
| }
applyImpl: (c: scala.reflect.macros.blackbox.Context)(expr: c.Expr[Unit])c.Expr[Nothing]
scala> def apply(expr: Unit): Nothing = macro applyImpl
defined term macro apply: (expr: Unit)Nothing
scala> apply{lazy val x = 1}
ReplGlobal.abort: Unexpected tree in genLoad: final <stable> private[this] def x$1(x$lzy$1: runtime.IntRef, bitmap$0$1: runtime.VolatileByteRef): Int = {
x$lzy$1.elem = 1;
x$lzy$1.elem
}/class scala.reflect.internal.Trees$DefDef at: source-<console>,line-12,offset=264
error: Unexpected tree in genLoad: final <stable> private[this] def x$1(x$lzy$1: runtime.IntRef, bitmap$0$1: runtime.VolatileByteRef): Int = {
x$lzy$1.elem = 1;
x$lzy$1.elem
}/class scala.reflect.internal.Trees$DefDef at: source-<console>,line-12,offset=264
scala.reflect.internal.FatalError: Unexpected tree in genLoad: final <stable> private[this] def x$1(x$lzy$1: runtime.IntRef, bitmap$0$1: runtime.VolatileByteRef): Int = {
x$lzy$1.elem = 1;
x$lzy$1.elem
}/class scala.reflect.internal.Trees$DefDef at: source-<console>,line-12,offset=264
at scala.reflect.internal.Reporting$class.abort(Reporting.scala:59)
at scala.tools.nsc.interpreter.IMain$$anon$1.scala$tools$nsc$interpreter$ReplGlobal$$super$abort(IMain.scala:243)
at scala.tools.nsc.interpreter.ReplGlobal$class.abort(ReplGlobal.scala:20)
at scala.tools.nsc.interpreter.IMain$$anon$1.abort(IMain.scala:243)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:1010)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genStat(GenICode.scala:181)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:155)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:155)
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:124)
at scala.collection.immutable.List.foldLeft(List.scala:84)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:915)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:924)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:916)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genStat(GenICode.scala:170)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:155)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase$$anonfun$genStat$1.apply(GenICode.scala:155)
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:124)
at scala.collection.immutable.List.foldLeft(List.scala:84)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.scala$tools$nsc$backend$icode$GenICode$ICodePhase$$genLoad(GenICode.scala:915)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:123)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:71)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:148)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:98)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:71)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:89)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.gen(GenICode.scala:67)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.apply(GenICode.scala:63)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$applyPhase$1.apply$mcV$sp(Global.scala:441)
at scala.tools.nsc.Global$GlobalPhase.withCurrentUnit(Global.scala:432)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:441)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:399)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:399)
at scala.collection.Iterator$class.foreach(Iterator.scala:750)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1202)
at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:399)
at scala.tools.nsc.backend.icode.GenICode$ICodePhase.run(GenICode.scala:55)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1500)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1487)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1482)
at scala.tools.nsc.interpreter.IMain.compileSourcesKeepingRun(IMain.scala:425)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compileAndSaveRun(IMain.scala:841)
at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:800)
at scala.tools.nsc.interpreter.IMain$Request.compile$lzycompute(IMain.scala:976)
at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:971)
at scala.tools.nsc.interpreter.IMain.compile(IMain.scala:568)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:556)
at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:554)
at scala.tools.nsc.interpreter.ILoop.reallyInterpret$1(ILoop.scala:802)
at scala.tools.nsc.interpreter.ILoop.interpretStartingWith(ILoop.scala:847)
at scala.tools.nsc.interpreter.ILoop.command(ILoop.scala:705)
at scala.tools.nsc.interpreter.ILoop.processLine(ILoop.scala:404)
at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:430)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply$mcZ$sp(ILoop.scala:918)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:904)
at scala.tools.nsc.interpreter.ILoop$$anonfun$process$1.apply(ILoop.scala:904)
at scala.reflect.internal.util.ScalaClassLoader$.savingContextLoader(ScalaClassLoader.scala:97)
at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:904)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:74)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
That entry seems to have slain the compiler. Shall I replay
your session? I can re-run each line except the last one.
[y/n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment