FIR2IR: Support not found dependencies classes
^KT-49119 Relates
This commit is contained in:
committed by
TeamCityServer
parent
9230195317
commit
f5da8957b4
@@ -135,7 +135,9 @@ fun FirClassifierSymbol<*>.toSymbol(
|
|||||||
is FirTypeAliasSymbol -> {
|
is FirTypeAliasSymbol -> {
|
||||||
handleAnnotations?.invoke(fir.expandedTypeRef.annotations)
|
handleAnnotations?.invoke(fir.expandedTypeRef.annotations)
|
||||||
val coneClassLikeType = fir.expandedTypeRef.coneType as ConeClassLikeType
|
val coneClassLikeType = fir.expandedTypeRef.coneType as ConeClassLikeType
|
||||||
coneClassLikeType.lookupTag.toSymbol(session)!!.toSymbol(session, classifierStorage, typeContext, handleAnnotations)
|
coneClassLikeType.lookupTag.toSymbol(session)
|
||||||
|
?.toSymbol(session, classifierStorage, typeContext, handleAnnotations)
|
||||||
|
?: classifierStorage.getIrClassSymbolForNotFoundClass(coneClassLikeType.lookupTag)
|
||||||
}
|
}
|
||||||
is FirClassSymbol -> {
|
is FirClassSymbol -> {
|
||||||
classifierStorage.getIrClassSymbol(this)
|
classifierStorage.getIrClassSymbol(this)
|
||||||
|
|||||||
+25
-4
@@ -5,10 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.fir.backend
|
package org.jetbrains.kotlin.fir.backend
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
|
||||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
|
||||||
import org.jetbrains.kotlin.descriptors.Visibility
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.*
|
import org.jetbrains.kotlin.fir.declarations.utils.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
|
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
|
||||||
@@ -24,6 +21,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
|||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
|
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||||
import org.jetbrains.kotlin.ir.builders.declarations.UNDEFINED_PARAMETER_INDEX
|
import org.jetbrains.kotlin.ir.builders.declarations.UNDEFINED_PARAMETER_INDEX
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl
|
||||||
@@ -468,6 +466,29 @@ class Fir2IrClassifierStorage(
|
|||||||
return symbol
|
return symbol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getIrClassSymbolForNotFoundClass(classLikeLookupTag: ConeClassLikeLookupTag): IrClassSymbol {
|
||||||
|
val classId = classLikeLookupTag.classId
|
||||||
|
val signature = IdSignature.CommonSignature(
|
||||||
|
classId.packageFqName.asString(), classId.relativeClassName.asString(), 0, 0,
|
||||||
|
)
|
||||||
|
|
||||||
|
val parentId = classId.outerClassId
|
||||||
|
val parentClass = parentId?.let { getIrClassSymbolForNotFoundClass(ConeClassLikeLookupTagImpl(it)) }
|
||||||
|
val irParent = parentClass?.owner ?: declarationStorage.getIrExternalPackageFragment(classId.packageFqName)
|
||||||
|
|
||||||
|
val symbol = Fir2IrClassSymbol(signature)
|
||||||
|
symbolTable.declareClass(signature, { symbol }) {
|
||||||
|
irFactory.createClass(
|
||||||
|
UNDEFINED_OFFSET, UNDEFINED_OFFSET, IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB, symbol, classId.shortClassName,
|
||||||
|
ClassKind.CLASS, DescriptorVisibilities.DEFAULT_VISIBILITY, Modality.FINAL,
|
||||||
|
).apply {
|
||||||
|
parent = irParent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return symbol
|
||||||
|
}
|
||||||
|
|
||||||
fun getIrTypeParameterSymbol(
|
fun getIrTypeParameterSymbol(
|
||||||
firTypeParameterSymbol: FirTypeParameterSymbol,
|
firTypeParameterSymbol: FirTypeParameterSymbol,
|
||||||
typeContext: ConversionTypeContext
|
typeContext: ConversionTypeContext
|
||||||
|
|||||||
+1
-1
@@ -210,7 +210,7 @@ class Fir2IrDeclarationStorage(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getIrExternalPackageFragment(fqName: FqName): IrExternalPackageFragment {
|
fun getIrExternalPackageFragment(fqName: FqName): IrExternalPackageFragment {
|
||||||
return fragmentCache.getOrPut(fqName) {
|
return fragmentCache.getOrPut(fqName) {
|
||||||
return symbolTable.declareExternalPackageFragment(FirPackageFragmentDescriptor(fqName, moduleDescriptor))
|
return symbolTable.declareExternalPackageFragment(FirPackageFragmentDescriptor(fqName, moduleDescriptor))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.languageVersionSettings
|
|||||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
|
import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||||
import org.jetbrains.kotlin.fir.typeContext
|
import org.jetbrains.kotlin.fir.typeContext
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.*
|
import org.jetbrains.kotlin.fir.types.impl.*
|
||||||
@@ -112,6 +113,7 @@ class Fir2IrTypeConverter(
|
|||||||
?: lookupTag.toSymbol(session)?.toSymbol(session, classifierStorage, typeContext) {
|
?: lookupTag.toSymbol(session)?.toSymbol(session, classifierStorage, typeContext) {
|
||||||
typeAnnotations += with(annotationGenerator) { it.toIrAnnotations() }
|
typeAnnotations += with(annotationGenerator) { it.toIrAnnotations() }
|
||||||
}
|
}
|
||||||
|
?: (lookupTag as? ConeClassLikeLookupTag)?.let(classifierStorage::getIrClassSymbolForNotFoundClass)
|
||||||
?: return createErrorType()
|
?: return createErrorType()
|
||||||
|
|
||||||
when {
|
when {
|
||||||
|
|||||||
+6
@@ -16366,6 +16366,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.kt");
|
runTest("compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("notFoundClasses.kt")
|
||||||
|
public void testNotFoundClasses() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/notFoundClasses.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("SamWithReceiverMavenProjectImportHandler.kt")
|
@TestMetadata("SamWithReceiverMavenProjectImportHandler.kt")
|
||||||
public void testSamWithReceiverMavenProjectImportHandler() throws Exception {
|
public void testSamWithReceiverMavenProjectImportHandler() throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
// WITH_RUNTIME
|
||||||
|
// IGNORE_BACKEND: JVM_IR
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
|
// MODULE: lib1
|
||||||
|
// FILE: A.java
|
||||||
|
public class A {}
|
||||||
|
|
||||||
|
// MODULE: lib2(lib1)
|
||||||
|
// FILE: B.java
|
||||||
|
public class B {
|
||||||
|
public static void foo(java.util.List<A> x) {}
|
||||||
|
public static java.util.List<A> getListOfA() { return new java.util.ArrayList<A>(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// MODULE: main(lib2)
|
||||||
|
// FILE: main.kt
|
||||||
|
|
||||||
|
val a = B.getListOfA()
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
B.foo(emptyList())
|
||||||
|
|
||||||
|
if (!a.isEmpty()) return "fail"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
-1
@@ -1,5 +1,4 @@
|
|||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// FILE: MySettings.java
|
// FILE: MySettings.java
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|||||||
+6
@@ -16252,6 +16252,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
|
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("notFoundClasses.kt")
|
||||||
|
public void testNotFoundClasses() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/notFoundClasses.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("SuspendExtension.kt")
|
@TestMetadata("SuspendExtension.kt")
|
||||||
public void testSuspendExtension() throws Exception {
|
public void testSuspendExtension() throws Exception {
|
||||||
|
|||||||
+6
@@ -16366,6 +16366,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.kt");
|
runTest("compiler/testData/codegen/box/fir/noSymbolForIntRangeIterator.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("notFoundClasses.kt")
|
||||||
|
public void testNotFoundClasses() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/notFoundClasses.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("SamWithReceiverMavenProjectImportHandler.kt")
|
@TestMetadata("SamWithReceiverMavenProjectImportHandler.kt")
|
||||||
public void testSamWithReceiverMavenProjectImportHandler() throws Exception {
|
public void testSamWithReceiverMavenProjectImportHandler() throws Exception {
|
||||||
|
|||||||
+5
@@ -13401,6 +13401,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
public void testNameHighlighter() throws Exception {
|
public void testNameHighlighter() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
|
runTest("compiler/testData/codegen/box/fir/NameHighlighter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("notFoundClasses.kt")
|
||||||
|
public void testNotFoundClasses() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/fir/notFoundClasses.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
@TestMetadata("compiler/testData/codegen/box/fullJdk")
|
||||||
|
|||||||
Reference in New Issue
Block a user