K2: consider backing fields of vars as smartcast unstable
#KT-61974 Fixed
This commit is contained in:
committed by
Space Team
parent
8e577e101e
commit
8bd792792f
+2
-3
@@ -161,9 +161,8 @@ class VariableStorageImpl(private val session: FirSession) : VariableStorage() {
|
|||||||
if (originalFir is FirThisReceiverExpression) return PropertyStability.STABLE_VALUE
|
if (originalFir is FirThisReceiverExpression) return PropertyStability.STABLE_VALUE
|
||||||
when (this) {
|
when (this) {
|
||||||
is FirAnonymousObjectSymbol -> return null
|
is FirAnonymousObjectSymbol -> return null
|
||||||
is FirFunctionSymbol<*>,
|
is FirFunctionSymbol<*>, is FirClassSymbol<*> -> return PropertyStability.STABLE_VALUE
|
||||||
is FirClassSymbol<*>,
|
is FirBackingFieldSymbol -> return if (isVal) PropertyStability.STABLE_VALUE else PropertyStability.MUTABLE_PROPERTY
|
||||||
is FirBackingFieldSymbol -> return PropertyStability.STABLE_VALUE
|
|
||||||
}
|
}
|
||||||
if (this !is FirVariableSymbol<*>) return null
|
if (this !is FirVariableSymbol<*>) return null
|
||||||
if (this is FirFieldSymbol && !this.isFinal) return PropertyStability.MUTABLE_PROPERTY
|
if (this is FirFieldSymbol && !this.isFinal) return PropertyStability.MUTABLE_PROPERTY
|
||||||
|
|||||||
+3
-3
@@ -39,18 +39,18 @@ FILE fqName:<root> fileName:/elvisOnBackingFieldInGetter.kt
|
|||||||
value: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.ResourceTable' type=<root>.ResourceTable origin=null
|
value: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.ResourceTable' type=<root>.ResourceTable origin=null
|
||||||
RETURN type=kotlin.Nothing from='public final fun <get-resourceTable> (): <root>.ResourceTable? declared in <root>.Test'
|
RETURN type=kotlin.Nothing from='public final fun <get-resourceTable> (): <root>.ResourceTable? declared in <root>.Test'
|
||||||
BLOCK type=<root>.ResourceTable origin=ELVIS
|
BLOCK type=<root>.ResourceTable origin=ELVIS
|
||||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Nothing? [val]
|
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:<root>.ResourceTable? [val]
|
||||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:<root>.ResourceTable? visibility:private' type=<root>.ResourceTable? origin=GET_PROPERTY
|
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:resourceTable type:<root>.ResourceTable? visibility:private' type=<root>.ResourceTable? origin=GET_PROPERTY
|
||||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.<get-resourceTable>' type=<root>.Test origin=null
|
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.<get-resourceTable>' type=<root>.Test origin=null
|
||||||
WHEN type=<root>.ResourceTable origin=null
|
WHEN type=<root>.ResourceTable origin=null
|
||||||
BRANCH
|
BRANCH
|
||||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||||
arg0: GET_VAR 'val tmp_0: kotlin.Nothing? declared in <root>.Test.<get-resourceTable>' type=kotlin.Nothing? origin=null
|
arg0: GET_VAR 'val tmp_0: <root>.ResourceTable? declared in <root>.Test.<get-resourceTable>' type=<root>.ResourceTable? origin=null
|
||||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||||
then: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.ResourceTable' type=<root>.ResourceTable origin=null
|
then: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.ResourceTable' type=<root>.ResourceTable origin=null
|
||||||
BRANCH
|
BRANCH
|
||||||
if: CONST Boolean type=kotlin.Boolean value=true
|
if: CONST Boolean type=kotlin.Boolean value=true
|
||||||
then: GET_VAR 'val tmp_0: kotlin.Nothing? declared in <root>.Test.<get-resourceTable>' type=kotlin.Nothing? origin=null
|
then: GET_VAR 'val tmp_0: <root>.ResourceTable? declared in <root>.Test.<get-resourceTable>' type=<root>.ResourceTable? origin=null
|
||||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-resourceTable> visibility:public modality:FINAL <> ($this:<root>.Test, <set-?>:<root>.ResourceTable?) returnType:kotlin.Unit
|
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-resourceTable> visibility:public modality:FINAL <> ($this:<root>.Test, <set-?>:<root>.ResourceTable?) returnType:kotlin.Unit
|
||||||
correspondingProperty: PROPERTY name:resourceTable visibility:public modality:FINAL [var]
|
correspondingProperty: PROPERTY name:resourceTable visibility:public modality:FINAL [var]
|
||||||
$this: VALUE_PARAMETER name:<this> type:<root>.Test
|
$this: VALUE_PARAMETER name:<this> type:<root>.Test
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ class Test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { // BLOCK
|
return { // BLOCK
|
||||||
val <elvis>: Nothing? = <this>.#resourceTable
|
val <elvis>: ResourceTable? = <this>.#resourceTable
|
||||||
when {
|
when {
|
||||||
EQEQ(arg0 = <elvis>, arg1 = null) -> ResourceTable()
|
EQEQ(arg0 = <elvis>, arg1 = null) -> ResourceTable()
|
||||||
else -> <elvis>
|
else -> <elvis>
|
||||||
|
|||||||
Reference in New Issue
Block a user