New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Elided invocation on RHS throws compile-time exception on primitive conversion #5051
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5051?orig=1 |
@som-snytt said: package elysian
class ElysianFields {
import ElysianFields._
def run() {
//oops // OK
feature
println("Hello, "+ bugInWaiting.getClass.getName)
}
def feature: Char = oops // DNC
//def feature: Unit = oops // OK
//java.lang.ClassCastException: scala.runtime.BoxedUnit cannot be cast to elysian.ElysianFields
//val bugInWaiting: ElysianFields = oops // OK to elide?
val bugInWaiting: AnyRef = oops // OK
}
object ElysianFields {
import annotation.elidable
import annotation.elidable._
@elidable(150)
def oops = throw new UnsupportedOperationException
def main(args: Array[String]) {
new ElysianFields().run()
}
} |
@paulp said: |
@som-snytt said: I'll try to figure out how the elidable deltas broke the build. I can attest that git pull and ant test worked on my machine, but there may be interactions with later commits. I'll have to learn how to use git to fetch the commits. |
@paulp said: |
@som-snytt said: |
@paulp said: |
@som-snytt said: |
@paulp said: |
@paulp said: |
The use case was a ??? method that would be easily @elidable, to prompt an error message from the compiler (in order to detect unimplementations). The following throws an error, apparently when generating the conversion to char. (Failing to compile is sufficient for the purpose of detecting ???. Unfortunately, it only works with primitive result types. Conversion to reference types results in ClassCastException. All this is abuse of the facility.)
package elysian
class ElysianFields {
import ElysianFields._
def run() {
//oops // OK
feature
println("Hello.")
}
//def feature: Unit = oops // OK
def feature: Char = oops // DNC
//java.lang.ClassCastException: scala.runtime.BoxedUnit cannot be cast to elysian.ElysianFields
val bugInWaiting: ElysianFields = oops // OK to elide?
}
object ElysianFields {
import annotation.elidable
import annotation.elidable._
@elidable(150)
def oops = throw new UnsupportedOperationException
def main(args: Array[String]) {
new ElysianFields().run()
}
}
$ scalac -d out -Xelide-below 1000 ./src/elysian/ElysianFields.scala
error: java.lang.ArrayIndexOutOfBoundsException: 8
at ch.epfl.lamp.fjbg.JExtendedCode.emitT2T(JExtendedCode.java:468)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genPrimitive$1(GenJVM.scala:1670)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$genBlock$1$2.apply(GenJVM.scala:1235)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$genBlock$1$2.apply(GenJVM.scala:1159)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:34)
at scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:38)
at scala.tools.nsc.backend.icode.BasicBlocks$BasicBlock.foreach(BasicBlocks.scala:126)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genBlock$1(GenJVM.scala:1159)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genBlocks$1(GenJVM.scala:1086)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genCode(GenJVM.scala:1702)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genMethod(GenJVM.scala:790)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$genClass$7.apply(GenJVM.scala:307)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator$$anonfun$genClass$7.apply(GenJVM.scala:307)
at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
at scala.collection.immutable.List.foreach(List.scala:45)
at scala.tools.nsc.backend.jvm.GenJVM$BytecodeGenerator.genClass(GenJVM.scala:307)
at scala.tools.nsc.backend.jvm.GenJVM$JvmPhase$$anonfun$run$4.apply(GenJVM.scala:86)
at scala.tools.nsc.backend.jvm.GenJVM$JvmPhase$$anonfun$run$4.apply(GenJVM.scala:86)
at scala.collection.mutable.HashMap$$anon$2$$anonfun$foreach$3.apply(HashMap.scala:102)
at scala.collection.mutable.HashMap$$anon$2$$anonfun$foreach$3.apply(HashMap.scala:102)
at scala.collection.Iterator$class.foreach(Iterator.scala:660)
at scala.collection.mutable.HashTable$$anon$1.foreach(HashTable.scala:157)
at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:190)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:43)
at scala.collection.mutable.HashMap$$anon$2.foreach(HashMap.scala:102)
at scala.tools.nsc.backend.jvm.GenJVM$JvmPhase.run(GenJVM.scala:86)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:953)
at scala.tools.nsc.Global$Run.compile(Global.scala:1038)
at scala.tools.nsc.Main$.process(Main.scala:106)
at scala.tools.nsc.Main$.main(Main.scala:123)
at scala.tools.nsc.Main.main(Main.scala)
The text was updated successfully, but these errors were encountered: