Skip to content

Instantly share code, notes, and snippets.

@dkristian
Created August 27, 2013 02:17
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 dkristian/6348965 to your computer and use it in GitHub Desktop.
Save dkristian/6348965 to your computer and use it in GitHub Desktop.
/tmp/return> scalac -version
Scala compiler version 2.10.2 -- Copyright 2002-2013, LAMP/EPFL
/tmp/return> java -version
java version "1.7.0_15"
Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
/tmp/return> echo "object Return { def test(oi:Option[Int]):Option[String] = oi.map(i => return Some(i.toString)) }" > return.scala
/tmp/return> scalac return.scala
/tmp/return> scalac -optimize return.scala
error: could not find init in: Return.test
error: uncaught exception during compilation: scala.reflect.internal.FatalError
error: scala.reflect.internal.FatalError:
while compiling: return.scala
during phase: dce
library version: version 2.10.2
compiler version: version 2.10.2
reconstructed args: -Ydead-code -optimise -Yinline -Yclosure-elim -Yinline-handlers
last tree to typer: Ident(nonLocalReturnKey1$1)
symbol: value nonLocalReturnKey1$1 (flags: <param> <synthetic> <triedcooking>)
symbol definition: nonLocalReturnKey1$1: Object
tpe: Object
symbol owners: value nonLocalReturnKey1$1 -> constructor Return$$anonfun$test$1 -> anonymous class anonfun$test$1 -> package <empty>
context owners: anonymous class anonfun$test$1 -> package <empty>
== Enclosing template or block ==
Template( // val <local $anonfun>: <notype>, tree.tpe=anonfun$test$1
"scala.runtime.AbstractFunction1", "scala.Serializable" // parents
ValDef(
private
"_"
<tpt>
<empty>
)
// 4 statements
DefDef( // final def apply(i: Int): Nothing
<method> final <triedcooking>
"apply"
[]
// 1 parameter list
ValDef( // i: Int
<param> <triedcooking>
"i"
<tpt> // tree.tpe=Int
<empty>
)
<tpt> // tree.tpe=Nothing
Throw( // tree.tpe=Nothing
Apply( // def <init>(key: Object,value: Object): scala.runtime.NonLocalReturnControl in class NonLocalReturnControl, tree.tpe=scala.runtime.NonLocalReturnControl
new runtime.NonLocalReturnControl."<init>" // def <init>(key: Object,value: Object): scala.runtime.NonLocalReturnControl in class NonLocalReturnControl, tree.tpe=(key: Object, value: Object)scala.runtime.NonLocalReturnControl
// 2 arguments
Return$$anonfun$test$1.this."nonLocalReturnKey1$1" // val nonLocalReturnKey1$1: Object, tree.tpe=Object
Apply( // def <init>(x: Object): Some in class Some, tree.tpe=Some
new Some."<init>" // def <init>(x: Object): Some in class Some, tree.tpe=(x: Object)Some
Apply( // def toString(): String in class Object, tree.tpe=String
scala.Int.box(i)."toString" // def toString(): String in class Object, tree.tpe=()String
Nil
)
)
)
)
)
DefDef( // final def apply(v1: Object): Object
<method> final <bridge>
"apply"
[]
// 1 parameter list
ValDef( // v1: Object
<param> <triedcooking>
"v1"
<tpt> // tree.tpe=Object
<empty>
)
<tpt> // tree.tpe=Object
Apply( // final def apply(i: Int): Nothing, tree.tpe=Nothing
Return$$anonfun$test$1.this."apply" // final def apply(i: Int): Nothing, tree.tpe=(i: Int)Nothing
Apply( // def unbox(x: Object): Int in object Int, tree.tpe=Int
"scala"."Int"."unbox" // def unbox(x: Object): Int in object Int, tree.tpe=(x: Object)Int
"v1" // v1: Object, tree.tpe=Object
)
)
)
ValDef( // val nonLocalReturnKey1$1: Object
private <local> <synthetic> <paramaccessor> <triedcooking> <notprotected> <notprivate>
"nonLocalReturnKey1$1"
<tpt> // tree.tpe=Object
<empty>
)
DefDef( // def <init>(nonLocalReturnKey1$1: Object): anonfun$test$1
<method> <triedcooking>
"<init>"
[]
// 1 parameter list
ValDef( // nonLocalReturnKey1$1: Object
<param> <synthetic> <triedcooking>
"nonLocalReturnKey1$1"
<tpt> // tree.tpe=Object
<empty>
)
<tpt> // tree.tpe=anonfun$test$1
Block( // tree.tpe=Unit
// 2 statements
Assign( // tree.tpe=Unit
Return$$anonfun$test$1.this."nonLocalReturnKey1$1" // val nonLocalReturnKey1$1: Object, tree.tpe=Object
"nonLocalReturnKey1$1" // nonLocalReturnKey1$1: Object, tree.tpe=Object
)
Apply( // def <init>(): scala.runtime.AbstractFunction1 in class AbstractFunction1, tree.tpe=scala.runtime.AbstractFunction1
Return$$anonfun$test$1.super."<init>" // def <init>(): scala.runtime.AbstractFunction1 in class AbstractFunction1, tree.tpe=()scala.runtime.AbstractFunction1
Nil
)
()
)
)
)
== Expanded type of tree ==
TypeRef(TypeSymbol(class Object extends ))
could not find init in: Return.test
at scala.reflect.internal.SymbolTable.abort(SymbolTable.scala:49)
at scala.tools.nsc.Global.abort(Global.scala:254)
at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode.scala$tools$nsc$backend$opt$DeadCodeElimination$DeadCode$$findInstruction(DeadCodeElimination.scala:428)
at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode.mark(DeadCodeElimination.scala:250)
at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode.dieCodeDie(DeadCodeElimination.scala:94)
at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCode.analyzeClass(DeadCodeElimination.scala:51)
at scala.tools.nsc.backend.opt.DeadCodeElimination$DeadCodeEliminationPhase.apply(DeadCodeElimination.scala:38)
at scala.tools.nsc.backend.icode.ICodes$ICodePhase$$anonfun$apply$2.apply(ICodes.scala:119)
at scala.tools.nsc.backend.icode.ICodes$ICodePhase$$anonfun$apply$2.apply(ICodes.scala:119)
at scala.collection.mutable.LinkedHashSet.foreach(LinkedHashSet.scala:87)
at scala.tools.nsc.backend.icode.ICodes$ICodePhase.apply(ICodes.scala:119)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:464)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:431)
at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:431)
at scala.collection.Iterator$class.foreach(Iterator.scala:727)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:431)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1583)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1557)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1553)
at scala.tools.nsc.Global$Run.compile(Global.scala:1662)
at scala.tools.nsc.Driver.doCompile(Driver.scala:33)
at scala.tools.nsc.Main$.doCompile(Main.scala:79)
at scala.tools.nsc.Driver.process(Driver.scala:54)
at scala.tools.nsc.Driver.main(Driver.scala:67)
at scala.tools.nsc.Main.main(Main.scala)
/tmp/return>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment