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
@@ -222,15 +222,15 @@ FILE fqName:<root> fileName:/dataClassWithArrayMembers.kt
CLASS CLASS name:Test2 modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test2
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
CONSTRUCTOR visibility:public <> (genericArray:kotlin.Array<T of <uninitialized parent>>) returnType:<root>.Test2<T of <uninitialized parent>> [primary]
VALUE_PARAMETER name:genericArray index:0 type:kotlin.Array<T of <uninitialized parent>>
CONSTRUCTOR visibility:public <> (genericArray:kotlin.Array<T of <root>.Test2>) returnType:<root>.Test2<T of <root>.Test2> [primary]
VALUE_PARAMETER name:genericArray index:0 type:kotlin.Array<T of <root>.Test2>
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
PROPERTY name:genericArray visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:genericArray type:kotlin.Array<T of <root>.Test2> visibility:private [final]
EXPRESSION_BODY
GET_VAR 'genericArray: kotlin.Array<T of <uninitialized parent>> declared in <root>.Test2.<init>' type=kotlin.Array<T of <uninitialized parent>> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
GET_VAR 'genericArray: kotlin.Array<T of <root>.Test2> declared in <root>.Test2.<init>' type=kotlin.Array<T of <root>.Test2> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-genericArray> visibility:public modality:FINAL <> ($this:<root>.Test2) returnType:kotlin.Array<T of <root>.Test2>
correspondingProperty: PROPERTY name:genericArray visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Test2
@@ -243,13 +243,13 @@ FILE fqName:<root> fileName:/dataClassWithArrayMembers.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.Array<T of <root>.Test2> declared in <root>.Test2'
CALL 'public final fun <get-genericArray> (): kotlin.Array<T of <root>.Test2> declared in <root>.Test2' type=kotlin.Array<T of <root>.Test2> origin=null
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2<T of <uninitialized parent>> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test2, genericArray:kotlin.Array<T of <root>.Test2>) returnType:<root>.Test2<T of <uninitialized parent>>
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2<T of <root>.Test2> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test2, genericArray:kotlin.Array<T of <root>.Test2>) returnType:<root>.Test2<T of <root>.Test2>
$this: VALUE_PARAMETER name:<this> type:<root>.Test2
VALUE_PARAMETER name:genericArray index:0 type:kotlin.Array<T of <root>.Test2>
EXPRESSION_BODY
CALL 'public final fun <get-genericArray> (): kotlin.Array<T of <root>.Test2> declared in <root>.Test2' type=kotlin.Array<T of <root>.Test2> origin=null
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2<T of <uninitialized parent>> origin=null
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2<T of <root>.Test2> 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:
@@ -2,15 +2,15 @@ FILE fqName:<root> fileName:/dataClassesGeneric.kt
CLASS CLASS name:Test1 modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test1
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
CONSTRUCTOR visibility:public <> (x:T of <uninitialized parent>) returnType:<root>.Test1<T of <uninitialized parent>> [primary]
VALUE_PARAMETER name:x index:0 type:T of <uninitialized parent>
CONSTRUCTOR visibility:public <> (x:T of <root>.Test1) returnType:<root>.Test1<T of <root>.Test1> [primary]
VALUE_PARAMETER name:x index:0 type:T of <root>.Test1
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test1 modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
PROPERTY name:x visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.Test1 visibility:private [final]
EXPRESSION_BODY
GET_VAR 'x: T of <uninitialized parent> declared in <root>.Test1.<init>' type=T of <uninitialized parent> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
GET_VAR 'x: T of <root>.Test1 declared in <root>.Test1.<init>' type=T of <root>.Test1 origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.Test1) returnType:T of <root>.Test1
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Test1
@@ -23,13 +23,13 @@ FILE fqName:<root> fileName:/dataClassesGeneric.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): T of <root>.Test1 declared in <root>.Test1'
CALL 'public final fun <get-x> (): T of <root>.Test1 declared in <root>.Test1' type=T of <root>.Test1 origin=null
$this: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1' type=<root>.Test1<T of <uninitialized parent>> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test1, x:T of <root>.Test1) returnType:<root>.Test1<T of <uninitialized parent>>
$this: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1' type=<root>.Test1<T of <root>.Test1> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test1, x:T of <root>.Test1) returnType:<root>.Test1<T of <root>.Test1>
$this: VALUE_PARAMETER name:<this> type:<root>.Test1
VALUE_PARAMETER name:x index:0 type:T of <root>.Test1
EXPRESSION_BODY
CALL 'public final fun <get-x> (): T of <root>.Test1 declared in <root>.Test1' type=T of <root>.Test1 origin=null
$this: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1' type=<root>.Test1<T of <uninitialized parent>> origin=null
$this: GET_VAR '<this>: <root>.Test1 declared in <root>.Test1' type=<root>.Test1<T of <root>.Test1> 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:
@@ -47,15 +47,15 @@ FILE fqName:<root> fileName:/dataClassesGeneric.kt
CLASS CLASS name:Test2 modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test2
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Number]
CONSTRUCTOR visibility:public <> (x:T of <uninitialized parent>) returnType:<root>.Test2<T of <uninitialized parent>> [primary]
VALUE_PARAMETER name:x index:0 type:T of <uninitialized parent>
CONSTRUCTOR visibility:public <> (x:T of <root>.Test2) returnType:<root>.Test2<T of <root>.Test2> [primary]
VALUE_PARAMETER name:x index:0 type:T of <root>.Test2
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test2 modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
PROPERTY name:x visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:x type:T of <root>.Test2 visibility:private [final]
EXPRESSION_BODY
GET_VAR 'x: T of <uninitialized parent> declared in <root>.Test2.<init>' type=T of <uninitialized parent> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
GET_VAR 'x: T of <root>.Test2 declared in <root>.Test2.<init>' type=T of <root>.Test2 origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.Test2) returnType:T of <root>.Test2
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Test2
@@ -68,13 +68,13 @@ FILE fqName:<root> fileName:/dataClassesGeneric.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): T of <root>.Test2 declared in <root>.Test2'
CALL 'public final fun <get-x> (): T of <root>.Test2 declared in <root>.Test2' type=T of <root>.Test2 origin=null
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2<T of <uninitialized parent>> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test2, x:T of <root>.Test2) returnType:<root>.Test2<T of <uninitialized parent>>
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2<T of <root>.Test2> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test2, x:T of <root>.Test2) returnType:<root>.Test2<T of <root>.Test2>
$this: VALUE_PARAMETER name:<this> type:<root>.Test2
VALUE_PARAMETER name:x index:0 type:T of <root>.Test2
EXPRESSION_BODY
CALL 'public final fun <get-x> (): T of <root>.Test2 declared in <root>.Test2' type=T of <root>.Test2 origin=null
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2<T of <uninitialized parent>> origin=null
$this: GET_VAR '<this>: <root>.Test2 declared in <root>.Test2' type=<root>.Test2<T of <root>.Test2> 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:
@@ -92,15 +92,15 @@ FILE fqName:<root> fileName:/dataClassesGeneric.kt
CLASS CLASS name:Test3 modality:FINAL visibility:public [data] superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Test3
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
CONSTRUCTOR visibility:public <> (x:kotlin.collections.List<T of <uninitialized parent>>) returnType:<root>.Test3<T of <uninitialized parent>> [primary]
VALUE_PARAMETER name:x index:0 type:kotlin.collections.List<T of <uninitialized parent>>
CONSTRUCTOR visibility:public <> (x:kotlin.collections.List<T of <root>.Test3>) returnType:<root>.Test3<T of <root>.Test3> [primary]
VALUE_PARAMETER name:x index:0 type:kotlin.collections.List<T of <root>.Test3>
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Test3 modality:FINAL visibility:public [data] superTypes:[kotlin.Any]'
PROPERTY name:x visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.collections.List<T of <root>.Test3> visibility:private [final]
EXPRESSION_BODY
GET_VAR 'x: kotlin.collections.List<T of <uninitialized parent>> declared in <root>.Test3.<init>' type=kotlin.collections.List<T of <uninitialized parent>> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
GET_VAR 'x: kotlin.collections.List<T of <root>.Test3> declared in <root>.Test3.<init>' type=kotlin.collections.List<T of <root>.Test3> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-x> visibility:public modality:FINAL <> ($this:<root>.Test3) returnType:kotlin.collections.List<T of <root>.Test3>
correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Test3
@@ -113,13 +113,13 @@ FILE fqName:<root> fileName:/dataClassesGeneric.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun component1 (): kotlin.collections.List<T of <root>.Test3> declared in <root>.Test3'
CALL 'public final fun <get-x> (): kotlin.collections.List<T of <root>.Test3> declared in <root>.Test3' type=kotlin.collections.List<T of <root>.Test3> origin=null
$this: GET_VAR '<this>: <root>.Test3 declared in <root>.Test3' type=<root>.Test3<T of <uninitialized parent>> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test3, x:kotlin.collections.List<T of <root>.Test3>) returnType:<root>.Test3<T of <uninitialized parent>>
$this: GET_VAR '<this>: <root>.Test3 declared in <root>.Test3' type=<root>.Test3<T of <root>.Test3> origin=null
FUN name:copy visibility:public modality:FINAL <> ($this:<root>.Test3, x:kotlin.collections.List<T of <root>.Test3>) returnType:<root>.Test3<T of <root>.Test3>
$this: VALUE_PARAMETER name:<this> type:<root>.Test3
VALUE_PARAMETER name:x index:0 type:kotlin.collections.List<T of <root>.Test3>
EXPRESSION_BODY
CALL 'public final fun <get-x> (): kotlin.collections.List<T of <root>.Test3> declared in <root>.Test3' type=kotlin.collections.List<T of <root>.Test3> origin=null
$this: GET_VAR '<this>: <root>.Test3 declared in <root>.Test3' type=<root>.Test3<T of <uninitialized parent>> origin=null
$this: GET_VAR '<this>: <root>.Test3 declared in <root>.Test3' type=<root>.Test3<T of <root>.Test3> 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:
@@ -2,15 +2,15 @@ FILE fqName:<root> fileName:/delegatingConstructorCallToTypeAliasConstructor.kt
CLASS CLASS name:Cell modality:OPEN visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Cell
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]
CONSTRUCTOR visibility:public <> (value:T of <uninitialized parent>) returnType:<root>.Cell<T of <uninitialized parent>> [primary]
VALUE_PARAMETER name:value index:0 type:T of <uninitialized parent>
CONSTRUCTOR visibility:public <> (value:T of <root>.Cell) returnType:<root>.Cell<T of <root>.Cell> [primary]
VALUE_PARAMETER name:value index:0 type:T of <root>.Cell
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Cell modality:OPEN visibility:public superTypes:[kotlin.Any]'
PROPERTY name:value visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:value type:T of <root>.Cell visibility:private [final]
EXPRESSION_BODY
GET_VAR 'value: T of <uninitialized parent> declared in <root>.Cell.<init>' type=T of <uninitialized parent> origin=INITIALIZE_PROPERTY_FROM_PARAMETER
GET_VAR 'value: T of <root>.Cell declared in <root>.Cell.<init>' type=T of <root>.Cell origin=INITIALIZE_PROPERTY_FROM_PARAMETER
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-value> visibility:public modality:FINAL <> ($this:<root>.Cell) returnType:T of <root>.Cell
correspondingProperty: PROPERTY name:value visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Cell
@@ -35,7 +35,7 @@ FILE fqName:<root> fileName:/delegatingConstructorCallToTypeAliasConstructor.kt
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C1
CONSTRUCTOR visibility:public <> () returnType:<root>.C1 [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (value: T of <uninitialized parent>) [primary] declared in <root>.Cell'
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (value: T of <root>.Cell) [primary] declared in <root>.Cell'
<T>: <none>
value: CONST String type=kotlin.String value="O"
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C1 modality:FINAL visibility:public superTypes:[<root>.Cell<kotlin.String>]'
@@ -62,7 +62,7 @@ FILE fqName:<root> fileName:/delegatingConstructorCallToTypeAliasConstructor.kt
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.C2
CONSTRUCTOR visibility:public <> () returnType:<root>.C2 [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (value: T of <uninitialized parent>) [primary] declared in <root>.Cell'
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (value: T of <root>.Cell) [primary] declared in <root>.Cell'
<T>: <none>
value: CONST String type=kotlin.String value="K"
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C2 modality:FINAL visibility:public superTypes:[<root>.Cell]'