-
Notifications
You must be signed in to change notification settings - Fork 1.1k
RuntimeError in backend / erasure #5006
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
Comments
I am using a slightly modified Dotty: diff --git a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/compiler/src/dotty/tools
index 606c820..fe441d2 100644
--- a/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
+++ b/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
@@ -505,7 +505,7 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
import scala.tools.asm.util.CheckClassAdapter
def wrap(body: => Unit): Boolean =
try { body; true }
- catch { case ex: Throwable => println(ex.getMessage); false }
+ catch { case ex: Throwable => println(ex.getMessage); throw ex; false }
val valid = wrap {
if (sym.is(Flags.Method)) {
diff --git a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala b/compiler/src/dotty/tools/backend/jvm/
index ffae0c2..d7a2cba 100644
--- a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala
+++ b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala
@@ -181,6 +181,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
case ex: Throwable =>
ex.printStackTrace()
ctx.error(s"Error while emitting ${int.sourceFileFor(item.cunit)}\n${ex.getMessage}")
+ throw ex
}
}
}
@@ -323,6 +324,7 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
case ex: Throwable =>
ex.printStackTrace()
ctx.error(s"Error while emitting ${item.plain.classNode.name}\n${ex.getMessage}")
+ throw ex
}
}
} but this should not affect the error, only the reporting. |
BTW I suspect we should accept/write such patches under a |
The same bug, but a slightly different callstack: object i0 {
val i1 = asInstanceOf[Int]
} Error while emitting RE-d341ba7adb385e80fb9955ca9161dd8f86ad3584.scala
Erasure should have added an unboxing operation to prevent this cast. Tree: TypeApply(Ident(asInstanceOf),List(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Int)]))
exception occurred while compiling RE-d341ba7adb385e80fb9955ca9161dd8f86ad3584.scala
Exception in thread "main" java.lang.RuntimeException: Erasure should have added an unboxing operation to prevent this cast. Tree: TypeApply(Ident(asInstanceOf),List(TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Int)]))
at dotty.tools.backend.jvm.DottyBackendInterface.abort(DottyBackendInterface.scala:394)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genTypeApply(BCodeBodyBuilder.scala:599)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:428)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStat(BCodeBodyBuilder.scala:77)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genNormalBlock$2$$anonfun$1(BCodeBodyBuilder.scala:860)
at scala.compat.java8.JProcedure1.apply(JProcedure1.java:18)
at scala.compat.java8.JProcedure1.apply(JProcedure1.java:10)
at scala.collection.immutable.List.foreach(List.scala:389)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genNormalBlock$1(BCodeBodyBuilder.scala:860)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genBlock(BCodeBodyBuilder.scala:892)
at scala.tools.nsc.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:408)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.emitNormalMethodBody$1(BCodeSkelBuilder.scala:602)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genDefDef(BCodeSkelBuilder.scala:635)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:506)
at scala.tools.nsc.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen$$anonfun$1(BCodeSkelBuilder.scala:508) RE-d341ba7adb385e80fb9955ca9161dd8f86ad3584 |
Ah, looks like That's why |
@Blaisorblade Do you remember why you didn't end up making a PR for dotty-staging@6cc105c which should fix this ? |
@smarter I'm not sure; I think I ran out of steam on revising those fixes for inclusion :-|. But feel free to cherry-pick that commit... |
OK, I'll have a look. |
Fix #5006: Enforce `asInstanceOf` to be a `Select` node
…-fails Revert "Fix #5006: Normalize prefixes of TypeApply in Erasure"
Fix #5006: Normalize prefixes of TypeApply in Erasure
Uh oh!
There was an error while loading. Please reload this page.
RE-96bd93de803119f21ab5d429b0ce0793869d86c5
The text was updated successfully, but these errors were encountered: