FIR: add implementation of reified type parameter references

This adds support of T::class.java for reified type parameters
This commit is contained in:
Mikhail Glukhikh
2019-12-16 17:34:12 +03:00
parent cccb95465e
commit 684bdc44bb
22 changed files with 184 additions and 64 deletions
@@ -36,10 +36,10 @@ fun test8() {}
inline val <reified T> T.test9
get() = @AnnArray(arrayOf(
<!OTHER_ERROR!>T<!>::class,
T::class,
Array<T>::class,
Array<Array<Array<T>>>::class
)) object {}
inline val <reified T> T.test10
get() = @AnnArray([<!OTHER_ERROR!>T<!>::class]) object {}
get() = @AnnArray([T::class]) object {}
@@ -6,7 +6,7 @@ annotation class Ann(vararg val k: KClass<*>)
inline val <reified T> T.test
get() = @Ann(
<!OTHER_ERROR!>T<!>::class,
T::class,
Array<T>::class,
Array<Array<Array<T>>>::class
) object {}
@@ -14,7 +14,7 @@ fun <T : Any> foo() {
}
inline fun <reified T : Any> bar() {
val t3 = <!OTHER_ERROR!>T<!>?::class
val t3 = T?::class
}
val m = Map<String>::class
@@ -17,11 +17,11 @@ public class A {
// types checked by txt file
// FILE: 1.kt
inline fun <reified X> test1() = <!OTHER_ERROR!>X<!>::class.<!INAPPLICABLE_CANDIDATE!>java<!>
inline fun <reified X : Any> test2() = <!OTHER_ERROR!>X<!>::class.<!INAPPLICABLE_CANDIDATE!>java<!>
inline fun <reified X : Any?> test3() = <!OTHER_ERROR!>X<!>::class.<!INAPPLICABLE_CANDIDATE!>java<!>
inline fun <reified X : Number> test4() = <!OTHER_ERROR!>X<!>::class.<!INAPPLICABLE_CANDIDATE!>java<!>
inline fun <reified X : Number?> test5() = <!OTHER_ERROR!>X<!>::class.<!INAPPLICABLE_CANDIDATE!>java<!>
inline fun <reified X> test1() = X::class.java
inline fun <reified X : Any> test2() = X::class.java
inline fun <reified X : Any?> test3() = X::class.java
inline fun <reified X : Number> test4() = X::class.java
inline fun <reified X : Number?> test5() = X::class.java
fun test6() = A.getA()::class.java
fun test7() = A.getKClass().java
@@ -3,7 +3,7 @@
inline fun<reified T> foo(block: () -> T): String = block().toString()
inline fun <reified T: Any> javaClass(): Class<T> = <!OTHER_ERROR!>T<!>::class.<!INAPPLICABLE_CANDIDATE!>java<!>
inline fun <reified T: Any> javaClass(): Class<T> = T::class.java
fun box() {
val a = arrayOf(null!!)
@@ -55,7 +55,7 @@ FILE fqName:<root> fileName:/classLiteralInAnnotation.kt
BLOCK type=<root>.test2.<no name provided> origin=OBJECT_LITERAL
CLASS OBJECT name:<no name provided> modality:FINAL visibility:local superTypes:[kotlin.Any]
annotations:
A(klass = GET_CLASS type=kotlin.reflect.KClass<IrErrorType>)
A(klass = CLASS_REFERENCE 'TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]' type=kotlin.reflect.KClass<T of <root>.test2>)
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.test2.<no name provided>
CONSTRUCTOR visibility:private <> () returnType:kotlin.Any [primary]
BLOCK_BODY
@@ -70,7 +70,7 @@ FILE fqName:<root> fileName:/classLiteralInAnnotation.kt
BLOCK type=<root>.<get-test3>.<no name provided> origin=OBJECT_LITERAL
CLASS OBJECT name:<no name provided> modality:FINAL visibility:local superTypes:[kotlin.Any]
annotations:
A(klass = GET_CLASS type=kotlin.reflect.KClass<IrErrorType>)
A(klass = CLASS_REFERENCE 'TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]' type=kotlin.reflect.KClass<T of <uninitialized parent>>)
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.<get-test3>.<no name provided>
CONSTRUCTOR visibility:private <> () returnType:kotlin.Any [primary]
BLOCK_BODY
@@ -84,7 +84,7 @@ FILE fqName:<root> fileName:/classLiteralInAnnotation.kt
BLOCK type=<root>.<set-test3>.<no name provided> origin=OBJECT_LITERAL
CLASS OBJECT name:<no name provided> modality:FINAL visibility:local superTypes:[kotlin.Any]
annotations:
A(klass = GET_CLASS type=kotlin.reflect.KClass<IrErrorType>)
A(klass = CLASS_REFERENCE 'TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?]' type=kotlin.reflect.KClass<T of <uninitialized parent>>)
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.<set-test3>.<no name provided>
CONSTRUCTOR visibility:private <> () returnType:kotlin.Any [primary]
BLOCK_BODY
@@ -1,53 +1,47 @@
FILE fqName:<root> fileName:/typeParameterClassLiteral.kt
FUN name:classRefFun visibility:public modality:FINAL <T> () returnType:kotlin.reflect.KClass<IrErrorType> [inline]
FUN name:classRefFun visibility:public modality:FINAL <T> () returnType:kotlin.reflect.KClass<T of <root>.classRefFun> [inline]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun classRefFun <T> (): kotlin.reflect.KClass<IrErrorType> [inline] declared in <root>'
GET_CLASS type=kotlin.reflect.KClass<IrErrorType>
ERROR_CALL 'Unresolved reference: R|?|' type=IrErrorType
FUN name:classRefExtFun visibility:public modality:FINAL <T> ($receiver:kotlin.Any) returnType:kotlin.reflect.KClass<IrErrorType> [inline]
RETURN type=kotlin.Nothing from='public final fun classRefFun <T> (): kotlin.reflect.KClass<T of <root>.classRefFun> [inline] declared in <root>'
CLASS_REFERENCE 'TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<T of <root>.classRefFun>
FUN name:classRefExtFun visibility:public modality:FINAL <T> ($receiver:kotlin.Any) returnType:kotlin.reflect.KClass<T of <root>.classRefExtFun> [inline]
TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun classRefExtFun <T> (): kotlin.reflect.KClass<IrErrorType> [inline] declared in <root>'
GET_CLASS type=kotlin.reflect.KClass<IrErrorType>
ERROR_CALL 'Unresolved reference: R|?|' type=IrErrorType
RETURN type=kotlin.Nothing from='public final fun classRefExtFun <T> (): kotlin.reflect.KClass<T of <root>.classRefExtFun> [inline] declared in <root>'
CLASS_REFERENCE 'TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<T of <root>.classRefExtFun>
PROPERTY name:classRefExtVal visibility:public modality:FINAL [val]
FUN name:<get-classRefExtVal> visibility:public modality:FINAL <> () returnType:kotlin.reflect.KClass<IrErrorType>
FUN name:<get-classRefExtVal> visibility:public modality:FINAL <> () returnType:kotlin.reflect.KClass<T of <uninitialized parent>>
correspondingProperty: PROPERTY name:classRefExtVal visibility:public modality:FINAL [val]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-classRefExtVal> (): kotlin.reflect.KClass<IrErrorType> declared in <root>'
GET_CLASS type=kotlin.reflect.KClass<IrErrorType>
ERROR_CALL 'Unresolved reference: R|?|' type=IrErrorType
RETURN type=kotlin.Nothing from='public final fun <get-classRefExtVal> (): kotlin.reflect.KClass<T of <uninitialized parent>> declared in <root>'
CLASS_REFERENCE 'TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<T of <uninitialized parent>>
CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Host
CONSTRUCTOR visibility:public <> () returnType:<root>.Host [primary]
BLOCK_BODY
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]'
FUN name:classRefGenericMemberFun visibility:public modality:FINAL <TF> ($this:<root>.Host) returnType:kotlin.reflect.KClass<IrErrorType> [inline]
FUN name:classRefGenericMemberFun visibility:public modality:FINAL <TF> ($this:<root>.Host) returnType:kotlin.reflect.KClass<TF of <root>.Host.classRefGenericMemberFun> [inline]
TYPE_PARAMETER name:TF index:0 variance: superTypes:[kotlin.Any]
$this: VALUE_PARAMETER name:<this> type:<root>.Host
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun classRefGenericMemberFun <TF> (): kotlin.reflect.KClass<IrErrorType> [inline] declared in <root>.Host'
GET_CLASS type=kotlin.reflect.KClass<IrErrorType>
ERROR_CALL 'Unresolved reference: R|?|' type=IrErrorType
FUN name:classRefGenericMemberExtFun visibility:public modality:FINAL <TF> ($this:<root>.Host, $receiver:kotlin.Any) returnType:kotlin.reflect.KClass<IrErrorType> [inline]
RETURN type=kotlin.Nothing from='public final fun classRefGenericMemberFun <TF> (): kotlin.reflect.KClass<TF of <root>.Host.classRefGenericMemberFun> [inline] declared in <root>.Host'
CLASS_REFERENCE 'TYPE_PARAMETER name:TF index:0 variance: superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<TF of <root>.Host.classRefGenericMemberFun>
FUN name:classRefGenericMemberExtFun visibility:public modality:FINAL <TF> ($this:<root>.Host, $receiver:kotlin.Any) returnType:kotlin.reflect.KClass<TF of <root>.Host.classRefGenericMemberExtFun> [inline]
TYPE_PARAMETER name:TF index:0 variance: superTypes:[kotlin.Any]
$this: VALUE_PARAMETER name:<this> type:<root>.Host
$receiver: VALUE_PARAMETER name:<this> type:kotlin.Any
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun classRefGenericMemberExtFun <TF> (): kotlin.reflect.KClass<IrErrorType> [inline] declared in <root>.Host'
GET_CLASS type=kotlin.reflect.KClass<IrErrorType>
ERROR_CALL 'Unresolved reference: R|?|' type=IrErrorType
RETURN type=kotlin.Nothing from='public final fun classRefGenericMemberExtFun <TF> (): kotlin.reflect.KClass<TF of <root>.Host.classRefGenericMemberExtFun> [inline] declared in <root>.Host'
CLASS_REFERENCE 'TYPE_PARAMETER name:TF index:0 variance: superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<TF of <root>.Host.classRefGenericMemberExtFun>
PROPERTY name:classRefGenericMemberExtVal visibility:public modality:FINAL [val]
FUN name:<get-classRefGenericMemberExtVal> visibility:public modality:FINAL <> ($this:<root>.Host) returnType:kotlin.reflect.KClass<IrErrorType>
FUN name:<get-classRefGenericMemberExtVal> visibility:public modality:FINAL <> ($this:<root>.Host) returnType:kotlin.reflect.KClass<TV of <uninitialized parent>>
correspondingProperty: PROPERTY name:classRefGenericMemberExtVal visibility:public modality:FINAL [val]
$this: VALUE_PARAMETER name:<this> type:<root>.Host
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-classRefGenericMemberExtVal> (): kotlin.reflect.KClass<IrErrorType> declared in <root>.Host'
GET_CLASS type=kotlin.reflect.KClass<IrErrorType>
ERROR_CALL 'Unresolved reference: R|?|' type=IrErrorType
RETURN type=kotlin.Nothing from='public final fun <get-classRefGenericMemberExtVal> (): kotlin.reflect.KClass<TV of <uninitialized parent>> declared in <root>.Host'
CLASS_REFERENCE 'TYPE_PARAMETER name:TV index:0 variance: superTypes:[kotlin.Any]' type=kotlin.reflect.KClass<TV of <uninitialized parent>>
FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator]
overridden:
public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any