IR: create stubs for constructor type parameters

Java constructors can have type parameters of their own:
  public class J<X extends Number> {
    public <Y extends CharSequence> J() {}
  }

When such constructors are called from Kotlin, type parameters for
constructor follow type parameters for class:
  fun test() = J<Int, String>() // <X=Int, Y=String>

Descriptor-based representation uses the same type parameters ordering.

Also, use 'withScope' in IrLazyFunction type parameters creation.
This commit is contained in:
Dmitry Petrov
2019-03-25 17:45:31 +03:00
parent 8be7f7f1f7
commit 2c9ed73ba8
6 changed files with 58 additions and 11 deletions
@@ -0,0 +1,8 @@
// FILE: javaConstructorWithTypeParameters.kt
// DUMP_EXTERNAL_CLASS J
fun test() = J<String>()
// FILE: J.java
public class J {
public <T> J() {}
}
@@ -0,0 +1,6 @@
FILE fqName:<root> fileName:/javaConstructorWithTypeParameters.kt
FUN name:test visibility:public modality:FINAL <> () returnType:<root>.J
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun test (): <root>.J declared in <root>'
CALL 'public constructor <init> <T> () declared in <root>.J' type=<root>.J origin=null
<T>: kotlin.String
@@ -0,0 +1,17 @@
CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:J modality:OPEN visibility:public superTypes:[<unbound IrClassSymbolImpl>]
$this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:<this> type:<root>.J
CONSTRUCTOR IR_EXTERNAL_DECLARATION_STUB visibility:public <T> () returnType:<root>.J
TYPE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:T index:0 variance: superTypes:[<unbound IrClassSymbolImpl>?]
FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:<unbound IrClassSymbolImpl>) returnType:<unbound IrClassSymbolImpl>
overridden:
public open fun hashCode (): <unbound IrClassSymbolImpl> declared in kotlin.Any
$this: VALUE_PARAMETER FAKE_OVERRIDE name:<this> type:kotlin.Any
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:<unbound IrClassSymbolImpl>
overridden:
public open fun equals (other: kotlin.Any?): <unbound IrClassSymbolImpl> declared in kotlin.Any
$this: VALUE_PARAMETER FAKE_OVERRIDE name:<this> type:kotlin.Any
VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:other index:0 type:kotlin.Any?
FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:<unbound IrClassSymbolImpl>
overridden:
public open fun toString (): <unbound IrClassSymbolImpl> declared in kotlin.Any
$this: VALUE_PARAMETER FAKE_OVERRIDE name:<this> type:kotlin.Any