Apply constant folding for collection literals to use in annotations
Currently this is achieved with several hacks: - Postpone computation of argument type info when there is no candidate resolver. We have to do this, because we don't have expected type and therefore we could write wrong information to trace - Presume that for annotation calls there is only one candidate resolver and then resolve arguments with expected type (see `getArgumentTypeInfo`), otherwise because of quadratic complexity of the algorithm resolve would be slow
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Foo(val a: Array<KClass<*>> = [])
|
||||
|
||||
class Gen<T>
|
||||
|
||||
annotation class Bar(val a: Array<KClass<*>> = [Int::class, Array<Int>::class, Gen::class])
|
||||
|
||||
@Foo([])
|
||||
fun test1() {}
|
||||
|
||||
@Foo([Int::class, String::class])
|
||||
fun test2() {}
|
||||
|
||||
@Foo([<!ARRAY_CLASS_LITERAL_REQUIRES_ARGUMENT!>Array::class<!>])
|
||||
fun test3() {}
|
||||
|
||||
@Foo([<!CLASS_LITERAL_LHS_NOT_A_CLASS!>Gen<Int>::class<!>])
|
||||
fun test4() {}
|
||||
|
||||
@Foo(<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>[""]<!>)
|
||||
fun test5() {}
|
||||
|
||||
@Foo(<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>[Int::class, 1]<!>)
|
||||
fun test6() {}
|
||||
|
||||
@Bar
|
||||
fun test7() {}
|
||||
Reference in New Issue
Block a user