FIR2IR: add local delegated property generation

This commit is contained in:
pyos
2020-09-07 14:11:17 +02:00
committed by Mikhail Glukhikh
parent 4792be2522
commit f198a19ab0
43 changed files with 211 additions and 217 deletions
@@ -149,11 +149,9 @@ private fun FirCallableSymbol<*>.toSymbol(declarationStorage: Fir2IrDeclarationS
} else {
syntheticProperty.setter!!.delegate.symbol.toSymbol(declarationStorage, preferGetter)
}
} ?: if (fir.isLocal) declarationStorage.getIrValueSymbol(this) else declarationStorage.getIrPropertyOrFieldSymbol(this)
}
is FirPropertySymbol -> {
if (fir.isLocal) declarationStorage.getIrValueSymbol(this) else declarationStorage.getIrPropertyOrFieldSymbol(this)
} ?: fir.toSymbol(declarationStorage)
}
is FirPropertySymbol -> fir.toSymbol(declarationStorage)
is FirFieldSymbol -> declarationStorage.getIrPropertyOrFieldSymbol(this)
is FirBackingFieldSymbol -> declarationStorage.getIrBackingFieldSymbol(this)
is FirDelegateFieldSymbol<*> -> declarationStorage.getIrBackingFieldSymbol(this)
@@ -161,6 +159,12 @@ private fun FirCallableSymbol<*>.toSymbol(declarationStorage: Fir2IrDeclarationS
else -> null
}
private fun FirProperty.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol? = when {
!isLocal -> declarationStorage.getIrPropertyOrFieldSymbol(symbol)
delegate != null -> declarationStorage.getIrLocalDelegatedPropertySymbol(symbol)
else -> declarationStorage.getIrValueSymbol(symbol)
}
fun FirConstExpression<*>.getIrConstKind(): IrConstKind<*> = when (kind) {
FirConstKind.IntegerLiteral -> {
val type = typeRef.coneTypeUnsafe<ConeIntegerLiteralType>()
@@ -525,7 +525,7 @@ class Fir2IrDeclarationStorage(
internal fun createIrPropertyAccessor(
propertyAccessor: FirPropertyAccessor?,
property: FirProperty,
correspondingProperty: IrProperty,
correspondingProperty: IrDeclarationWithName,
propertyType: IrType,
irParent: IrDeclarationParent?,
thisReceiverOwner: IrClass? = irParent as? IrClass,
@@ -537,7 +537,7 @@ class Fir2IrDeclarationStorage(
): IrSimpleFunction {
val prefix = if (isSetter) "set" else "get"
val signature = if (isLocal) null else signatureComposer.composeAccessorSignature(property, isSetter)
val containerSource = correspondingProperty.containerSource
val containerSource = (correspondingProperty as? IrProperty)?.containerSource
return declareIrAccessor(
signature,
containerSource,
@@ -550,8 +550,8 @@ class Fir2IrDeclarationStorage(
irFactory.createFunction(
startOffset, endOffset, origin, symbol,
Name.special("<$prefix-${correspondingProperty.name}>"),
visibility ?: correspondingProperty.visibility,
correspondingProperty.modality, accessorReturnType,
visibility ?: (correspondingProperty as IrDeclarationWithVisibility).visibility,
(correspondingProperty as? IrOverridableMember)?.modality ?: Modality.FINAL, accessorReturnType,
isInline = propertyAccessor?.isInline == true,
isExternal = propertyAccessor?.isExternal == true,
isTailrec = false, isSuspend = false, isOperator = false,
@@ -559,7 +559,7 @@ class Fir2IrDeclarationStorage(
isExpect = false, isFakeOverride = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
containerSource = containerSource,
).apply {
correspondingPropertySymbol = correspondingProperty.symbol
correspondingPropertySymbol = (correspondingProperty as? IrProperty)?.symbol
if (propertyAccessor != null) {
metadata = FirMetadataSource.Function(propertyAccessor)
// Note that deserialized annotations are stored in the accessor, not the property.
@@ -883,6 +883,41 @@ class Fir2IrDeclarationStorage(
return irVariable
}
fun createIrLocalDelegatedProperty(property: FirProperty, irParent: IrDeclarationParent): IrLocalDelegatedProperty {
val type = property.returnTypeRef.toIrType()
val origin = IrDeclarationOrigin.DEFINED
val irProperty = property.convertWithOffsets { startOffset, endOffset ->
val descriptor = WrappedVariableDescriptorWithAccessor()
symbolTable.declareLocalDelegatedProperty(startOffset, endOffset, origin, descriptor, type) {
irFactory.createLocalDelegatedProperty(startOffset, endOffset, origin, it, property.name, type, property.isVar).apply {
descriptor.bind(this)
}
}
}.apply {
parent = irParent
enterScope(this)
delegate = declareIrVariable(
startOffset, endOffset, IrDeclarationOrigin.PROPERTY_DELEGATE,
Name.identifier("${property.name}\$delegate"), property.delegate!!.typeRef.toIrType(),
isVar = false, isConst = false, isLateinit = false
)
delegate.parent = irParent
getter = createIrPropertyAccessor(
property.getter, property, this, type, irParent, null, false,
IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR, startOffset, endOffset, isLocal
)
if (property.isVar) {
setter = createIrPropertyAccessor(
property.setter, property, this, type, irParent, null, true,
IrDeclarationOrigin.DELEGATED_PROPERTY_ACCESSOR, startOffset, endOffset, isLocal
)
}
leaveScope(this)
}
localStorage.putDelegatedProperty(property, irProperty)
return irProperty
}
fun declareTemporaryVariable(base: IrExpression, nameHint: String? = null): IrVariable {
return declareIrVariable(
base.startOffset, base.endOffset, IrDeclarationOrigin.IR_TEMPORARY_VARIABLE,
@@ -1029,6 +1064,9 @@ class Fir2IrDeclarationStorage(
fun getIrBackingFieldSymbol(firVariableSymbol: FirVariableSymbol<*>): IrSymbol {
return when (val fir = firVariableSymbol.fir) {
is FirProperty -> {
if (fir.isLocal) {
return localStorage.getDelegatedProperty(fir)?.delegate?.symbol ?: getIrVariableSymbol(fir)
}
propertyCache[fir]?.let { return it.backingField!!.symbol }
val irParent = findIrParent(fir)
val parentOrigin = (irParent as? IrDeclaration)?.origin ?: IrDeclarationOrigin.DEFINED
@@ -1047,6 +1085,11 @@ class Fir2IrDeclarationStorage(
?: throw IllegalArgumentException("Cannot find variable ${firVariable.render()} in local storage")
}
fun getIrLocalDelegatedPropertySymbol(firPropertySymbol: FirPropertySymbol): IrSymbol {
return localStorage.getDelegatedProperty(firPropertySymbol.fir)?.symbol
?: throw IllegalArgumentException("Cannot find delegated property ${firPropertySymbol.fir.render()} in local storage")
}
fun getIrValueSymbol(firVariableSymbol: FirVariableSymbol<*>): IrSymbol {
return when (val firDeclaration = firVariableSymbol.fir) {
is FirEnumEntry -> {
@@ -6,10 +6,7 @@
package org.jetbrains.kotlin.fir.backend
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.declarations.IrVariable
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.name.ClassId
class Fir2IrLocalStorage {
@@ -35,13 +32,8 @@ class Fir2IrLocalStorage {
return null
}
fun getVariable(variable: FirVariable<*>): IrVariable? {
for (cache in cacheStack.asReversed()) {
val local = cache.getVariable(variable)
if (local != null) return local
}
return null
}
fun getVariable(variable: FirVariable<*>): IrVariable? =
last { getVariable(variable) }
fun getLocalClass(localClass: FirClass<*>): IrClass? {
return localClassCache[localClass]
@@ -51,10 +43,15 @@ class Fir2IrLocalStorage {
return localClassCache.entries.find { (firClass, _) -> firClass.classId == classId }?.value
}
fun getLocalFunction(localFunction: FirFunction<*>): IrSimpleFunction? {
fun getLocalFunction(localFunction: FirFunction<*>): IrSimpleFunction? =
last { getLocalFunction(localFunction) }
fun getDelegatedProperty(property: FirProperty): IrLocalDelegatedProperty? =
last { getDelegatedProperty(property) }
private inline fun <T> last(getter: Fir2IrScopeCache.() -> T?): T? {
for (cache in cacheStack.asReversed()) {
val local = cache.getLocalFunction(localFunction)
if (local != null) return local
cache.getter()?.let { return it }
}
return null
}
@@ -74,4 +71,8 @@ class Fir2IrLocalStorage {
fun putLocalFunction(firFunction: FirFunction<*>, irFunction: IrSimpleFunction) {
cacheStack.last().putLocalFunction(firFunction, irFunction)
}
fun putDelegatedProperty(firProperty: FirProperty, irProperty: IrLocalDelegatedProperty) {
cacheStack.last().putDelegatedProperty(firProperty, irProperty)
}
}
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.backend
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.ir.declarations.IrLocalDelegatedProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
import org.jetbrains.kotlin.ir.declarations.IrVariable
@@ -18,6 +19,8 @@ class Fir2IrScopeCache {
private val localFunctionCache = mutableMapOf<FirFunction<*>, IrSimpleFunction>()
private val delegatedPropertyCache = mutableMapOf<FirProperty, IrLocalDelegatedProperty>()
fun getParameter(parameter: FirValueParameter): IrValueParameter? = parameterCache[parameter]
fun putParameter(firParameter: FirValueParameter, irParameter: IrValueParameter) {
@@ -37,9 +40,16 @@ class Fir2IrScopeCache {
localFunctionCache[localFunction] = irFunction
}
fun getDelegatedProperty(property: FirProperty): IrLocalDelegatedProperty? = delegatedPropertyCache[property]
fun putDelegatedProperty(firProperty: FirProperty, irProperty: IrLocalDelegatedProperty) {
delegatedPropertyCache[firProperty] = irProperty
}
fun clear() {
parameterCache.clear()
variableCache.clear()
localFunctionCache.clear()
delegatedPropertyCache.clear()
}
}
@@ -254,6 +254,20 @@ class Fir2IrVisitor(
private fun visitLocalVariable(variable: FirProperty): IrElement {
assert(variable.isLocal)
val delegate = variable.delegate
if (delegate != null) {
val irProperty = declarationStorage.createIrLocalDelegatedProperty(variable, conversionScope.parentFromStack())
irProperty.delegate.initializer = convertToIrExpression(delegate)
conversionScope.withFunction(irProperty.getter) {
memberGenerator.convertFunctionContent(irProperty.getter, variable.getter, null)
}
irProperty.setter?.let {
conversionScope.withFunction(it) {
memberGenerator.convertFunctionContent(it, variable.setter, null)
}
}
return irProperty
}
val initializer = variable.initializer
val isNextVariable = initializer is FirFunctionCall &&
initializer.resolvedNamedFunctionSymbol()?.callableId?.isIteratorNext() == true &&
@@ -79,6 +79,15 @@ class CallAndReferenceGenerator(
origin
)
}
is IrLocalDelegatedPropertySymbol -> {
IrLocalDelegatedPropertyReferenceImpl(
startOffset, endOffset, type, symbol,
symbol.owner.delegate.symbol,
symbol.owner.getter.symbol as IrSimpleFunctionSymbol,
symbol.owner.setter?.symbol as IrSimpleFunctionSymbol?,
IrStatementOrigin.PROPERTY_REFERENCE_FOR_DELEGATE
)
}
is IrConstructorSymbol -> {
val constructor = symbol.owner
val klass = constructor.parent as? IrClass
@@ -489,6 +498,15 @@ class CallAndReferenceGenerator(
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol)
)
}
is IrLocalDelegatedPropertySymbol -> {
IrCallImpl(
startOffset, endOffset, type, symbol.owner.getter.symbol as IrSimpleFunctionSymbol,
typeArgumentsCount = symbol.owner.getter.typeParameters.size,
valueArgumentsCount = 0,
origin = IrStatementOrigin.GET_LOCAL_PROPERTY,
superQualifierSymbol = dispatchReceiver.superQualifierSymbol(symbol)
)
}
is IrPropertySymbol -> {
val getter = symbol.owner.getter
val backingField = symbol.owner.backingField
@@ -541,6 +559,21 @@ class CallAndReferenceGenerator(
is IrFieldSymbol -> IrSetFieldImpl(startOffset, endOffset, symbol, type, origin).apply {
value = assignedValue
}
is IrLocalDelegatedPropertySymbol -> {
val setter = symbol.owner.setter
when {
setter != null -> IrCallImpl(
startOffset, endOffset, type, setter.symbol as IrSimpleFunctionSymbol,
typeArgumentsCount = setter.typeParameters.size,
valueArgumentsCount = 1,
origin = origin,
superQualifierSymbol = variableAssignment.dispatchReceiver.superQualifierSymbol(symbol)
).apply {
putValueArgument(0, assignedValue)
}
else -> generateErrorCallExpression(startOffset, endOffset, calleeReference)
}
}
is IrPropertySymbol -> {
val irProperty = symbol.owner
val setter = irProperty.setter
@@ -966,17 +966,19 @@ class SymbolTable(
endOffset: Int,
origin: IrDeclarationOrigin,
descriptor: VariableDescriptorWithAccessors,
type: IrType
type: IrType,
factory: (IrLocalDelegatedPropertySymbol) -> IrLocalDelegatedProperty = {
irFactory.createLocalDelegatedProperty(
startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor), type, descriptor.isVar
)
}
): IrLocalDelegatedProperty =
localDelegatedPropertySymbolTable.declareLocal(
descriptor,
{ IrLocalDelegatedPropertySymbolImpl(descriptor) },
) {
irFactory.createLocalDelegatedProperty(
startOffset, endOffset, origin, it, nameProvider.nameForDeclaration(descriptor), type, descriptor.isVar
).apply {
metadata = MetadataSource.LocalDelegatedProperty(descriptor)
}
factory
).apply {
metadata = MetadataSource.LocalDelegatedProperty(descriptor)
}
fun referenceLocalDelegatedProperty(descriptor: VariableDescriptorWithAccessors) =
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Del<T>(var x: T) {
operator fun getValue(thisRef: Any?, kProp: Any) = x
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// WITH_COROUTINES
// COMMON_COROUTINES_TEST
@@ -1,6 +1,5 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
// IGNORE_BACKEND_FIR: JVM_IR
val log = StringBuilder()
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package foo
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package foo
import kotlin.reflect.KProperty
@@ -14,7 +14,8 @@ class Delegate {
fun box(): String {
var prop: Int by Delegate()
if (prop != 1) return "fail get 1"
run { prop = 2 }
if (prop != 2) return "fail get"
return run { if (prop != 2) "fail set" else "OK" }
if (prop != 2) return "fail get 2"
return run { if (prop != 2) "fail get 3" else "OK" }
}
@@ -14,7 +14,8 @@ class Delegate {
fun box(): String {
var prop: Int by Delegate()
if (prop != 1) return "fail get 1"
run { prop = 2 }
if (prop != 2) return "fail get"
return run { if (prop != 2) "fail set" else "OK" }
if (prop != 2) return "fail get 2"
return run { if (prop != 2) "fail get 3" else "OK" }
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package foo
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package foo
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
//WITH_RUNTIME
fun box(): String {
val x by lazy { "OK" }
@@ -1,5 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
object Whatever {
operator fun getValue(thisRef: Any?, prop: Any?) = "OK"
}
@@ -1,5 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Delegate(val value: String) {
operator fun getValue(thisRef: Any?, kProperty: Any?) = value
}
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package foo
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package foo
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package foo
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
package foo
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Provider<T>(val _value: T) {
inline operator fun provideDelegate(thisRef: Any?, kProperty: Any?) =
Mut(_value)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
class Provider<T>(val _value: T) {
inline operator fun provideDelegate(thisRef: Any?, kProperty: Any) =
Mut(_value)
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// MODULE: lib
// FILE: lib.kt
package lib
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// MODULE: lib
// FILE: lib.kt
package lib
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
import kotlin.reflect.KProperty
operator fun Int.provideDelegate(thiz: Any?, property: KProperty<*>): String = property.name
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
val topLevelLazyVal by lazy { 1 }
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
import kotlin.reflect.KProperty
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
import kotlin.test.*
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
import kotlin.test.*
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
import kotlin.test.*
@@ -1,5 +1,4 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
import kotlin.reflect.KMutableProperty0
@@ -1,5 +1,4 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND_FIR: JVM_IR
var setterInvoked = 0
@@ -1,5 +1,4 @@
// !LANGUAGE: +InlineClasses
// IGNORE_BACKEND_FIR: JVM_IR
var setterInvoked = 0
@@ -1,5 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
import kotlin.reflect.KProperty
inline class ICInt(val i: Int)
@@ -30,4 +30,20 @@ FILE fqName:<root> fileName:/localDelegatedPropertiesWithAnnotations.kt
FUN name:foo visibility:public modality:FINAL <> (m:kotlin.collections.Map<kotlin.String, kotlin.Int>) returnType:kotlin.Unit
VALUE_PARAMETER name:m index:0 type:kotlin.collections.Map<kotlin.String, kotlin.Int>
BLOCK_BODY
VAR name:test type:kotlin.Int [val]
LOCAL_DELEGATED_PROPERTY name:test type:kotlin.Int flags:val
VAR PROPERTY_DELEGATE name:test$delegate type:kotlin.Lazy<kotlin.Int> [val]
CALL 'public final fun lazy <T> (initializer: kotlin.Function0<T of kotlin.lazy>): kotlin.Lazy<T of kotlin.lazy> declared in kotlin' type=kotlin.Lazy<kotlin.Int> origin=null
<T>: kotlin.Int
initializer: FUN_EXPR type=kotlin.Function0<kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.foo'
CONST Int type=kotlin.Int value=42
FUN DELEGATED_PROPERTY_ACCESSOR name:<get-test> visibility:local modality:FINAL <> () returnType:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <get-test> (): kotlin.Int declared in <root>.foo'
CALL 'public final fun getValue <T> (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null
<T>: kotlin.Int
$receiver: GET_VAR 'val test$delegate: kotlin.Lazy<kotlin.Int> [val] declared in <root>.foo' type=kotlin.Lazy<kotlin.Int> origin=null
thisRef: CONST Null type=kotlin.Nothing? value=null
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'val test: kotlin.Int by (...)' delegate='val test$delegate: kotlin.Lazy<kotlin.Int> [val] declared in <root>.foo' getter='local final fun <get-test> (): kotlin.Int declared in <root>.foo' setter=null type=kotlin.reflect.KProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
@@ -1,24 +1,62 @@
FILE fqName:<root> fileName:/localDelegatedProperties.kt
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:x type:kotlin.Int [val]
LOCAL_DELEGATED_PROPERTY name:x type:kotlin.Int flags:val
VAR PROPERTY_DELEGATE name:x$delegate type:kotlin.Lazy<kotlin.Int> [val]
CALL 'public final fun lazy <T> (initializer: kotlin.Function0<T of kotlin.lazy>): kotlin.Lazy<T of kotlin.lazy> declared in kotlin' type=kotlin.Lazy<kotlin.Int> origin=null
<T>: kotlin.Int
initializer: FUN_EXPR type=kotlin.Function0<kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test1'
CONST Int type=kotlin.Int value=42
FUN DELEGATED_PROPERTY_ACCESSOR name:<get-x> visibility:local modality:FINAL <> () returnType:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <get-x> (): kotlin.Int declared in <root>.test1'
CALL 'public final fun getValue <T> (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): T of kotlin.getValue [inline,operator] declared in kotlin' type=kotlin.Int origin=null
<T>: kotlin.Int
$receiver: GET_VAR 'val x$delegate: kotlin.Lazy<kotlin.Int> [val] declared in <root>.test1' type=kotlin.Lazy<kotlin.Int> origin=null
thisRef: CONST Null type=kotlin.Nothing? value=null
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'val x: kotlin.Int by (...)' delegate='val x$delegate: kotlin.Lazy<kotlin.Int> [val] declared in <root>.test1' getter='local final fun <get-x> (): kotlin.Int declared in <root>.test1' setter=null type=kotlin.reflect.KProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
CALL 'public final fun println (message: kotlin.Int): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null
message: GET_VAR 'val x: kotlin.Int [val] declared in <root>.test1' type=kotlin.Int origin=null
message: CALL 'local final fun <get-x> (): kotlin.Int declared in <root>.test1' type=kotlin.Int origin=GET_LOCAL_PROPERTY
FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:x type:kotlin.Int? [var]
SET_VAR 'var x: kotlin.Int? [var] declared in <root>.test2' type=kotlin.Unit origin=EQ
CONST Int type=kotlin.Int value=0
LOCAL_DELEGATED_PROPERTY name:x type:kotlin.Int? flags:var
VAR PROPERTY_DELEGATE name:x$delegate type:java.util.HashMap<kotlin.String, kotlin.Int> [val]
CALL 'public final fun hashMapOf <K, V> (): java.util.HashMap<K of kotlin.collections.hashMapOf, V of kotlin.collections.hashMapOf> [inline] declared in kotlin.collections' type=java.util.HashMap<kotlin.String, kotlin.Int> origin=null
<K>: kotlin.String
<V>: kotlin.Int
FUN DELEGATED_PROPERTY_ACCESSOR name:<get-x> visibility:local modality:FINAL <> () returnType:kotlin.Int?
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <get-x> (): kotlin.Int? declared in <root>.test2'
CALL 'public final fun getValue <V, V1> (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>): V1 of kotlin.collections.getValue [inline,operator] declared in kotlin.collections' type=kotlin.Int? origin=null
<V>: kotlin.Int?
<V1>: kotlin.Int?
$receiver: GET_VAR 'val x$delegate: java.util.HashMap<kotlin.String, kotlin.Int> [val] declared in <root>.test2' type=java.util.HashMap<kotlin.String, kotlin.Int> origin=null
thisRef: CONST Null type=kotlin.Nothing? value=null
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'var x: kotlin.Int? by (...)' delegate='val x$delegate: java.util.HashMap<kotlin.String, kotlin.Int> [val] declared in <root>.test2' getter='local final fun <get-x> (): kotlin.Int? declared in <root>.test2' setter='local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.reflect.KMutableProperty0<kotlin.Int?> origin=PROPERTY_REFERENCE_FOR_DELEGATE
FUN DELEGATED_PROPERTY_ACCESSOR name:<set-x> visibility:local modality:FINAL <> (<set-?>:kotlin.Int?) returnType:kotlin.Unit
VALUE_PARAMETER name:<set-?> index:0 type:kotlin.Int?
BLOCK_BODY
CALL 'public final fun setValue <V> (thisRef: kotlin.Any?, property: kotlin.reflect.KProperty<*>, value: V of kotlin.collections.setValue): kotlin.Unit [inline,operator] declared in kotlin.collections' type=kotlin.Unit origin=null
<V>: kotlin.Int?
$receiver: GET_VAR 'val x$delegate: java.util.HashMap<kotlin.String, kotlin.Int> [val] declared in <root>.test2' type=java.util.HashMap<kotlin.String, kotlin.Int> origin=null
thisRef: CONST Null type=kotlin.Nothing? value=null
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'var x: kotlin.Int? by (...)' delegate='val x$delegate: java.util.HashMap<kotlin.String, kotlin.Int> [val] declared in <root>.test2' getter='local final fun <get-x> (): kotlin.Int? declared in <root>.test2' setter='local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.reflect.KMutableProperty0<kotlin.Int?> origin=PROPERTY_REFERENCE_FOR_DELEGATE
value: GET_VAR '<set-?>: kotlin.Int? declared in <root>.test2.<set-x>' type=kotlin.Int? origin=null
CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ
<set-?>: CONST Int type=kotlin.Int value=0
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val]
TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int
GET_VAR 'var x: kotlin.Int? [var] declared in <root>.test2' type=kotlin.Int? origin=null
SET_VAR 'var x: kotlin.Int? [var] declared in <root>.test2' type=kotlin.Unit origin=EQ
CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
CALL 'local final fun <get-x> (): kotlin.Int? declared in <root>.test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY
CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ
<set-?>: CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
GET_VAR 'val tmp_0: kotlin.Int [val] declared in <root>.test2' type=kotlin.Int origin=null
SET_VAR 'var x: kotlin.Int? [var] declared in <root>.test2' type=kotlin.Unit origin=EQ
CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
CALL 'local final fun <set-x> (<set-?>: kotlin.Int?): kotlin.Unit declared in <root>.test2' type=kotlin.Unit origin=EQ
<set-?>: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null
$this: TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int
GET_VAR 'var x: kotlin.Int? [var] declared in <root>.test2' type=kotlin.Int? origin=null
CALL 'local final fun <get-x> (): kotlin.Int? declared in <root>.test2' type=kotlin.Int? origin=GET_LOCAL_PROPERTY
other: CONST Int type=kotlin.Int value=1
@@ -1,83 +0,0 @@
FILE fqName:<root> fileName:/local.kt
CLASS CLASS name:Delegate modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Delegate
CONSTRUCTOR visibility:public <> (value:kotlin.String) returnType:<root>.Delegate [primary]
VALUE_PARAMETER name:value index:0 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Delegate modality:FINAL visibility:public superTypes:[kotlin.Any]'
PROPERTY name:value visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.String visibility:private [final]
EXPRESSION_BODY
GET_VAR 'value: kotlin.String declared in <root>.Delegate.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-value> visibility:public modality:FINAL <> ($this:<root>.Delegate) returnType:kotlin.String
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Delegate
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-value> (): kotlin.String declared in <root>.Delegate'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.Delegate declared in <root>.Delegate.<get-value>' type=<root>.Delegate origin=null
FUN name:getValue visibility:public modality:FINAL <> ($this:<root>.Delegate, thisRef:kotlin.Any?, property:kotlin.Any?) returnType:kotlin.String [operator]
$this: VALUE_PARAMETER name:<this> type:<root>.Delegate
VALUE_PARAMETER name:thisRef index:0 type:kotlin.Any?
VALUE_PARAMETER name:property index:1 type:kotlin.Any?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun getValue (thisRef: kotlin.Any?, property: kotlin.Any?): kotlin.String [operator] declared in <root>.Delegate'
CALL 'public final fun <get-value> (): kotlin.String declared in <root>.Delegate' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Delegate declared in <root>.Delegate.getValue' type=<root>.Delegate origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
CLASS CLASS name:DelegateProvider modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.DelegateProvider
CONSTRUCTOR visibility:public <> (value:kotlin.String) returnType:<root>.DelegateProvider [primary]
VALUE_PARAMETER name:value index:0 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:DelegateProvider modality:FINAL visibility:public superTypes:[kotlin.Any]'
PROPERTY name:value visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.String visibility:private [final]
EXPRESSION_BODY
GET_VAR 'value: kotlin.String declared in <root>.DelegateProvider.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-value> visibility:public modality:FINAL <> ($this:<root>.DelegateProvider) returnType:kotlin.String
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.DelegateProvider
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-value> (): kotlin.String declared in <root>.DelegateProvider'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.DelegateProvider declared in <root>.DelegateProvider.<get-value>' type=<root>.DelegateProvider origin=null
FUN name:provideDelegate visibility:public modality:FINAL <> ($this:<root>.DelegateProvider, thisRef:kotlin.Any?, property:kotlin.Any?) returnType:<root>.Delegate [operator]
$this: VALUE_PARAMETER name:<this> type:<root>.DelegateProvider
VALUE_PARAMETER name:thisRef index:0 type:kotlin.Any?
VALUE_PARAMETER name:property index:1 type:kotlin.Any?
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun provideDelegate (thisRef: kotlin.Any?, property: kotlin.Any?): <root>.Delegate [operator] declared in <root>.DelegateProvider'
CONSTRUCTOR_CALL 'public constructor <init> (value: kotlin.String) [primary] declared in <root>.Delegate' type=<root>.Delegate origin=null
value: CALL 'public final fun <get-value> (): kotlin.String declared in <root>.DelegateProvider' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.DelegateProvider declared in <root>.DelegateProvider.provideDelegate' type=<root>.DelegateProvider origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:testMember type:kotlin.String [val]
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
class Delegate(val value: String) {
operator fun getValue(thisRef: Any?, property: Any?) = value
}
@@ -1,57 +0,0 @@
FILE fqName:<root> fileName:/localDifferentReceivers.kt
CLASS CLASS name:MyClass modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyClass
CONSTRUCTOR visibility:public <> (value:kotlin.String) returnType:<root>.MyClass [primary]
VALUE_PARAMETER name:value index:0 type:kotlin.String
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:MyClass modality:FINAL visibility:public superTypes:[kotlin.Any]'
PROPERTY name:value visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.String visibility:private [final]
EXPRESSION_BODY
GET_VAR 'value: kotlin.String declared in <root>.MyClass.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-value> visibility:public modality:FINAL <> ($this:<root>.MyClass) returnType:kotlin.String
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.MyClass
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-value> (): kotlin.String declared in <root>.MyClass'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:value type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
receiver: GET_VAR '<this>: <root>.MyClass declared in <root>.MyClass.<get-value>' type=<root>.MyClass origin=null
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override]
overridden:
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
FUN name:provideDelegate visibility:public modality:FINAL <> ($receiver:<root>.MyClass, host:kotlin.Any?, p:kotlin.Any) returnType:kotlin.String [operator]
$receiver: VALUE_PARAMETER name:<this> type:<root>.MyClass
VALUE_PARAMETER name:host index:0 type:kotlin.Any?
VALUE_PARAMETER name:p index:1 type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun provideDelegate (host: kotlin.Any?, p: kotlin.Any): kotlin.String [operator] declared in <root>'
CALL 'public final fun <get-value> (): kotlin.String declared in <root>.MyClass' type=kotlin.String origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.MyClass declared in <root>.provideDelegate' type=<root>.MyClass origin=null
FUN name:getValue visibility:public modality:FINAL <> ($receiver:kotlin.String, receiver:kotlin.Any?, p:kotlin.Any) returnType:kotlin.String [operator]
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
VALUE_PARAMETER name:receiver index:0 type:kotlin.Any?
VALUE_PARAMETER name:p index:1 type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun getValue (receiver: kotlin.Any?, p: kotlin.Any): kotlin.String [operator] declared in <root>'
GET_VAR '<this>: kotlin.String declared in <root>.getValue' type=kotlin.String origin=null
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
BLOCK_BODY
VAR name:testO type:kotlin.String [val]
VAR name:testK type:kotlin.String [val]
VAR name:testOK type:kotlin.String [val]
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS
$this: GET_VAR 'val testO: kotlin.String [val] declared in <root>.box' type=kotlin.String origin=null
other: GET_VAR 'val testK: kotlin.String [val] declared in <root>.box' type=kotlin.String origin=null
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
GET_VAR 'val testOK: kotlin.String [val] declared in <root>.box' type=kotlin.String origin=null
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// WITH_RUNTIME
class MyClass(val value: String)