FIR: Do not copy type parameters from class to constructors

Use the same instances from class declaration instead

Otherwise, primary constructor value parameter types when used
in the class body are considered as different from types
based on the class type parameters

See the test genericConstructors.kt, before this commit
"id" call was reported in inapplicable
This commit is contained in:
Denis Zharkov
2019-12-05 13:08:51 +03:00
parent 20d02dd0ee
commit b8984d154b
46 changed files with 212 additions and 153 deletions
@@ -2,8 +2,8 @@ FILE fqName:<root> fileName:/dataClassMembers.kt
CLASS CLASS name:Test modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
CONSTRUCTOR visibility:public <> (x:T of <uninitialized parent>, y:kotlin.String) returnType:<root>.Test<T of <uninitialized parent>> [primary]
VALUE_PARAMETER name:x index:0 type:T of <uninitialized parent>
CONSTRUCTOR visibility:public <> (x:T of <root>.Test, y:kotlin.String) returnType:<root>.Test<T of <root>.Test> [primary]
VALUE_PARAMETER name:x index:0 type:T of <root>.Test
VALUE_PARAMETER name:y index:1 type:kotlin.String
EXPRESSION_BODY
CONST String type=kotlin.String value=""
@@ -13,7 +13,7 @@ FILE fqName:<root> fileName:/dataClassMembers.kt
PROPERTY name:x visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.Test visibility:private [final]
EXPRESSION_BODY
GET_VAR 'x: T of <uninitialized parent> declared in <root>.Test.<init>' type=T of <uninitialized parent> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
GET_VAR 'x: T of <root>.Test declared in <root>.Test.<init>' type=T of <root>.Test origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.Test) returnType:T of <root>.Test
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Test
@@ -37,23 +37,23 @@ FILE fqName:<root> fileName:/dataClassMembers.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): T of <root>.Test declared in <root>.Test'
CALL 'public final fun <get-x> (): T of <root>.Test declared in <root>.Test' type=T of <root>.Test origin=null
$this: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test<T of <uninitialized parent>> origin=null
$this: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test<T of <root>.Test> origin=null
FUN name:component2 visibility:public modality:FINAL <> ($this:<root>.Test) returnType:kotlin.String
$this: VALUE_PARAMETER name:<this> type:<root>.Test
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component2 (): kotlin.String declared in <root>.Test'
CALL 'public final fun <get-y> (): kotlin.String declared in <root>.Test' type=kotlin.String origin=null
$this: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test<T of <uninitialized parent>> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test, x:T of <root>.Test, y:kotlin.String) returnType:<root>.Test<T of <uninitialized parent>>
$this: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test<T of <root>.Test> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test, x:T of <root>.Test, y:kotlin.String) returnType:<root>.Test<T of <root>.Test>
$this: VALUE_PARAMETER name:<this> type:<root>.Test
VALUE_PARAMETER name:x index:0 type:T of <root>.Test
EXPRESSION_BODY
CALL 'public final fun <get-x> (): T of <root>.Test declared in <root>.Test' type=T of <root>.Test origin=null
$this: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test<T of <uninitialized parent>> origin=null
$this: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test<T of <root>.Test> origin=null
VALUE_PARAMETER name:y index:1 type:kotlin.String
EXPRESSION_BODY
CALL 'public final fun <get-y> (): kotlin.String declared in <root>.Test' type=kotlin.String origin=null
$this: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test<T of <uninitialized parent>> origin=null
$this: GET_VAR '<this>: <root>.Test declared in <root>.Test' type=<root>.Test<T of <root>.Test> origin=null
BLOCK_BODY
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden: