K2: restore smart cast in case with invisible receiver but visible callable
Related to KT-52432 #KT-63164 Fixed
This commit is contained in:
committed by
Space Team
parent
a139965231
commit
ec7caba8ea
@@ -71,7 +71,12 @@ fun FirVisibilityChecker.isVisible(
|
||||
|
||||
if (!isVisible(declaration, callInfo, dispatchReceiverWithoutSmartCastType, skipCheckForContainingClassVisibility)) return false
|
||||
|
||||
candidate.dispatchReceiver = dispatchReceiverWithoutSmartCastType
|
||||
// Note: in case of a smart cast, we already checked the visibility of the smart cast target before,
|
||||
// so now it's visibility is not important, only callable visibility itself should be taken into account
|
||||
// Otherwise we avoid correct smart casts in corner cases like KT-63164
|
||||
if (!isVisible(declaration, callInfo, candidate.dispatchReceiver, skipCheckForContainingClassVisibility = true)) {
|
||||
candidate.dispatchReceiver = dispatchReceiverWithoutSmartCastType
|
||||
}
|
||||
}
|
||||
|
||||
val backingField = declaration.getBackingFieldIfApplicable()
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
Module: m1
|
||||
FILE fqName:<root> fileName:/info.kt
|
||||
CLASS CLASS name:Info modality:FINAL visibility:internal superTypes:[kotlin.Any]
|
||||
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Info
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.Info [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in kotlin.Any'
|
||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Info modality:FINAL visibility:internal superTypes:[kotlin.Any]'
|
||||
PROPERTY name:status visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:status type:kotlin.String visibility:private [final]
|
||||
EXPRESSION_BODY
|
||||
CONST String type=kotlin.String value="OK"
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-status> visibility:public modality:FINAL <> ($this:<root>.Info) returnType:kotlin.String
|
||||
correspondingProperty: PROPERTY name:status visibility:public modality:FINAL [val]
|
||||
$this: VALUE_PARAMETER name:<this> type:<root>.Info
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-status> (): kotlin.String declared in <root>.Info'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:status type:kotlin.String visibility:private [final]' type=kotlin.String origin=null
|
||||
receiver: GET_VAR '<this>: <root>.Info declared in <root>.Info.<get-status>' type=<root>.Info 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 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
|
||||
PROPERTY name:info visibility:public modality:FINAL [val]
|
||||
FIELD PROPERTY_BACKING_FIELD name:info type:kotlin.Any? visibility:private [final,static]
|
||||
EXPRESSION_BODY
|
||||
CONSTRUCTOR_CALL 'public constructor <init> () declared in <root>.Info' type=<root>.Info origin=null
|
||||
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-info> visibility:public modality:FINAL <> () returnType:kotlin.Any?
|
||||
correspondingProperty: PROPERTY name:info visibility:public modality:FINAL [val]
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun <get-info> (): kotlin.Any? declared in <root>'
|
||||
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:info type:kotlin.Any? visibility:private [final,static]' type=kotlin.Any? origin=null
|
||||
Module: m2
|
||||
FILE fqName:<root> fileName:/box.kt
|
||||
FUN name:getStatus visibility:public modality:FINAL <> (param:kotlin.Any?) returnType:kotlin.String
|
||||
VALUE_PARAMETER name:param index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=<root>.Info
|
||||
GET_VAR 'param: kotlin.Any? declared in <root>.getStatus' type=kotlin.Any? origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun getStatus (param: kotlin.Any?): kotlin.String declared in <root>'
|
||||
CALL 'public final fun <get-status> (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=GET_PROPERTY
|
||||
$this: GET_VAR 'param: kotlin.Any? declared in <root>.getStatus' type=kotlin.Any? origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun getStatus (param: kotlin.Any?): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="NO STATUS"
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CALL 'public final fun getStatus (param: kotlin.Any?): kotlin.String declared in <root>' type=kotlin.String origin=null
|
||||
param: CALL 'public final fun <get-info> (): kotlin.Any? declared in <root>' type=kotlin.Any? origin=GET_PROPERTY
|
||||
@@ -1,7 +1,6 @@
|
||||
// IGNORE_BACKEND_K2: JVM_IR, JS_IR, NATIVE, WASM
|
||||
// FIR status: see KT-63164
|
||||
// ISSUE: KT-63164
|
||||
// DUMP_IR
|
||||
// FIR_IDENTICAL
|
||||
|
||||
// MODULE: m1
|
||||
// FILE: info.kt
|
||||
|
||||
Reference in New Issue
Block a user