[FIR] Ignore anonymous functions during annotation argument phase

Anonymous functions (lambdas) are not allowed as annotation arguments.
However, because it is still possible to parse code written this way, it
must be handled without exception. So ignore these expressions when
processing annotation arguments.

#KT-59565 Fixed
This commit is contained in:
Brian Norman
2023-09-20 09:06:16 -05:00
committed by Space Team
parent 223c793258
commit 79303ab2db
8 changed files with 80 additions and 0 deletions
@@ -0,0 +1,18 @@
// ISSUE: KT-59565
@Target(AnnotationTarget.TYPE)
annotation class Ann(val x: Int)
class A<T: @Ann(<!ARGUMENT_TYPE_MISMATCH!>{
fun local() = 1
var result = local()
result += 1
result
}<!>) Any>
fun f(x: @Ann(<!ARGUMENT_TYPE_MISMATCH!>{
fun local() = 1
var result = local()
result += 1
result
}<!>) Int) = x
@@ -0,0 +1,18 @@
// ISSUE: KT-59565
@Target(AnnotationTarget.TYPE)
annotation class Ann(val x: Int)
class A<T: @Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST, TYPE_MISMATCH!>{
fun local() = 1
var result = local()
result += 1
result
}<!>) Any>
fun f(x: @Ann(<!ANNOTATION_ARGUMENT_MUST_BE_CONST, TYPE_MISMATCH!>{
fun local() = 1
var result = local()
result += 1
result
}<!>) Int) = x