JVM: generate $assertionsDisabled before inlining the node
This fixes the problem where compiling a class initializer that contains a call to an `assert`ing function in a separate module causes the assertion to always be enabled (i.e. the attached test used to fail in CompileKotlinAgainstInlineKotlin mode).
This commit is contained in:
@@ -231,12 +231,6 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
//through generation captured parameters will be added to invocationParamBuilder
|
||||
putClosureParametersOnStack()
|
||||
|
||||
val shouldSpillStack = !canSkipStackSpillingOnInline(node)
|
||||
|
||||
if (shouldSpillStack) {
|
||||
addInlineMarker(codegen.v, true)
|
||||
}
|
||||
|
||||
val parameters = invocationParamBuilder.buildParameters()
|
||||
|
||||
val info = RootInliningContext(
|
||||
@@ -271,16 +265,21 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
removeFinallyMarkers(adapter)
|
||||
}
|
||||
|
||||
adapter.accept(MethodBodyVisitor(codegen.v))
|
||||
// In case `codegen.v` is `<clinit>`, initializer for the `$assertionsDisabled` field
|
||||
// needs to be inserted before the code that actually uses it.
|
||||
generateAssertFieldIfNeeded(info)
|
||||
|
||||
val shouldSpillStack = !canSkipStackSpillingOnInline(node)
|
||||
if (shouldSpillStack) {
|
||||
addInlineMarker(codegen.v, true)
|
||||
}
|
||||
adapter.accept(MethodBodyVisitor(codegen.v))
|
||||
if (shouldSpillStack) {
|
||||
addInlineMarker(codegen.v, false)
|
||||
}
|
||||
|
||||
defaultSourceMapper.callSiteMarker = null
|
||||
|
||||
generateAssertFieldIfNeeded(info)
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user