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,12 +2,12 @@ FILE fqName:<root> fileName:/genericClassInDifferentModule_m2.kt
CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[<root>.Base<T of <root>.Derived1>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Derived1
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
CONSTRUCTOR visibility:public <> (x:T of <uninitialized parent>) returnType:<root>.Derived1<T of <uninitialized parent>> [primary]
VALUE_PARAMETER name:x index:0 type:T of <uninitialized parent>
CONSTRUCTOR visibility:public <> (x:T of <root>.Derived1) returnType:<root>.Derived1<T of <root>.Derived1> [primary]
VALUE_PARAMETER name:x index:0 type:T of <root>.Derived1
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (x: T of <uninitialized parent>) [primary] declared in <root>.Base'
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (x: T of <root>.Base) [primary] declared in <root>.Base'
<T>: <none>
x: GET_VAR 'x: T of <uninitialized parent> declared in <root>.Derived1.<init>' type=T of <uninitialized parent> origin=null
x: GET_VAR 'x: T of <root>.Derived1 declared in <root>.Derived1.<init>' type=T of <root>.Derived1 origin=null
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Derived1 modality:FINAL visibility:public superTypes:[<root>.Base<T of <root>.Derived1>]'
FUN name:foo visibility:public modality:FINAL <Y> ($this:<root>.Derived1, y:Y of <root>.Derived1.foo) returnType:T of <root>.Derived1
TYPE_PARAMETER name:Y index:0 variance: superTypes:[kotlin.Any?]
@@ -20,7 +20,7 @@ FILE fqName:<root> fileName:/genericClassInDifferentModule_m2.kt
PROPERTY name:bar visibility:public modality:FINAL [var]
FIELD PROPERTY_BACKING_FIELD name:bar type:T of <root>.Derived1 visibility:private
EXPRESSION_BODY
GET_VAR 'x: T of <uninitialized parent> declared in <root>.Derived1.<init>' type=T of <uninitialized parent> origin=null
GET_VAR 'x: T of <root>.Derived1 declared in <root>.Derived1.<init>' type=T of <root>.Derived1 origin=null
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-bar> visibility:public modality:FINAL <> ($this:<root>.Derived1) returnType:T of <root>.Derived1
correspondingProperty: PROPERTY name:bar visibility:public modality:FINAL [var]
$this: VALUE_PARAMETER name:<this> type:<root>.Derived1
@@ -42,7 +42,7 @@ FILE fqName:<root> fileName:/genericClassInDifferentModule_m2.kt
$this: VALUE_PARAMETER name:<this> type:<root>.Derived1
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-exn> (): T of <root>.Derived1 declared in <root>.Derived1'
GET_VAR 'x: T of <uninitialized parent> declared in <root>.Derived1.<init>' type=T of <uninitialized parent> origin=null
GET_VAR 'x: T of <root>.Derived1 declared in <root>.Derived1.<init>' type=T of <root>.Derived1 origin=null
FUN name:<set-exn> visibility:public modality:FINAL <> ($this:<root>.Derived1, value:T of <root>.Derived1) returnType:kotlin.Unit
correspondingProperty: PROPERTY name:exn visibility:public modality:FINAL [var]
$this: VALUE_PARAMETER name:<this> type:<root>.Derived1