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
|
||||
when (this) {
|
||||
is FirAnonymousObjectSymbol -> return null
|
||||
is FirFunctionSymbol<*>,
|
||||
is FirClassSymbol<*>,
|
||||
is FirBackingFieldSymbol -> return PropertyStability.STABLE_VALUE
|
||||
is FirFunctionSymbol<*>, is FirClassSymbol<*> -> return PropertyStability.STABLE_VALUE
|
||||
is FirBackingFieldSymbol -> return if (isVal) PropertyStability.STABLE_VALUE else PropertyStability.MUTABLE_PROPERTY
|
||||
}
|
||||
if (this !is FirVariableSymbol<*>) return null
|
||||
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
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-resourceTable> (): <root>.ResourceTable? declared in <root>.Test'
|
||||
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
|
||||
receiver: GET_VAR '<this>: <root>.Test declared in <root>.Test.<get-resourceTable>' type=<root>.Test origin=null
|
||||
WHEN type=<root>.ResourceTable origin=null
|
||||
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
|
||||
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
|
||||
then: CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.ResourceTable' type=<root>.ResourceTable origin=null
|
||||
BRANCH
|
||||
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
|
||||
correspondingProperty: PROPERTY name:resourceTable visibility:public modality:FINAL [var]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Test
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class Test {
|
||||
}
|
||||
}
|
||||
return { // BLOCK
|
||||
val <elvis>: Nothing? = <this>.#resourceTable
|
||||
val <elvis>: ResourceTable? = <this>.#resourceTable
|
||||
when {
|
||||
EQEQ(arg0 = <elvis>, arg1 = null) -> ResourceTable()
|
||||
else -> <elvis>
|
||||
|
||||
Reference in New Issue
Block a user