FIR: don't check annotations on returnTypeRefs that are not of real kind

This fixes an exception in FirAnnotationChecker where we tried to report
repeated annotations on implicit type refs that have no source.
This commit is contained in:
Kirill Rakhman
2023-01-12 11:49:56 +01:00
committed by Space Team
parent c0961e91b8
commit 5a08d8da8d
6 changed files with 90 additions and 1 deletions
@@ -0,0 +1,33 @@
FILE: test.kt
public final fun <T> foo(bar: R|() -> T|): R|kotlin/Unit| {
}
@R|kotlin/annotation/Target|(allowedTargets = vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.TYPE|)) public final annotation class Ann : R|kotlin/Annotation| {
public constructor(): R|Ann| {
super<R|kotlin/Any|>()
}
}
public final fun baz(): R|@R|Ann|() @R|Ann|() kotlin/String| {
^baz String(12)
}
public final fun qux(): R|@R|SomeAnn|(value = Int(1)) @R|SomeAnn|(value = Int(2)) kotlin/String!| {
^qux Q|Some|.R|/Some.foo|().R|SubstitutionOverride<kotlin/collections/MutableList.get: R|@R|SomeAnn|(value = Int(1)) @R|SomeAnn|(value = Int(2)) kotlin/String!|>|(Int(0))
}
public final fun test(): R|kotlin/Unit| {
R|/foo|<R|@R|SomeAnn|(value = Int(1)) @R|SomeAnn|(value = Int(2)) kotlin/String!|>(foo@fun <anonymous>(): R|@R|SomeAnn|(value = Int(1)) @R|SomeAnn|(value = Int(2)) kotlin/String!| <inline=NoInline> {
^ Q|Some|.R|/Some.foo|().R|SubstitutionOverride<kotlin/collections/MutableList.get: R|@R|SomeAnn|(value = Int(1)) @R|SomeAnn|(value = Int(2)) kotlin/String!|>|(Int(0))
}
)
R|/foo|<R|@R|Ann|() @R|Ann|() kotlin/String|>(foo@fun <anonymous>(): R|@R|Ann|() @R|Ann|() kotlin/String| <inline=NoInline> {
^ R|/baz|()
}
)
R|/foo|<R|@R|SomeAnn|(value = Int(1)) @R|SomeAnn|(value = Int(2)) kotlin/String!|>(foo@fun <anonymous>(): R|@R|SomeAnn|(value = Int(1)) @R|SomeAnn|(value = Int(2)) kotlin/String!| <inline=NoInline> {
^ R|/qux|()
}
)
R|/foo|<R|@R|Ann|() @R|Ann|() kotlin/String|>(fun <anonymous>(): R|@R|Ann|() @R|Ann|() kotlin/String| <inline=NoInline> {
^@foo String()
}
)
}
@@ -0,0 +1,37 @@
// FILE: Some.java
import java.util.List;
public class Some {
public static List<@SomeAnn(1) @SomeAnn(2) String> foo() {
return null;
}
}
// FILE: SomeAnn.java
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
public @interface SomeAnn {
int value();
}
// FILE: test.kt
fun <T> foo(bar: () -> T) {
}
@Target(AnnotationTarget.TYPE)
annotation class Ann
fun baz(): @Ann <!REPEATED_ANNOTATION!>@Ann<!> String = "12"
fun qux() = Some.foo()[0]
fun test() {
foo({ Some.foo()[0] })
foo({ baz() })
foo({ qux() })
foo(fun(): @Ann <!REPEATED_ANNOTATION!>@Ann<!> String {
return ""
})
}