Return type of local delegated property setter should be Unit
#KT-17950 Fixed
This commit is contained in:
+5
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.descriptors.impl
|
|||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
sealed class LocalVariableAccessorDescriptor(
|
sealed class LocalVariableAccessorDescriptor(
|
||||||
@@ -38,7 +39,10 @@ sealed class LocalVariableAccessorDescriptor(
|
|||||||
init {
|
init {
|
||||||
val valueParameters =
|
val valueParameters =
|
||||||
if (isGetter) emptyList() else listOf(createValueParameter(Name.identifier("value"), correspondingVariable.type))
|
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 {
|
private fun createValueParameter(name: Name, type: KotlinType): ValueParameterDescriptorImpl {
|
||||||
|
|||||||
@@ -35,33 +35,31 @@ FILE /localDelegatedProperties.kt
|
|||||||
<V>: Int
|
<V>: Int
|
||||||
$receiver: GET_VAR '`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' type=kotlin.collections.HashMap<kotlin.String, kotlin.Int> /* = java.util.HashMap<kotlin.String, kotlin.Int> */ origin=null
|
$receiver: GET_VAR '`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' type=kotlin.collections.HashMap<kotlin.String, kotlin.Int> /* = java.util.HashMap<kotlin.String, kotlin.Int> */ origin=null
|
||||||
thisRef: CONST Null type=kotlin.Nothing? value='null'
|
thisRef: CONST Null type=kotlin.Nothing? value='null'
|
||||||
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' getter='<get-x>(): Int' setter='<set-x>(Int): Int' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' getter='<get-x>(): Int' setter='<set-x>(Int): Unit' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
||||||
FUN DELEGATED_PROPERTY_ACCESSOR local final fun <set-x>(value: kotlin.Int): kotlin.Int
|
FUN DELEGATED_PROPERTY_ACCESSOR local final fun <set-x>(value: kotlin.Int): kotlin.Unit
|
||||||
VALUE_PARAMETER value-parameter value: kotlin.Int
|
VALUE_PARAMETER value-parameter value: kotlin.Int
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='<set-x>(Int): Int'
|
RETURN type=kotlin.Nothing from='<set-x>(Int): Unit'
|
||||||
TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int
|
CALL 'setValue(Any?, KProperty<*>, Int) on MutableMap<in String, in Int>: Unit' type=kotlin.Unit origin=null
|
||||||
CALL 'setValue(Any?, KProperty<*>, Int) on MutableMap<in String, in Int>: Unit' type=kotlin.Unit origin=null
|
<V>: Int
|
||||||
<V>: Int
|
$receiver: GET_VAR '`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' type=kotlin.collections.HashMap<kotlin.String, kotlin.Int> /* = java.util.HashMap<kotlin.String, kotlin.Int> */ origin=null
|
||||||
$receiver: GET_VAR '`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' type=kotlin.collections.HashMap<kotlin.String, kotlin.Int> /* = java.util.HashMap<kotlin.String, kotlin.Int> */ origin=null
|
thisRef: CONST Null type=kotlin.Nothing? value='null'
|
||||||
thisRef: CONST Null type=kotlin.Nothing? value='null'
|
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' getter='<get-x>(): Int' setter='<set-x>(Int): Unit' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
||||||
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'x: Int' delegate='`x$delegate`: HashMap<String, Int> /* = HashMap<String, Int> */' getter='<get-x>(): Int' setter='<set-x>(Int): Int' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
value: GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=null
|
||||||
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
|
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||||
CALL '<set-x>(Int): Int' type=kotlin.Int origin=EQ
|
CALL '<set-x>(Int): Unit' type=kotlin.Int origin=EQ
|
||||||
value: CONST Int type=kotlin.Int value='0'
|
value: CONST Int type=kotlin.Int value='0'
|
||||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||||
BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
||||||
VAR IR_TEMPORARY_VARIABLE val tmp0: kotlin.Int
|
VAR IR_TEMPORARY_VARIABLE val tmp0: kotlin.Int
|
||||||
CALL '<get-x>(): Int' type=kotlin.Int origin=POSTFIX_INCR
|
CALL '<get-x>(): Int' type=kotlin.Int origin=POSTFIX_INCR
|
||||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||||
CALL '<set-x>(Int): Int' type=kotlin.Int origin=POSTFIX_INCR
|
CALL '<set-x>(Int): Unit' type=kotlin.Int origin=POSTFIX_INCR
|
||||||
value: CALL 'inc(): Int' 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
|
$this: GET_VAR 'tmp0: Int' type=kotlin.Int origin=null
|
||||||
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
|
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||||
CALL '<set-x>(Int): Int' type=kotlin.Int origin=PLUSEQ
|
CALL '<set-x>(Int): Unit' type=kotlin.Int origin=PLUSEQ
|
||||||
value: CALL 'plus(Int): Int' type=kotlin.Int origin=PLUSEQ
|
value: CALL 'plus(Int): Int' type=kotlin.Int origin=PLUSEQ
|
||||||
$this: CALL '<get-x>(): Int' type=kotlin.Int origin=PLUSEQ
|
$this: CALL '<get-x>(): Int' type=kotlin.Int origin=PLUSEQ
|
||||||
other: CONST Int type=kotlin.Int value='1'
|
other: CONST Int type=kotlin.Int value='1'
|
||||||
|
|
||||||
|
|||||||
+9
-10
@@ -97,21 +97,20 @@ FILE /localDelegatedPropertyWithSuspendOperators.kt
|
|||||||
CALL 'provideDelegate(Any?, Any): A' type=A origin=null
|
CALL 'provideDelegate(Any?, Any): A' type=A origin=null
|
||||||
$this: CALL 'constructor A()' type=A origin=null
|
$this: CALL 'constructor A()' type=A origin=null
|
||||||
host: CONST Null type=kotlin.Nothing? value='null'
|
host: CONST Null type=kotlin.Nothing? value='null'
|
||||||
p: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='<get-testVar>(): Int' setter='<set-testVar>(Int): Int' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
p: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='<get-testVar>(): Int' setter='<set-testVar>(Int): Unit' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
||||||
FUN DELEGATED_PROPERTY_ACCESSOR local final suspend fun <get-testVar>(): kotlin.Int
|
FUN DELEGATED_PROPERTY_ACCESSOR local final suspend fun <get-testVar>(): kotlin.Int
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='<get-testVar>(): Int'
|
RETURN type=kotlin.Nothing from='<get-testVar>(): Int'
|
||||||
CALL 'getValue(Any?, KProperty<*>): Int' type=kotlin.Int origin=null
|
CALL 'getValue(Any?, KProperty<*>): Int' type=kotlin.Int origin=null
|
||||||
$this: GET_VAR '`testVar$delegate`: A' type=A origin=null
|
$this: GET_VAR '`testVar$delegate`: A' type=A origin=null
|
||||||
thisRef: CONST Null type=kotlin.Nothing? value='null'
|
thisRef: CONST Null type=kotlin.Nothing? value='null'
|
||||||
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='<get-testVar>(): Int' setter='<set-testVar>(Int): Int' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='<get-testVar>(): Int' setter='<set-testVar>(Int): Unit' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
||||||
FUN DELEGATED_PROPERTY_ACCESSOR local final suspend fun <set-testVar>(value: kotlin.Int): kotlin.Int
|
FUN DELEGATED_PROPERTY_ACCESSOR local final suspend fun <set-testVar>(value: kotlin.Int): kotlin.Unit
|
||||||
VALUE_PARAMETER value-parameter value: kotlin.Int
|
VALUE_PARAMETER value-parameter value: kotlin.Int
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
RETURN type=kotlin.Nothing from='<set-testVar>(Int): Int'
|
RETURN type=kotlin.Nothing from='<set-testVar>(Int): Unit'
|
||||||
TYPE_OP type=kotlin.Int origin=IMPLICIT_CAST typeOperand=kotlin.Int
|
CALL 'setValue(Any?, KProperty<*>, Int): Unit' type=kotlin.Unit origin=null
|
||||||
CALL 'setValue(Any?, KProperty<*>, Int): Unit' type=kotlin.Unit origin=null
|
$this: GET_VAR '`testVar$delegate`: A' type=A origin=null
|
||||||
$this: GET_VAR '`testVar$delegate`: A' type=A origin=null
|
thisRef: CONST Null type=kotlin.Nothing? value='null'
|
||||||
thisRef: CONST Null type=kotlin.Nothing? value='null'
|
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='<get-testVar>(): Int' setter='<set-testVar>(Int): Unit' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
||||||
property: LOCAL_DELEGATED_PROPERTY_REFERENCE 'testVar: Int' delegate='`testVar$delegate`: A' getter='<get-testVar>(): Int' setter='<set-testVar>(Int): Int' type=kotlin.reflect.KMutableProperty0<kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
|
value: GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=null
|
||||||
value: GET_VAR 'value-parameter value: Int' type=kotlin.Int origin=null
|
|
||||||
|
|||||||
Reference in New Issue
Block a user