You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TypeAssigner: fix return type of clone() for arrays
Given the following code:
val x: Array[String] = new Array[String](1)
x(0) = "foo"
println(x.clone().apply(0))
Before this commit, the last line was rewritten in Erasure to:
println(x.clone().[]apply(0))
This is incorrect: clone() returns an Object, so a cast is necessary,
this resulted in the following failure at runtime:
java.lang.VerifyError: Bad type on operand stack in aaload
After this commit, the last line is rewritten in Erasure to:
println(x.clone().asInstanceOf[String[]].[]apply(0))
This corresponds to adding a "checkcast" instruction in the generated
bytecode, and is enough to fix the runtime error.
0 commit comments