Rollback script related LDL changes...
to reimplement them properly in the script lowering
This commit is contained in:
committed by
TeamCityServer
parent
586fa8af64
commit
87952d63a3
+7
-23
@@ -5,13 +5,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.backend.common.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.BodyLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.BodyAndScriptBodyLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.descriptors.synthesizedString
|
||||
import org.jetbrains.kotlin.backend.common.ir.*
|
||||
import org.jetbrains.kotlin.backend.common.lower.inline.isInlineParameter
|
||||
import org.jetbrains.kotlin.backend.common.runOnFilePostfix
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
|
||||
@@ -83,7 +82,7 @@ class LocalDeclarationsLowering(
|
||||
val suggestUniqueNames: Boolean = true, // When `true` appends a `-#index` suffix to lifted declaration names
|
||||
val forceFieldsForInlineCaptures: Boolean = false // See `LocalClassContext`
|
||||
) :
|
||||
BodyAndScriptBodyLoweringPass {
|
||||
BodyLoweringPass {
|
||||
|
||||
override fun lower(irFile: IrFile) {
|
||||
runOnFilePostfix(irFile, allowDeclarationModification = true)
|
||||
@@ -96,16 +95,11 @@ class LocalDeclarationsLowering(
|
||||
IrDeclarationOriginImpl("FIELD_FOR_CROSSINLINE_CAPTURED_VALUE", isSynthetic = true)
|
||||
|
||||
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
||||
LocalDeclarationsTransformer(irBody, container, null, false).lowerLocalDeclarations()
|
||||
LocalDeclarationsTransformer(irBody, container, null).lowerLocalDeclarations()
|
||||
}
|
||||
|
||||
override fun lowerScriptBody(irDeclarationContainer: IrDeclarationContainer, container: IrDeclaration) {
|
||||
LocalDeclarationsTransformer(irDeclarationContainer, container, null, true).lowerLocalDeclarations()
|
||||
}
|
||||
|
||||
|
||||
fun lower(irElement: IrElement, container: IrDeclaration, classesToLower: Set<IrClass>) {
|
||||
LocalDeclarationsTransformer(irElement, container, classesToLower, false).lowerLocalDeclarations()
|
||||
LocalDeclarationsTransformer(irElement, container, classesToLower).lowerLocalDeclarations()
|
||||
}
|
||||
|
||||
internal class ScopeWithCounter(val irElement: IrElement) {
|
||||
@@ -235,7 +229,7 @@ class LocalDeclarationsLowering(
|
||||
}
|
||||
|
||||
private inner class LocalDeclarationsTransformer(
|
||||
val irElement: IrElement, val container: IrDeclaration, val classesToLower: Set<IrClass>?, val isScriptMode: Boolean
|
||||
val irElement: IrElement, val container: IrDeclaration, val classesToLower: Set<IrClass>?
|
||||
) {
|
||||
val localFunctions: MutableMap<IrFunction, LocalFunctionContext> = LinkedHashMap()
|
||||
val localClasses: MutableMap<IrClass, LocalClassContext> = LinkedHashMap()
|
||||
@@ -496,8 +490,6 @@ class LocalDeclarationsLowering(
|
||||
|
||||
irClass.transformChildrenVoid(FunctionBodiesRewriter(localClassContext))
|
||||
|
||||
if (isScriptMode && constructors.isEmpty()) return
|
||||
|
||||
// NOTE: if running before InitializersLowering, we can instead look for constructors that have
|
||||
// IrInstanceInitializerCall. However, Native runs these two lowerings in opposite order.
|
||||
val constructorsCallingSuper = constructors
|
||||
@@ -952,11 +944,7 @@ class LocalDeclarationsLowering(
|
||||
override fun visitConstructor(declaration: IrConstructor, data: Data) {
|
||||
super.visitConstructor(declaration, data)
|
||||
|
||||
if (!isScriptMode && !declaration.constructedClass.isLocalNotInner()) return
|
||||
// Inner classes in scripts are handled properly in the InnerClassesLowering
|
||||
if (isScriptMode && declaration.constructedClass.isInner) return
|
||||
// LDL doesn't work on the enums because local enums are not allowed, so skipping them in scripts too
|
||||
if (isScriptMode && declaration.constructedClass.kind == ClassKind.ENUM_CLASS) return
|
||||
if (!declaration.constructedClass.isLocalNotInner()) return
|
||||
|
||||
localClassConstructors[declaration] = LocalClassConstructorContext(declaration, data.inInlineFunctionScope)
|
||||
}
|
||||
@@ -965,11 +953,7 @@ class LocalDeclarationsLowering(
|
||||
if (classesToLower?.contains(declaration) == false) return
|
||||
super.visitClass(declaration, data.withCurrentClass(declaration))
|
||||
|
||||
if (!isScriptMode && !declaration.isLocalNotInner()) return
|
||||
// Inner classes in scripts are handled properly in the InnerClassesLowering
|
||||
if (isScriptMode && declaration.isInner) return
|
||||
// LDL doesn't work on the enums because local enums are not allowed, so skipping them in scripts too
|
||||
if (isScriptMode && declaration.kind == ClassKind.ENUM_CLASS) return
|
||||
if (!declaration.isLocalNotInner()) return
|
||||
|
||||
// If there are many non-delegating constructors, each copy of the initializer requires different remapping:
|
||||
// class C {
|
||||
|
||||
Reference in New Issue
Block a user