diff --git a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/LocalVariableAccessorDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/LocalVariableAccessorDescriptor.kt index 270afbe0dff..0d1513859e9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/LocalVariableAccessorDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/descriptors/impl/LocalVariableAccessorDescriptor.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.descriptors.impl import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns import org.jetbrains.kotlin.types.KotlinType sealed class LocalVariableAccessorDescriptor( @@ -38,7 +39,10 @@ sealed class LocalVariableAccessorDescriptor( init { val valueParameters = if (isGetter) emptyList() else listOf(createValueParameter(Name.identifier("value"), correspondingVariable.type)) - initialize(null, null, emptyList(), valueParameters, correspondingVariable.type, Modality.FINAL, Visibilities.LOCAL) + val returnType = + if (isGetter) correspondingVariable.type else correspondingVariable.builtIns.unitType + @Suppress("LeakingThis") + initialize(null, null, emptyList(), valueParameters, returnType, Modality.FINAL, Visibilities.LOCAL) } private fun createValueParameter(name: Name, type: KotlinType): ValueParameterDescriptorImpl { diff --git a/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt b/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt index cba3620ce16..0e8fd4e24ab 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedProperties.txt @@ -35,33 +35,31 @@ FILE /localDelegatedProperties.kt : Int $receiver: GET_VAR '`x$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null thisRef: CONST Null type=kotlin.Nothing? value='null' - property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap /* = HashMap */' getter='(): Int' setter='(Int): Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE - FUN DELEGATED_PROPERTY_ACCESSOR local final fun (value: kotlin.Int): kotlin.Int + property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap /* = HashMap */' getter='(): Int' setter='(Int): Unit' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + FUN DELEGATED_PROPERTY_ACCESSOR local final fun (value: kotlin.Int): kotlin.Unit VALUE_PARAMETER value-parameter value: kotlin.Int BLOCK_BODY - RETURN type=kotlin.Nothing from='(Int): Int' - TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int - CALL 'setValue(Any?, KProperty<*>, Int) on MutableMap: Unit' type=kotlin.Unit origin=null - : Int - $receiver: GET_VAR '`x$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null - thisRef: CONST Null type=kotlin.Nothing? value='null' - property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap /* = HashMap */' getter='(): Int' setter='(Int): Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE - value: GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='(Int): Unit' + CALL 'setValue(Any?, KProperty<*>, Int) on MutableMap: Unit' type=kotlin.Unit origin=null + : Int + $receiver: GET_VAR '`x$delegate`: HashMap /* = HashMap */' type=kotlin.collections.HashMap /* = java.util.HashMap */ origin=null + thisRef: CONST Null type=kotlin.Nothing? value='null' + property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap /* = HashMap */' getter='(): Int' setter='(Int): Unit' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + value: GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL '(Int): Int' type=kotlin.Int origin=EQ + CALL '(Int): Unit' type=kotlin.Int origin=EQ value: CONST Int type=kotlin.Int value='0' TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int origin=POSTFIX_INCR VAR IR_TEMPORARY_VARIABLE val tmp0: kotlin.Int CALL '(): Int' type=kotlin.Int origin=POSTFIX_INCR TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL '(Int): Int' type=kotlin.Int origin=POSTFIX_INCR + CALL '(Int): Unit' type=kotlin.Int origin=POSTFIX_INCR value: CALL 'inc(): Int' type=kotlin.Int origin=POSTFIX_INCR $this: GET_VAR 'tmp0: Int' type=kotlin.Int origin=null GET_VAR 'tmp0: Int' type=kotlin.Int origin=null TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL '(Int): Int' type=kotlin.Int origin=PLUSEQ + CALL '(Int): Unit' type=kotlin.Int origin=PLUSEQ value: CALL 'plus(Int): Int' type=kotlin.Int origin=PLUSEQ $this: CALL '(): Int' type=kotlin.Int origin=PLUSEQ other: CONST Int type=kotlin.Int value='1' - diff --git a/compiler/testData/ir/irText/declarations/localDelegatedPropertyWithSuspendOperators.txt b/compiler/testData/ir/irText/declarations/localDelegatedPropertyWithSuspendOperators.txt index 70589bceb68..58ee488a560 100644 --- a/compiler/testData/ir/irText/declarations/localDelegatedPropertyWithSuspendOperators.txt +++ b/compiler/testData/ir/irText/declarations/localDelegatedPropertyWithSuspendOperators.txt @@ -97,21 +97,20 @@ FILE /localDelegatedPropertyWithSuspendOperators.kt CALL 'provideDelegate(Any?, Any): A' type=A origin=null $this: CALL 'constructor A()' type=A origin=null host: CONST Null type=kotlin.Nothing? value='null' - p: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='(): Int' setter='(Int): Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + p: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='(): Int' setter='(Int): Unit' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE FUN DELEGATED_PROPERTY_ACCESSOR local final suspend fun (): kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='(): Int' CALL 'getValue(Any?, KProperty<*>): Int' type=kotlin.Int origin=null $this: GET_VAR '`testVar$delegate`: A' type=A origin=null thisRef: CONST Null type=kotlin.Nothing? value='null' - property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='(): Int' setter='(Int): Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE - FUN DELEGATED_PROPERTY_ACCESSOR local final suspend fun (value: kotlin.Int): kotlin.Int + property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='(): Int' setter='(Int): Unit' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + FUN DELEGATED_PROPERTY_ACCESSOR local final suspend fun (value: kotlin.Int): kotlin.Unit VALUE_PARAMETER value-parameter value: kotlin.Int BLOCK_BODY - RETURN type=kotlin.Nothing from='(Int): Int' - TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int - CALL 'setValue(Any?, KProperty<*>, Int): Unit' type=kotlin.Unit origin=null - $this: GET_VAR '`testVar$delegate`: A' type=A origin=null - thisRef: CONST Null type=kotlin.Nothing? value='null' - property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='(): Int' setter='(Int): Int' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE - value: GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='(Int): Unit' + CALL 'setValue(Any?, KProperty<*>, Int): Unit' type=kotlin.Unit origin=null + $this: GET_VAR '`testVar$delegate`: A' type=A origin=null + thisRef: CONST Null type=kotlin.Nothing? value='null' + property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='(): Int' setter='(Int): Unit' type=kotlin.reflect.KMutableProperty0 origin=PROPERTY_REFERENCE_FOR_DELEGATE + value: GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=null