Avoid irGet with Unit value if it is last it IrReturnableBlock
This is needed to pass `MethodVerifier` check on JVM backend
This commit is contained in:
+6
-1
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrDoWhileLoopImpl
|
|||||||
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||||
import org.jetbrains.kotlin.ir.transformStatement
|
import org.jetbrains.kotlin.ir.transformStatement
|
||||||
|
import org.jetbrains.kotlin.ir.types.isUnit
|
||||||
|
|
||||||
// TODO migrate other usages and move this file to backend.jvm
|
// TODO migrate other usages and move this file to backend.jvm
|
||||||
/**
|
/**
|
||||||
@@ -158,7 +159,11 @@ class ReturnableBlockTransformer(val context: CommonBackendContext, val containe
|
|||||||
return builder.irBlock(expression, expression.origin) {
|
return builder.irBlock(expression, expression.origin) {
|
||||||
+variable
|
+variable
|
||||||
+loop
|
+loop
|
||||||
+irGet(variable)
|
if (!expression.type.isUnit()) {
|
||||||
|
// In case of Unit return type we don't need to return an explicit value. This will not be optimized by JVM backend and
|
||||||
|
// may result in exceptions in `MethodVerifier` before optimizations.
|
||||||
|
+irGet(variable)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user