JVM_IR: reorder lowerings
Some lowerings have to come before DefaultParameterInjector.
This commit is contained in:
@@ -72,7 +72,7 @@ private val propertiesPhase = makeIrFilePhase<CommonBackendContext>(
|
|||||||
stickyPostconditions = setOf((PropertiesLowering)::checkNoProperties)
|
stickyPostconditions = setOf((PropertiesLowering)::checkNoProperties)
|
||||||
)
|
)
|
||||||
|
|
||||||
private val localDeclarationsPhase = makeIrFilePhase<CommonBackendContext>(
|
internal val localDeclarationsPhase = makeIrFilePhase<CommonBackendContext>(
|
||||||
{ context ->
|
{ context ->
|
||||||
LocalDeclarationsLowering(context, object : LocalNameProvider {
|
LocalDeclarationsLowering(context, object : LocalNameProvider {
|
||||||
override fun localName(declaration: IrDeclarationWithName): String =
|
override fun localName(declaration: IrDeclarationWithName): String =
|
||||||
@@ -95,7 +95,7 @@ private val defaultArgumentInjectorPhase = makeIrFilePhase(
|
|||||||
::JvmDefaultParameterInjector,
|
::JvmDefaultParameterInjector,
|
||||||
name = "DefaultParameterInjector",
|
name = "DefaultParameterInjector",
|
||||||
description = "Transform calls with default arguments into calls to stubs",
|
description = "Transform calls with default arguments into calls to stubs",
|
||||||
prerequisite = setOf(defaultArgumentStubPhase)
|
prerequisite = setOf(defaultArgumentStubPhase, callableReferencePhase)
|
||||||
)
|
)
|
||||||
|
|
||||||
private val innerClassesPhase = makeIrFilePhase(
|
private val innerClassesPhase = makeIrFilePhase(
|
||||||
@@ -131,8 +131,21 @@ private val jvmFilePhases =
|
|||||||
|
|
||||||
enumWhenPhase then
|
enumWhenPhase then
|
||||||
singletonReferencesPhase then
|
singletonReferencesPhase then
|
||||||
|
|
||||||
callableReferencePhase then
|
callableReferencePhase then
|
||||||
|
functionNVarargInvokePhase then
|
||||||
localDeclarationsPhase then
|
localDeclarationsPhase then
|
||||||
|
|
||||||
|
singleAbstractMethodPhase then
|
||||||
|
addContinuationPhase then
|
||||||
|
|
||||||
|
jvmOverloadsAnnotationPhase then
|
||||||
|
jvmDefaultConstructorPhase then
|
||||||
|
|
||||||
|
flattenStringConcatenationPhase then
|
||||||
|
foldConstantLoweringPhase then
|
||||||
|
computeStringTrimPhase then
|
||||||
|
|
||||||
defaultArgumentStubPhase then
|
defaultArgumentStubPhase then
|
||||||
defaultArgumentInjectorPhase then
|
defaultArgumentInjectorPhase then
|
||||||
|
|
||||||
@@ -141,10 +154,6 @@ private val jvmFilePhases =
|
|||||||
interfaceSuperCallsPhase then
|
interfaceSuperCallsPhase then
|
||||||
interfaceDefaultCallsPhase then
|
interfaceDefaultCallsPhase then
|
||||||
|
|
||||||
singleAbstractMethodPhase then
|
|
||||||
addContinuationPhase then
|
|
||||||
functionNVarargInvokePhase then
|
|
||||||
|
|
||||||
innerClassesPhase then
|
innerClassesPhase then
|
||||||
innerClassConstructorCallsPhase then
|
innerClassConstructorCallsPhase then
|
||||||
forLoopsPhase then
|
forLoopsPhase then
|
||||||
@@ -156,16 +165,11 @@ private val jvmFilePhases =
|
|||||||
makeInitializersPhase(JvmLoweredDeclarationOrigin.CLASS_STATIC_INITIALIZER, true) then
|
makeInitializersPhase(JvmLoweredDeclarationOrigin.CLASS_STATIC_INITIALIZER, true) then
|
||||||
collectionStubMethodLowering then
|
collectionStubMethodLowering then
|
||||||
bridgePhase then
|
bridgePhase then
|
||||||
jvmOverloadsAnnotationPhase then
|
|
||||||
jvmDefaultConstructorPhase then
|
|
||||||
jvmStaticAnnotationPhase then
|
jvmStaticAnnotationPhase then
|
||||||
staticDefaultFunctionPhase then
|
staticDefaultFunctionPhase then
|
||||||
syntheticAccessorPhase then
|
syntheticAccessorPhase then
|
||||||
|
|
||||||
toArrayPhase then
|
toArrayPhase then
|
||||||
flattenStringConcatenationPhase then
|
|
||||||
foldConstantLoweringPhase then
|
|
||||||
computeStringTrimPhase then
|
|
||||||
jvmBuiltinOptimizationLoweringPhase then
|
jvmBuiltinOptimizationLoweringPhase then
|
||||||
additionalClassAnnotationPhase then
|
additionalClassAnnotationPhase then
|
||||||
|
|
||||||
|
|||||||
+2
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
|||||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
||||||
import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor
|
import org.jetbrains.kotlin.backend.common.ir.createImplicitParameterDeclarationWithWrappedDescriptor
|
||||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||||
|
import org.jetbrains.kotlin.backend.common.lower.insertCallsToDefaultArgumentStubs
|
||||||
import org.jetbrains.kotlin.backend.common.lower.irBlock
|
import org.jetbrains.kotlin.backend.common.lower.irBlock
|
||||||
import org.jetbrains.kotlin.backend.common.lower.irIfThen
|
import org.jetbrains.kotlin.backend.common.lower.irIfThen
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||||
@@ -18,6 +19,7 @@ import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
|||||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineFunctionCall
|
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineFunctionCall
|
||||||
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineIrExpression
|
import org.jetbrains.kotlin.backend.jvm.codegen.isInlineIrExpression
|
||||||
import org.jetbrains.kotlin.backend.jvm.ir.isInlineParameter
|
import org.jetbrains.kotlin.backend.jvm.ir.isInlineParameter
|
||||||
|
import org.jetbrains.kotlin.backend.jvm.localDeclarationsPhase
|
||||||
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
|
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor
|
||||||
import org.jetbrains.kotlin.codegen.PropertyReferenceCodegen
|
import org.jetbrains.kotlin.codegen.PropertyReferenceCodegen
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
|
|||||||
+1
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.backend.jvm.lower
|
|||||||
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
||||||
import org.jetbrains.kotlin.backend.common.ir.passTypeArgumentsFrom
|
import org.jetbrains.kotlin.backend.common.ir.passTypeArgumentsFrom
|
||||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||||
|
import org.jetbrains.kotlin.backend.common.lower.insertCallsToDefaultArgumentStubs
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||||
import org.jetbrains.kotlin.ir.builders.declarations.addConstructor
|
import org.jetbrains.kotlin.ir.builders.declarations.addConstructor
|
||||||
|
|||||||
+9
-8
@@ -7,21 +7,18 @@ package org.jetbrains.kotlin.backend.jvm.lower
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||||
import org.jetbrains.kotlin.backend.common.deepCopyWithWrappedDescriptors
|
|
||||||
import org.jetbrains.kotlin.backend.common.descriptors.WrappedClassConstructorDescriptor
|
import org.jetbrains.kotlin.backend.common.descriptors.WrappedClassConstructorDescriptor
|
||||||
import org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor
|
import org.jetbrains.kotlin.backend.common.descriptors.WrappedSimpleFunctionDescriptor
|
||||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
||||||
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
|
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
|
||||||
|
import org.jetbrains.kotlin.backend.common.lower.insertCallsToDefaultArgumentStubs
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrConstructorImpl
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
|
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrConstructorSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||||
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
import org.jetbrains.kotlin.ir.util.deepCopyWithSymbols
|
||||||
@@ -104,9 +101,13 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wrapperIrFunction.body = IrExpressionBodyImpl(
|
wrapperIrFunction.body = if (target is IrConstructor) {
|
||||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, call
|
IrBlockBodyImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, listOf(call))
|
||||||
)
|
} else {
|
||||||
|
IrExpressionBodyImpl(
|
||||||
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, call
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return wrapperIrFunction
|
return wrapperIrFunction
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
|||||||
import org.jetbrains.kotlin.backend.common.lower.irBlock
|
import org.jetbrains.kotlin.backend.common.lower.irBlock
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase
|
||||||
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin
|
||||||
|
import org.jetbrains.kotlin.backend.jvm.localDeclarationsPhase
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||||
@@ -36,7 +37,8 @@ import org.jetbrains.kotlin.util.OperatorNameConventions
|
|||||||
internal val singleAbstractMethodPhase = makeIrFilePhase(
|
internal val singleAbstractMethodPhase = makeIrFilePhase(
|
||||||
::SingleAbstractMethodLowering,
|
::SingleAbstractMethodLowering,
|
||||||
name = "SingleAbstractMethod",
|
name = "SingleAbstractMethod",
|
||||||
description = "Replace SAM conversions with instances of interface-implementing classes"
|
description = "Replace SAM conversions with instances of interface-implementing classes",
|
||||||
|
prerequisite = setOf(localDeclarationsPhase)
|
||||||
)
|
)
|
||||||
|
|
||||||
class SingleAbstractMethodLowering(val context: CommonBackendContext) : ClassLoweringPass {
|
class SingleAbstractMethodLowering(val context: CommonBackendContext) : ClassLoweringPass {
|
||||||
|
|||||||
Reference in New Issue
Block a user