FIR2IR: provide more precise conversion type context at some use-sites

This commit is contained in:
Mikhail Glukhikh
2022-06-29 14:48:43 +02:00
committed by Space
parent 517614a190
commit 2880cd8d5a
10 changed files with 38 additions and 132 deletions
@@ -75,6 +75,6 @@ FILE fqName:<root> fileName:/genericDelegatedProperty.kt
CALL 'public final fun setValue (thisRef: kotlin.Any?, kProp: kotlin.Any?, newValue: kotlin.Int): kotlin.Unit [operator] declared in <root>.Delegate' type=kotlin.Unit origin=null
$this: GET_FIELD 'FIELD PROPERTY_DELEGATE name:genericDelegatedProperty$delegate type:<root>.Delegate visibility:private [final,static]' type=<root>.Delegate origin=null
thisRef: GET_VAR '<this>: <root>.C<T of <root>.<set-genericDelegatedProperty>> declared in <root>.<set-genericDelegatedProperty>' type=<root>.C<T of <root>.<set-genericDelegatedProperty>> origin=null
kProp: PROPERTY_REFERENCE 'public final genericDelegatedProperty: kotlin.Int [delegated,var]' field=null getter='public final fun <get-genericDelegatedProperty> <T> (): kotlin.Int declared in <root>' setter='public final fun <set-genericDelegatedProperty> <T> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.reflect.KMutableProperty1<<root>.C<T of <root>.<get-genericDelegatedProperty>>, kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
kProp: PROPERTY_REFERENCE 'public final genericDelegatedProperty: kotlin.Int [delegated,var]' field=null getter='public final fun <get-genericDelegatedProperty> <T> (): kotlin.Int declared in <root>' setter='public final fun <set-genericDelegatedProperty> <T> (<set-?>: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.reflect.KMutableProperty1<<root>.C<T of <root>.<set-genericDelegatedProperty>>, kotlin.Int> origin=PROPERTY_REFERENCE_FOR_DELEGATE
<1>: <none>
newValue: GET_VAR '<set-?>: kotlin.Int declared in <root>.<set-genericDelegatedProperty>' type=kotlin.Int origin=null
@@ -181,7 +181,7 @@ FILE fqName:<root> fileName:/genericPropertyRef.kt
CALL 'public final fun <set-recivier> (<set-?>: kotlin.Any?): kotlin.Unit declared in <root>' type=kotlin.Unit origin=EQ
<set-?>: GET_VAR '<this>: T of <root>.<set-bar> declared in <root>.<set-bar>' type=T of <root>.<set-bar> origin=null
CALL 'public final fun <set-value2> (<set-?>: kotlin.Any?): kotlin.Unit declared in <root>' type=kotlin.Unit origin=EQ
<set-?>: GET_VAR 'value: T of <root>.<set-bar> declared in <root>.<set-bar>' type=T of <root>.<get-bar> origin=null
<set-?>: GET_VAR 'value: T of <root>.<set-bar> declared in <root>.<set-bar>' type=T of <root>.<set-bar> origin=null
PROPERTY name:barRef visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:barRef type:kotlin.reflect.KMutableProperty1<kotlin.String?, kotlin.String?> visibility:private [final,static]
EXPRESSION_BODY
@@ -1,81 +0,0 @@
FILE fqName:<root> fileName:/genericPropertyReferenceType.kt
CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C<T of <root>.C>
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
CONSTRUCTOR visibility:public <> (x:T of <root>.C) returnType:<root>.C<T of <root>.C> [primary]
VALUE_PARAMETER name:x index:0 type:T of <root>.C
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[kotlin.Any]'
PROPERTY name:x visibility:public modality:FINAL [var]
FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:private
EXPRESSION_BODY
GET_VAR 'x: T of <root>.C declared in <root>.C.<init>' type=T of <root>.C origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.C<T of <root>.C>) returnType:T of <root>.C
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var]
$this: VALUE_PARAMETER name:<this> type:<root>.C<T of <root>.C>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-x> (): T of <root>.C declared in <root>.C'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:private' type=T of <root>.C origin=null
receiver: GET_VAR '<this>: <root>.C<T of <root>.C> declared in <root>.C.<get-x>' type=<root>.C<T of <root>.C> origin=null
FUN DEFAULT_PROPERTY_ACCESSOR name:<set-x> visibility:public modality:FINAL <> ($this:<root>.C<T of <root>.C>, <set-?>:T of <root>.C) returnType:kotlin.Unit
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [var]
$this: VALUE_PARAMETER name:<this> type:<root>.C<T of <root>.C>
VALUE_PARAMETER name:<set-?> index:0 type:T of <root>.C
BLOCK_BODY
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.C visibility:private' type=kotlin.Unit origin=null
receiver: GET_VAR '<this>: <root>.C<T of <root>.C> declared in <root>.C.<set-x>' type=<root>.C<T of <root>.C> origin=null
value: GET_VAR '<set-?>: T of <root>.C declared in <root>.C.<set-x>' type=T of <root>.C 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 [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 name:y visibility:public modality:FINAL [var]
FUN name:<get-y> visibility:public modality:FINAL <T> ($receiver:<root>.C<T of <root>.<get-y>>) returnType:T of <root>.<get-y>
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
$receiver: VALUE_PARAMETER name:<this> type:<root>.C<T of <root>.<get-y>>
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-y> <T> (): T of <root>.<get-y> declared in <root>'
CALL 'public final fun <get-x> (): T of <root>.C declared in <root>.C' type=T of <root>.<get-y> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.C<T of <root>.<get-y>> declared in <root>.<get-y>' type=<root>.C<T of <root>.<get-y>> origin=null
FUN name:<set-y> visibility:public modality:FINAL <T> ($receiver:<root>.C<T of <root>.<set-y>>, v:T of <root>.<set-y>) returnType:kotlin.Unit
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] reified:false
$receiver: VALUE_PARAMETER name:<this> type:<root>.C<T of <root>.<set-y>>
VALUE_PARAMETER name:v index:0 type:T of <root>.<set-y>
BLOCK_BODY
CALL 'public final fun <set-x> (<set-?>: T of <root>.C): kotlin.Unit declared in <root>.C' type=kotlin.Unit origin=EQ
$this: GET_VAR '<this>: <root>.C<T of <root>.<set-y>> declared in <root>.<set-y>' type=<root>.C<T of <root>.<set-y>> origin=null
<set-?>: GET_VAR 'v: T of <root>.<set-y> declared in <root>.<set-y>' type=T of <root>.<get-y> origin=null
FUN name:use visibility:public modality:FINAL <> (p:kotlin.reflect.KMutableProperty<kotlin.String>) returnType:kotlin.Unit
VALUE_PARAMETER name:p index:0 type:kotlin.reflect.KMutableProperty<kotlin.String>
BLOCK_BODY
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun use (p: kotlin.reflect.KMutableProperty<kotlin.String>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
p: PROPERTY_REFERENCE 'public final y: T of <root>.<get-y> [var]' field=null getter='public final fun <get-y> <T> (): T of <root>.<get-y> declared in <root>' setter='public final fun <set-y> <T> (v: T of <root>.<set-y>): kotlin.Unit declared in <root>' type=kotlin.reflect.KMutableProperty0<kotlin.String> origin=null
<1>: kotlin.String
$receiver: CONSTRUCTOR_CALL 'public constructor <init> (x: T of <root>.C) [primary] declared in <root>.C' type=<root>.C<kotlin.String> origin=null
<class: T>: kotlin.String
x: CONST String type=kotlin.String value="abc"
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
TYPE_OP type=<root>.C<kotlin.String> origin=CAST typeOperand=<root>.C<kotlin.String>
GET_VAR 'a: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
CALL 'public final fun use (p: kotlin.reflect.KMutableProperty<kotlin.String>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
p: PROPERTY_REFERENCE 'public final y: T of <root>.<get-y> [var]' field=null getter='public final fun <get-y> <T> (): T of <root>.<get-y> declared in <root>' setter='public final fun <set-y> <T> (v: T of <root>.<set-y>): kotlin.Unit declared in <root>' type=kotlin.reflect.KMutableProperty0<kotlin.String> origin=null
<1>: kotlin.String
$receiver: TYPE_OP type=<root>.C<kotlin.String> origin=IMPLICIT_CAST typeOperand=<root>.C<kotlin.String>
GET_VAR 'a: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
@@ -1,34 +0,0 @@
class C<T : Any?> {
constructor(x: T) /* primary */ {
super/*Any*/()
/* <init>() */
}
var x: T
field = x
get
set
}
var <T : Any?> C<T>.y: T
get(): T {
return <this>.<get-x>()
}
set(v: T) {
<this>.<set-x>(<set-?> = v)
}
fun use(p: KMutableProperty<String>) {
}
fun test1() {
use(p = C<String>(x = "abc")::y/*<String>()*/)
}
fun test2(a: Any) {
a as C<String> /*~> Unit */
use(p = a /*as C<String> */::y/*<String>()*/)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
import kotlin.reflect.KMutableProperty
class C<T>(var x: T)