[FIR] make java annotation mapping lazily

to avoid contract violations from getDeprecation

^KT-59342 Fixed
^KT-60520
This commit is contained in:
Dmitrii Gridin
2023-07-13 19:31:52 +02:00
committed by Space Team
parent 4f92e7c48c
commit 32ad4380b3
6 changed files with 140 additions and 33 deletions
@@ -0,0 +1,31 @@
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtProperty
// FILE: KotlinFile.kt
package one.three
import one.four.Manager
class KotlinFile {
<expr>private val branchManager: Manager? = null</expr>
}
// FILE: one/four/Manager.java
package one.four;
import one.two.Service;
import static one.three.KotlinFile.*;
@Service(Service.Level.PROJECT)
public class Manager {
}
// FILE: one/two/Service.java
package one.two;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public @interface Service {
Level[] value() default Level.APP;
enum Level {APP, PROJECT}
}
@@ -0,0 +1,22 @@
KT element: KtProperty
FIR element: FirPropertyImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
private final [ResolvedTo(BODY_RESOLVE)] val branchManager: <ERROR TYPE REF: Symbol not found for Manager?> = Null(null)
private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=KotlinFile] get(): <ERROR TYPE REF: Symbol not found for Manager?>
FIR FILE:
FILE: [ResolvedTo(IMPORTS)] KotlinFile.kt
[ResolvedTo(BODY_RESOLVE)] annotations container
package one.three
public final [ResolvedTo(STATUS)] class KotlinFile : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=KotlinFile] constructor(): R|one/three/KotlinFile| {
LAZY_super<R|kotlin/Any|>
}
private final [ResolvedTo(BODY_RESOLVE)] val branchManager: <ERROR TYPE REF: Symbol not found for Manager?> = Null(null)
private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=KotlinFile] get(): <ERROR TYPE REF: Symbol not found for Manager?>
}
@@ -0,0 +1,22 @@
KT element: KtProperty
FIR element: FirPropertyImpl
FIR source kind: KtRealSourceElementKind
FIR element rendered:
private final [ResolvedTo(BODY_RESOLVE)] val branchManager: R|one/four/Manager?| = Null(null)
private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=KotlinFile] get(): R|one/four/Manager?|
FIR FILE:
FILE: [ResolvedTo(IMPORTS)] KotlinFile.kt
[ResolvedTo(BODY_RESOLVE)] annotations container
package one.three
public final [ResolvedTo(STATUS)] class KotlinFile : R|kotlin/Any| {
public [ResolvedTo(STATUS)] [ContainingClassKey=KotlinFile] constructor(): R|one/three/KotlinFile| {
LAZY_super<R|kotlin/Any|>
}
private final [ResolvedTo(BODY_RESOLVE)] val branchManager: R|one/four/Manager?| = Null(null)
private [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=KotlinFile] get(): R|one/four/Manager?|
}
@@ -507,6 +507,12 @@ public class OutOfContentRootGetOrBuildFirTestGenerated extends AbstractOutOfCon
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/destructuringEntry.kt");
}
@Test
@TestMetadata("kt60387.kt")
public void testKt60387() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/kt60387.kt");
}
@Test
@TestMetadata("ktij23263.kt")
public void testKtij23263() throws Exception {
@@ -507,6 +507,12 @@ public class SourceGetOrBuildFirTestGenerated extends AbstractSourceGetOrBuildFi
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/destructuringEntry.kt");
}
@Test
@TestMetadata("kt60387.kt")
public void testKt60387() throws Exception {
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/kt60387.kt");
}
@Test
@TestMetadata("ktij23263.kt")
public void testKtij23263() throws Exception {