[FIR] add tests on external annotations

Tests are excluded in COMPILED_JAVA mode because in this
mode external annotations are not present at all

^KT-62310
This commit is contained in:
Dmitrii Gridin
2023-10-05 11:46:50 +02:00
committed by Space Team
parent e452113a7a
commit 2cac922cd0
45 changed files with 1158 additions and 17 deletions
@@ -0,0 +1,47 @@
// FIR_IDENTICAL
// FILE: ClassWithExternalAnnotatedMembers.java
import org.jetbrains.annotations.NotNull;
public class ClassWithExternalAnnotatedMembers {
public String externalNotNullMethod() {
return "";
}
@NotNull
public String explicitNotNullMethod() {
return "";
}
public static String staticExternalNotNullMethod() {
return "";
}
@NotNull
public static String staticExplicitNotNullMethod() {
return "";
}
}
// FILE: usage.kt
fun test() {
val x = ClassWithExternalAnnotatedMembers()
x.externalNotNullMethod()<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
x.explicitNotNullMethod()<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
ClassWithExternalAnnotatedMembers.staticExternalNotNullMethod()<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
ClassWithExternalAnnotatedMembers.staticExplicitNotNullMethod()<!UNNECESSARY_SAFE_CALL!>?.<!>foo()
}
fun String.foo() {
}
// FILE: annotations.xml
<root>
<item name='ClassWithExternalAnnotatedMembers java.lang.String externalNotNullMethod()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
<item name='ClassWithExternalAnnotatedMembers java.lang.String staticExternalNotNullMethod()'>
<annotation name='org.jetbrains.annotations.NotNull'/>
</item>
</root>