报错:
java.lang.IllegalStateException: Backend Internal error: Exception during code generation
Cause: Back-end (JVM) Internal error: wrong code generated
org.jetbrains.kotlin.codegen.CompilationException Back-end (JVM) Internal error: Couldn't transform method node:
···
此处省略N行
···
Cause: Label wasn't found during iterating through instructions
Element is unknownThe root cause was thrown at: LabelNormalizationMethodTransformer.kt:148
at org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:92)
at org.jetbrains.org.objectweb.asm.MethodVisitor.visitEnd(MethodVisitor.java:778)
at org.jetbrains.kotlin.codegen.FunctionCodegen.endVisit(FunctionCodegen.java:983)
... 86 more
Caused by: java.lang.IllegalStateException: Label wasn't found during iterating through instructions
at org.jetbrains.kotlin.codegen.optimization.LabelNormalizationMethodTransformer$TransformerForMethod.getNew(LabelNormalizationMethodTransformer.kt:148)
at org.jetbrains.kotlin.codegen.optimization.LabelNormalizationMethodTransformer$TransformerForMethod.rewriteLabels(LabelNormalizationMethodTransformer.kt:125)
at org.jetbrains.kotlin.codegen.optimization.LabelNormalizationMethodTransformer$TransformerForMethod.rewriteJumpInsn(LabelNormalizationMethodTransformer.kt:88)
at org.jetbrains.kotlin.codegen.optimization.LabelNormalizationMethodTransformer$TransformerForMethod.rewriteNonLabelInstructions(LabelNormalizationMethodTransformer.kt:69)
at org.jetbrains.kotlin.codegen.optimization.LabelNormalizationMethodTransformer$TransformerForMethod.transform(LabelNormalizationMethodTransformer.kt:36)
at org.jetbrains.kotlin.codegen.optimization.LabelNormalizationMethodTransformer.transform(LabelNormalizationMethodTransformer.kt:27)
at org.jetbrains.kotlin.codegen.optimization.transformer.CompositeMethodTransformer.transform(CompositeMethodTransformer.kt:25)
at org.jetbrains.kotlin.codegen.optimization.transformer.CompositeMethodTransformer.transform(CompositeMethodTransformer.kt:25)
at org.jetbrains.kotlin.codegen.optimization.OptimizationMethodVisitor.performTransformations(OptimizationMethodVisitor.kt:62)
at org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:70)
... 88 more
解决:
出现该问题是因为编译器不识别类型导致的,我遇到该情况是在对一个可能为空的 String? 追加值时出现
bean?.name += "test"
修改为:
if (bean != null)
bean!!.name += "test"
主要是要修改为一个确切的类型