Use SYNTHETIC_OFFSET for declarations created in IR
Native compiler doesn't support new declarations created with UNDEFINED_OFFSET, they should use SYNTHETIC_OFFSET instead (based on the data class gen). This change adds these offsets to declarations created by Compose plugin.
Change-Id: I910294269466da61740ceea0372abee12de07c4a
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/AbstractComposeLowering.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/AbstractComposeLowering.kt
index 49c690a..09d2ab6 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/AbstractComposeLowering.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/AbstractComposeLowering.kt
@@ -127,6 +127,7 @@
import org.jetbrains.kotlin.ir.types.typeWith
import org.jetbrains.kotlin.ir.util.ConstantValueGenerator
import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper
+import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
import org.jetbrains.kotlin.ir.util.TypeTranslator
import org.jetbrains.kotlin.ir.util.functions
import org.jetbrains.kotlin.ir.util.getArguments
@@ -920,17 +921,19 @@
isVar: Boolean = false,
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
): IrVariableImpl {
+ val descriptor = WrappedVariableDescriptor()
return IrVariableImpl(
value.startOffset,
value.endOffset,
origin,
- IrVariableSymbolImpl(WrappedVariableDescriptor()),
+ IrVariableSymbolImpl(descriptor),
Name.identifier(name),
irType,
isVar,
false,
false
).apply {
+ descriptor.bind(this)
initializer = value
}
}
@@ -1044,6 +1047,8 @@
fun makeStabilityField(): IrField {
return context.irFactory.buildField {
+ startOffset = SYNTHETIC_OFFSET
+ endOffset = SYNTHETIC_OFFSET
name = KtxNameConventions.STABILITY_FLAG
isStatic = true
isFinal = true
diff --git a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerLambdaMemoization.kt b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerLambdaMemoization.kt
index fd62c1c..a598c6b 100644
--- a/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerLambdaMemoization.kt
+++ b/compose/compiler/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposerLambdaMemoization.kt
@@ -77,6 +77,7 @@
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrType
import org.jetbrains.kotlin.ir.util.DeepCopySymbolRemapper
+import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.isLocal
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
@@ -266,6 +267,8 @@
val filePath = declaration.fileEntry.name
val fileName = filePath.split('/').last()
val current = context.irFactory.buildClass {
+ startOffset = SYNTHETIC_OFFSET
+ endOffset = SYNTHETIC_OFFSET
kind = ClassKind.OBJECT
visibility = DescriptorVisibilities.INTERNAL
val shortName = PackagePartClassUtils.getFilePartShortName(fileName)
@@ -549,6 +552,8 @@
visibility = DescriptorVisibilities.INTERNAL
}.also { p ->
p.backingField = context.irFactory.buildField {
+ startOffset = SYNTHETIC_OFFSET
+ endOffset = SYNTHETIC_OFFSET
name = Name.identifier(lambdaName)
type = lambdaType
visibility = DescriptorVisibilities.INTERNAL