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
@@ -9,15 +9,15 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Outer
TYPE_PARAMETER name:T1 index:0 variance: superTypes:[kotlin.Any?]
CONSTRUCTOR visibility:public <> (j11:<root>.J<T1 of <uninitialized parent>, T1 of <uninitialized parent>>) returnType:<root>.Outer<T1 of <uninitialized parent>> [primary]
VALUE_PARAMETER name:j11 index:0 type:<root>.J<T1 of <uninitialized parent>, T1 of <uninitialized parent>>
CONSTRUCTOR visibility:public <> (j11:<root>.J<T1 of <root>.Outer, T1 of <root>.Outer>) returnType:<root>.Outer<T1 of <root>.Outer> [primary]
VALUE_PARAMETER name:j11 index:0 type:<root>.J<T1 of <root>.Outer, T1 of <root>.Outer>
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Outer modality:FINAL visibility:public superTypes:[kotlin.Any]'
PROPERTY name:j11 visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:j11 type:<root>.J<T1 of <root>.Outer, T1 of <root>.Outer> visibility:private [final]
EXPRESSION_BODY
GET_VAR 'j11: <root>.J<T1 of <uninitialized parent>, T1 of <uninitialized parent>> declared in <root>.Outer.<init>' type=<root>.J<T1 of <uninitialized parent>, T1 of <uninitialized parent>> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
GET_VAR 'j11: <root>.J<T1 of <root>.Outer, T1 of <root>.Outer> declared in <root>.Outer.<init>' type=<root>.J<T1 of <root>.Outer, T1 of <root>.Outer> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-j11> visibility:public modality:FINAL <> ($this:<root>.Outer) returnType:<root>.J<T1 of <root>.Outer, T1 of <root>.Outer>
correspondingProperty: PROPERTY name:j11 visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Outer
@@ -28,15 +28,15 @@ FILE fqName:<root> fileName:/samConversionInGenericConstructorCall_NI.kt
CLASS CLASS name:Inner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Outer.Inner
TYPE_PARAMETER name:T2 index:0 variance: superTypes:[kotlin.Any?]
CONSTRUCTOR visibility:public <> (j12:<root>.J<T1 of <root>.Outer, T2 of <uninitialized parent>>) returnType:<root>.Outer.Inner<T2 of <uninitialized parent>> [primary]
VALUE_PARAMETER name:j12 index:0 type:<root>.J<T1 of <root>.Outer, T2 of <uninitialized parent>>
CONSTRUCTOR visibility:public <> (j12:<root>.J<T1 of <root>.Outer, T2 of <root>.Outer.Inner>) returnType:<root>.Outer.Inner<T2 of <root>.Outer.Inner> [primary]
VALUE_PARAMETER name:j12 index:0 type:<root>.J<T1 of <root>.Outer, T2 of <root>.Outer.Inner>
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Inner modality:FINAL visibility:public [inner] superTypes:[kotlin.Any]'
PROPERTY name:j12 visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:j12 type:<root>.J<T1 of <root>.Outer, T2 of <root>.Outer.Inner> visibility:private [final]
EXPRESSION_BODY
GET_VAR 'j12: <root>.J<T1 of <root>.Outer, T2 of <uninitialized parent>> declared in <root>.Outer.Inner.<init>' type=<root>.J<T1 of <root>.Outer, T2 of <uninitialized parent>> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
GET_VAR 'j12: <root>.J<T1 of <root>.Outer, T2 of <root>.Outer.Inner> declared in <root>.Outer.Inner.<init>' type=<root>.J<T1 of <root>.Outer, T2 of <root>.Outer.Inner> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-j12> visibility:public modality:FINAL <> ($this:<root>.Outer.Inner) returnType:<root>.J<T1 of <root>.Outer, T2 of <root>.Outer.Inner>
correspondingProperty: PROPERTY name:j12 visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Outer.Inner