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:
Mikhail Zarechenskiy
2017-03-20 16:31:02 +03:00
parent c85f6e7d0e
commit e49b2811ec
12 changed files with 321 additions and 19 deletions
@@ -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() {}