Commit 8e7ef94
committed
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.1 parent 1e9c012 commit 8e7ef94
1 file changed
+0
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
213 | | - | |
214 | 213 | | |
215 | 214 | | |
216 | 215 | | |
| |||
0 commit comments