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,23 @@
annotation class Foo(
val a: Array<String> = ["/"],
val b: Array<String> = [],
val c: Array<String> = ["1", "2"]
)
annotation class Bar(
val a: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[' ']<!>,
val b: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>["", <!EMPTY_CHARACTER_LITERAL!>''<!>]<!>,
val c: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[1]<!>
)
annotation class Base(
val a0: IntArray = [],
val a1: IntArray = [1],
val b1: FloatArray = [1f],
val b0: FloatArray = []
)
annotation class Err(
val a: IntArray = <!ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1L<!>]<!>,
val b: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[1]<!>
)