K2: Support dependency symbol providers for binary libraries When a symbol X from a binary library A uses another symbol Y from another binary library B, `LLFirDependenciesSymbolProvider` cannot resolve Y for X. This is because the existing LLFirAbstractSessionFactory passes symbol providers for only builtin libraries to `LLFirDependenciesSymbolProvider` even when the session has dependencies. As a result, when `LLFirDependenciesSymbolProvider` searches a symbol, it can find only symbols from the builtin libraries, but it cannot find a symbol from libraries other than builtin libraries. This happens only for the binary libraries. ^KT-65240 Fixed
diff --git a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/compilerFacility/FirIdeNormalAnalysisLibraryBinaryModuleMultiModuleCompilerFacilityTestGenerated.java b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/compilerFacility/FirIdeNormalAnalysisLibraryBinaryModuleMultiModuleCompilerFacilityTestGenerated.java index 153628e..f4b6644 100644 --- a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/compilerFacility/FirIdeNormalAnalysisLibraryBinaryModuleMultiModuleCompilerFacilityTestGenerated.java +++ b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/components/compilerFacility/FirIdeNormalAnalysisLibraryBinaryModuleMultiModuleCompilerFacilityTestGenerated.java
@@ -51,4 +51,10 @@ public void testDependencyBetweenBinaryLibraries() throws Exception { runTest("analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/dependencyBetweenBinaryLibraries.kt"); } + + @Test + @TestMetadata("javaAnnotationWithVararg.kt") + public void testJavaAnnotationWithVararg() throws Exception { + runTest("analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.kt"); + } }
diff --git a/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.ir.txt b/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.ir.txt new file mode 100644 index 0000000..331cd89 --- /dev/null +++ b/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.ir.txt
@@ -0,0 +1,40 @@ +MODULE_FRAGMENT + FILE fqName:<root> fileName:main.kt + CLASS CLASS name:Child modality:FINAL visibility:public superTypes:[p2.Parent] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Child + CONSTRUCTOR visibility:public <> () returnType:<root>.Child [primary] + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () declared in p2.Parent' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:Child modality:FINAL visibility:public superTypes:[p2.Parent]' + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in p2.Parent + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in p2.Parent + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN FAKE_OVERRIDE name:setContentView visibility:public modality:OPEN <> ($this:p2.Parent, p0:kotlin.Int) returnType:kotlin.Unit [fake_override] + overridden: + public open fun setContentView (p0: kotlin.Int): kotlin.Unit declared in p2.Parent + $this: VALUE_PARAMETER name:<this> type:p2.Parent + VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + annotations: + Anno(value = ["UnknownNullness", "MissingNullability"]) + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in p2.Parent + $this: VALUE_PARAMETER name:<this> type:kotlin.Any + FUN name:bar visibility:private modality:FINAL <> ($this:<root>.Child) returnType:kotlin.Unit + $this: VALUE_PARAMETER name:<this> type:<root>.Child + BLOCK_BODY + FUN name:onCreate visibility:protected modality:OPEN <> ($this:<root>.Child) returnType:kotlin.Unit + overridden: + protected/*protected and package*/ open fun onCreate (): kotlin.Unit declared in p2.Parent + $this: VALUE_PARAMETER name:<this> type:<root>.Child + BLOCK_BODY + CALL 'protected/*protected and package*/ open fun onCreate (): kotlin.Unit declared in p2.Parent' superQualifier='CLASS IR_EXTERNAL_JAVA_DECLARATION_STUB CLASS name:Parent modality:OPEN visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit origin=null + $this: GET_VAR '<this>: <root>.Child declared in <root>.Child.onCreate' type=<root>.Child origin=null + CALL 'private final fun bar (): kotlin.Unit declared in <root>.Child' type=kotlin.Unit origin=null + $this: GET_VAR '<this>: <root>.Child declared in <root>.Child.onCreate' type=<root>.Child origin=null
diff --git a/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.kt b/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.kt new file mode 100644 index 0000000..1c3d19f --- /dev/null +++ b/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.kt
@@ -0,0 +1,42 @@ +// MODULE: lib +// FILE: p3/Anno.java +package p3; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.*; + +@Target({TYPE, FIELD, METHOD, PARAMETER, CONSTRUCTOR, LOCAL_VARIABLE}) +@Retention(RetentionPolicy.CLASS) +public @interface Anno { + String[] value(); +} +// MODULE: lib2(lib) +// FILE: p2/Parent.java +package p2; + +import p3.Anno; + +public class Parent { + protected void onCreate() { + setContentView(10); + } + + public void setContentView(@Anno({"UnknownNullness", "MissingNullability"}) int id) { + } +} +// MODULE: main(lib, lib2) +// MODULE_KIND: Source +// FILE: main.kt +import p2.Parent + +class Child: Parent() { + override fun onCreate() { + super.onCreate() + bar() + } + + private fun bar() {} +} \ No newline at end of file
diff --git a/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.txt b/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.txt new file mode 100644 index 0000000..35260a6 --- /dev/null +++ b/analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.txt
@@ -0,0 +1,6 @@ +public final class Child { + // source: 'main.kt' + public method <init>(): void + private final method bar(): void + protected method onCreate(): void +} \ No newline at end of file
diff --git a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/sessions/LLFirAbstractSessionFactory.kt b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/sessions/LLFirAbstractSessionFactory.kt index ba3ef5c..61695a4 100644 --- a/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/sessions/LLFirAbstractSessionFactory.kt +++ b/analysis/low-level-api-fir/src/org/jetbrains/kotlin/analysis/low/level/api/fir/sessions/LLFirAbstractSessionFactory.kt
@@ -85,7 +85,12 @@ builtinTypes, scope ), - LLFirDependenciesSymbolProvider(session) { listOf(builtinSymbolProvider) }, + LLFirDependenciesSymbolProvider(session) { + buildList { + addAll(collectDependencySymbolProviders(moduleData.ktModule)) + add(builtinSymbolProvider) + } + }, ) }