Keep original casts during reification to avoid VerifyError

#KT-26435 Fixed
This commit is contained in:
Mikhael Bogdanov
2019-12-17 09:29:11 +01:00
parent 6f16d02920
commit 03c2350e79
11 changed files with 190 additions and 1 deletions
@@ -222,7 +222,11 @@ class ReifiedTypeInliner<KT : KotlinTypeMarker>(
generateAsCast(InstructionAdapter(newMethodNode), kotlinType, asmType, safe, languageVersionSettings)
instructions.insert(insn, newMethodNode.instructions)
instructions.remove(stubCheckcast)
// Keep stubCheckcast to avoid VerifyErrors on 1.8+ bytecode,
// it's safe to remove cast to Object as FrameMap will use it as default value for merged branches
if (stubCheckcast.desc == AsmTypes.OBJECT_TYPE.internalName) {
instructions.remove(stubCheckcast)
}
// TODO: refine max stack calculation (it's not always as big as +4)
maxStackSize = max(maxStackSize, 4)