PSI2IR KT-44855 propagate smart cast information for property values

This commit is contained in:
Dmitry Petrov
2021-07-29 15:30:07 +03:00
committed by teamcityserver
parent cdbd0eb932
commit ca5ebdc13c
12 changed files with 322 additions and 5 deletions
+75
View File
@@ -0,0 +1,75 @@
FILE fqName:<root> fileName:/kt44855.kt
CLASS CLASS name:Child modality:OPEN visibility:public superTypes:[<root>.Parent]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Child
CONSTRUCTOR visibility:public <> (x:<root>.Parent?) returnType:<root>.Child [primary]
VALUE_PARAMETER name:x index:0 type:<root>.Parent?
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Parent'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Child modality:OPEN visibility:public superTypes:[<root>.Parent]'
PROPERTY name:x visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:x type:<root>.Parent? visibility:private [final]
EXPRESSION_BODY
GET_VAR 'x: <root>.Parent? declared in <root>.Child.<init>' type=<root>.Parent? origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.Child) returnType:<root>.Parent?
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Child
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-x> (): <root>.Parent? declared in <root>.Child'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:<root>.Parent? visibility:private [final]' type=<root>.Parent? origin=null
receiver: GET_VAR '<this>: <root>.Child declared in <root>.Child.<get-x>' type=<root>.Child origin=null
CLASS CLASS name:QQQ modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Child.QQQ
CONSTRUCTOR visibility:public <> ($this:<root>.Child) returnType:<root>.Child.QQQ [primary]
$outer: VALUE_PARAMETER name:<this> type:<root>.Child
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:QQQ modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]'
FUN name:z visibility:public modality:FINAL <> ($this:<root>.Child.QQQ) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Child.QQQ
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Child origin=CAST typeOperand=<root>.Child
CALL 'public final fun <get-x> (): <root>.Parent? declared in <root>.Child' type=<root>.Parent? origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Child declared in <root>.Child' type=<root>.Child origin=null
VAR name:q type:@[FlexibleNullability] kotlin.String? [val]
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:qqq type:@[FlexibleNullability] kotlin.String? visibility:protected/*protected and package*/' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY
receiver: TYPE_OP type=<root>.Child origin=IMPLICIT_CAST typeOperand=<root>.Child
CALL 'public final fun <get-x> (): <root>.Parent? declared in <root>.Child' type=<root>.Parent? origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Child declared in <root>.Child' type=<root>.Child origin=null
SET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:qqq type:@[FlexibleNullability] kotlin.String? visibility:protected/*protected and package*/' type=kotlin.Unit origin=EQ
receiver: TYPE_OP type=<root>.Child origin=IMPLICIT_CAST typeOperand=<root>.Child
CALL 'public final fun <get-x> (): <root>.Parent? declared in <root>.Child' type=<root>.Parent? origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Child declared in <root>.Child' type=<root>.Child origin=null
value: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS
$this: GET_VAR 'val q: @[FlexibleNullability] kotlin.String? [val] declared in <root>.Child.QQQ.z' type=@[FlexibleNullability] kotlin.String? origin=null
other: CONST String type=kotlin.String value="OK"
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 [operator] 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
FUN FAKE_OVERRIDE name:getQqq visibility:public modality:OPEN <> ($this:<root>.Parent) returnType:@[FlexibleNullability] kotlin.String? [fake_override]
overridden:
public open fun getQqq (): @[FlexibleNullability] kotlin.String? declared in <root>.Parent
$this: VALUE_PARAMETER name:<this> type:<root>.Parent
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 [fake_override,operator] declared in <root>.Parent
$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 [fake_override] declared in <root>.Parent
$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 [fake_override] declared in <root>.Parent
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
+22
View File
@@ -0,0 +1,22 @@
// TARGET_BACKEND: JVM
// SKIP_KT_DUMP
// FILE: kt44855.kt
open class Child(val x: Parent?) : Parent() {
inner class QQQ {
fun z() {
x as Child
val q = x.qqq
x.qqq = q + "OK"
}
}
}
// FILE: Parent.java
public class Parent {
protected String qqq = "";
public String getQqq() {
return qqq;
}
}
+79
View File
@@ -0,0 +1,79 @@
FILE fqName:<root> fileName:/kt44855.kt
CLASS CLASS name:Child modality:OPEN visibility:public superTypes:[<root>.Parent]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Child
CONSTRUCTOR visibility:public <> (x:<root>.Parent?) returnType:<root>.Child [primary]
VALUE_PARAMETER name:x index:0 type:<root>.Parent?
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in <root>.Parent'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Child modality:OPEN visibility:public superTypes:[<root>.Parent]'
PROPERTY name:x visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:x type:<root>.Parent? visibility:private [final]
EXPRESSION_BODY
GET_VAR 'x: <root>.Parent? declared in <root>.Child.<init>' type=<root>.Parent? origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.Child) returnType:<root>.Parent?
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Child
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-x> (): <root>.Parent? declared in <root>.Child'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:<root>.Parent? visibility:private [final]' type=<root>.Parent? origin=null
receiver: GET_VAR '<this>: <root>.Child declared in <root>.Child.<get-x>' type=<root>.Child origin=null
CLASS CLASS name:QQQ modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Child.QQQ
CONSTRUCTOR visibility:public <> ($this:<root>.Child) returnType:<root>.Child.QQQ [primary]
$outer: VALUE_PARAMETER name:<this> type:<root>.Child
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:QQQ modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]'
FUN name:z visibility:public modality:FINAL <> ($this:<root>.Child.QQQ) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.Child.QQQ
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.Child origin=CAST typeOperand=<root>.Child
CALL 'public final fun <get-x> (): <root>.Parent? declared in <root>.Child' type=<root>.Parent? origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Child declared in <root>.Child' type=<root>.Child origin=null
VAR name:q type:@[FlexibleNullability] kotlin.String? [val]
GET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:qqq type:@[FlexibleNullability] kotlin.String? visibility:protected/*protected and package*/' type=@[FlexibleNullability] kotlin.String? origin=GET_PROPERTY
receiver: TYPE_OP type=<root>.Child origin=IMPLICIT_CAST typeOperand=<root>.Child
CALL 'public final fun <get-x> (): <root>.Parent? declared in <root>.Child' type=<root>.Parent? origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Child declared in <root>.Child' type=<root>.Child origin=null
SET_FIELD 'FIELD IR_EXTERNAL_JAVA_DECLARATION_STUB name:qqq type:@[FlexibleNullability] kotlin.String? visibility:protected/*protected and package*/' type=kotlin.Unit origin=EQ
receiver: TYPE_OP type=<root>.Child origin=IMPLICIT_CAST typeOperand=<root>.Child
CALL 'public final fun <get-x> (): <root>.Parent? declared in <root>.Child' type=<root>.Parent? origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.Child declared in <root>.Child' type=<root>.Child origin=null
value: CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUS
$this: TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String
GET_VAR 'val q: @[FlexibleNullability] kotlin.String? [val] declared in <root>.Child.QQQ.z' type=@[FlexibleNullability] kotlin.String? origin=null
other: CONST String type=kotlin.String value="OK"
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 [operator] 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 FAKE_OVERRIDE name:qqq visibility:protected/*protected and package*/ modality:FINAL [fake_override,var]
overridden:
protected/*protected and package*/ final qqq: @[FlexibleNullability] kotlin.String? [var]
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 [fake_override,operator] declared in <root>.Parent
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
VALUE_PARAMETER name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:getQqq visibility:public modality:OPEN <> ($this:<root>.Parent) returnType:@[FlexibleNullability] kotlin.String? [fake_override]
overridden:
public open fun getQqq (): @[FlexibleNullability] kotlin.String? declared in <root>.Parent
$this: VALUE_PARAMETER name:<this> type:<root>.Parent
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override]
overridden:
public open fun hashCode (): kotlin.Int [fake_override] declared in <root>.Parent
$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 [fake_override] declared in <root>.Parent
$this: VALUE_PARAMETER name:<this> type:kotlin.Any