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
This commit is contained in:
+6
@@ -51,4 +51,10 @@ public class FirIdeNormalAnalysisLibraryBinaryModuleMultiModuleCompilerFacilityT
|
|||||||
public void testDependencyBetweenBinaryLibraries() {
|
public void testDependencyBetweenBinaryLibraries() {
|
||||||
runTest("analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/dependencyBetweenBinaryLibraries.kt");
|
runTest("analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/dependencyBetweenBinaryLibraries.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("javaAnnotationWithVararg.kt")
|
||||||
|
public void testJavaAnnotationWithVararg() {
|
||||||
|
runTest("analysis/analysis-api/testData/components/compilerFacility/compilationMultiBinaryModule/javaAnnotationWithVararg.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+40
@@ -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
|
||||||
+42
@@ -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() {}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
public final class Child {
|
||||||
|
// source: 'main.kt'
|
||||||
|
public method <init>(): void
|
||||||
|
private final method bar(): void
|
||||||
|
protected method onCreate(): void
|
||||||
|
}
|
||||||
+6
-1
@@ -85,7 +85,12 @@ internal abstract class LLFirAbstractSessionFactory(protected val project: Proje
|
|||||||
builtinTypes,
|
builtinTypes,
|
||||||
scope
|
scope
|
||||||
),
|
),
|
||||||
LLFirDependenciesSymbolProvider(session) { listOf(builtinSymbolProvider) },
|
LLFirDependenciesSymbolProvider(session) {
|
||||||
|
buildList {
|
||||||
|
addAll(collectDependencySymbolProviders(moduleData.ktModule))
|
||||||
|
add(builtinSymbolProvider)
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user