[LL FIR] ContextCollector: add tests for file package and imports

It reproduces redundant resolution

^KT-65344
^KT-65560
This commit is contained in:
Dmitrii Gridin
2024-02-05 17:44:40 +01:00
committed by Space Team
parent 58ad26ee5b
commit 0c3a1dfd67
10 changed files with 172 additions and 0 deletions
@@ -0,0 +1,24 @@
Tower Data Context:
Element 0
Scope: FirDefaultStarImportingScope
Element 1
Scope: FirExplicitStarImportingScope
Element 2
Scope: FirDefaultSimpleImportingScope
Element 3
Scope: FirDefaultSimpleImportingScope
Element 4
Scope: FirPackageMemberScope
Element 5
Scope: FirExplicitSimpleImportingScope
Import name:Anno
Qualified name: foo.Anno
Is all under: false
FILE: [ResolvedTo(IMPORTS)] fileImport.kt
@R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| {
public? [ResolvedTo(RAW_FIR)] constructor(): R|foo/Anno| {
LAZY_super<R|kotlin/Any|>
}
}
@@ -0,0 +1,6 @@
package foo
<expr>import foo.Anno</expr>
@Target(FILE)
annotation class Anno
@@ -0,0 +1,24 @@
Tower Data Context:
Element 0
Scope: FirDefaultStarImportingScope
Element 1
Scope: FirExplicitStarImportingScope
Element 2
Scope: FirDefaultSimpleImportingScope
Element 3
Scope: FirDefaultSimpleImportingScope
Element 4
Scope: FirPackageMemberScope
Element 5
Scope: FirExplicitSimpleImportingScope
Import name:Anno
Qualified name: foo.Anno
Is all under: false
FILE: [ResolvedTo(IMPORTS)] fileImport.kt
@R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| {
public [ResolvedTo(STATUS)] constructor(): R|foo/Anno| {
LAZY_super<R|kotlin/Any|>
}
}
@@ -0,0 +1,24 @@
Tower Data Context:
Element 0
Scope: FirDefaultStarImportingScope
Element 1
Scope: FirExplicitStarImportingScope
Element 2
Scope: FirDefaultSimpleImportingScope
Element 3
Scope: FirDefaultSimpleImportingScope
Element 4
Scope: FirPackageMemberScope
Element 5
Scope: FirExplicitSimpleImportingScope
Import name:Anno
Qualified name: foo.Anno
Is all under: false
FILE: [ResolvedTo(IMPORTS)] fileImportInside.kt
@R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| {
public [ResolvedTo(BODY_RESOLVE)] constructor(): R|foo/Anno| {
super<R|kotlin/Any|>()
}
}
@@ -0,0 +1,6 @@
package foo
import <expr>foo.Anno</expr>
@Target(FILE)
annotation class Anno
@@ -0,0 +1,24 @@
Tower Data Context:
Element 0
Scope: FirDefaultStarImportingScope
Element 1
Scope: FirExplicitStarImportingScope
Element 2
Scope: FirDefaultSimpleImportingScope
Element 3
Scope: FirDefaultSimpleImportingScope
Element 4
Scope: FirPackageMemberScope
Element 5
Scope: FirExplicitSimpleImportingScope
Import name:Anno
Qualified name: foo.Anno
Is all under: false
FILE: [ResolvedTo(IMPORTS)] fileImportInside.kt
@R|kotlin/annotation/Target|[Types](allowedTargets = vararg(<Unresolved name: FILE>#)) public final [ResolvedTo(ANNOTATION_ARGUMENTS)] annotation class Anno : R|kotlin/Annotation| {
public [ResolvedTo(BODY_RESOLVE)] constructor(): R|foo/Anno| {
super<R|kotlin/Any|>()
}
}
@@ -0,0 +1,21 @@
Tower Data Context:
Element 0
Scope: FirDefaultStarImportingScope
Element 1
Scope: FirExplicitStarImportingScope
Element 2
Scope: FirDefaultSimpleImportingScope
Element 3
Scope: FirDefaultSimpleImportingScope
Element 4
Scope: FirPackageMemberScope
Element 5
Scope: FirExplicitSimpleImportingScope
FILE: [ResolvedTo(IMPORTS)] filePackage.kt
@R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| {
public? [ResolvedTo(RAW_FIR)] constructor(): R|foo/Anno| {
LAZY_super<R|kotlin/Any|>
}
}
@@ -0,0 +1,4 @@
<expr>package foo</expr>
@Target(FILE)
annotation class Anno
@@ -0,0 +1,21 @@
Tower Data Context:
Element 0
Scope: FirDefaultStarImportingScope
Element 1
Scope: FirExplicitStarImportingScope
Element 2
Scope: FirDefaultSimpleImportingScope
Element 3
Scope: FirDefaultSimpleImportingScope
Element 4
Scope: FirPackageMemberScope
Element 5
Scope: FirExplicitSimpleImportingScope
FILE: [ResolvedTo(IMPORTS)] filePackage.kt
@R|kotlin/annotation/Target|[Types](FILE#) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| {
public [ResolvedTo(STATUS)] constructor(): R|foo/Anno| {
LAZY_super<R|kotlin/Any|>
}
}
@@ -84,6 +84,24 @@ public class ContextCollectorSourceTestGenerated extends AbstractContextCollecto
runTest("analysis/low-level-api-fir/testData/contextCollector/fileAnnotation.kt");
}
@Test
@TestMetadata("fileImport.kt")
public void testFileImport() throws Exception {
runTest("analysis/low-level-api-fir/testData/contextCollector/fileImport.kt");
}
@Test
@TestMetadata("fileImportInside.kt")
public void testFileImportInside() throws Exception {
runTest("analysis/low-level-api-fir/testData/contextCollector/fileImportInside.kt");
}
@Test
@TestMetadata("filePackage.kt")
public void testFilePackage() throws Exception {
runTest("analysis/low-level-api-fir/testData/contextCollector/filePackage.kt");
}
@Test
@TestMetadata("forLoopVariable.kt")
public void testForLoopVariable() throws Exception {