Fir2Ir: handle nested class references in type parameter bounds
This commit is contained in:
committed by
Alexander Udalov
parent
9fb1a901cf
commit
49576e0cbb
@@ -546,6 +546,10 @@ class Fir2IrClassifierStorage(
|
|||||||
val parentId = classId.outerClassId
|
val parentId = classId.outerClassId
|
||||||
val parentClass = parentId?.let { session.symbolProvider.getClassLikeSymbolByClassId(it) }
|
val parentClass = parentId?.let { session.symbolProvider.getClassLikeSymbolByClassId(it) }
|
||||||
val irParent = declarationStorage.findIrParent(classId.packageFqName, parentClass?.toLookupTag(), firClassSymbol, firClass.origin)!!
|
val irParent = declarationStorage.findIrParent(classId.packageFqName, parentClass?.toLookupTag(), firClassSymbol, firClass.origin)!!
|
||||||
|
|
||||||
|
// firClass may be referenced by some parent's type parameters as a bound. In that case, getIrClassSymbol will be called recursively.
|
||||||
|
getCachedIrClass(firClass)?.let { return it.symbol }
|
||||||
|
|
||||||
val irClass = firClass.convertWithOffsets { startOffset, endOffset ->
|
val irClass = firClass.convertWithOffsets { startOffset, endOffset ->
|
||||||
symbolTable.declareClass(signature, { symbol }) {
|
symbolTable.declareClass(signature, { symbol }) {
|
||||||
Fir2IrLazyClass(components, startOffset, endOffset, firClass.irOrigin(firProvider), firClass, symbol).apply {
|
Fir2IrLazyClass(components, startOffset, endOffset, firClass.irOrigin(firProvider), firClass, symbol).apply {
|
||||||
|
|||||||
+6
@@ -7355,6 +7355,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassAsBound.kt")
|
||||||
|
public void testNestedClassAsBound() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClassAsBound.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
||||||
public void testNestedClassInAnnotationArgument() throws Exception {
|
public void testNestedClassInAnnotationArgument() throws Exception {
|
||||||
|
|||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// MODULE: lib
|
||||||
|
// FILE: Q.kt
|
||||||
|
class Q<T : Q.S> {
|
||||||
|
open class S {
|
||||||
|
val ok = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: box.kt
|
||||||
|
fun box() = Q.S().ok
|
||||||
+6
@@ -7241,6 +7241,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassAsBound.kt")
|
||||||
|
public void testNestedClassAsBound() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClassAsBound.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
||||||
public void testNestedClassInAnnotationArgument() throws Exception {
|
public void testNestedClassInAnnotationArgument() throws Exception {
|
||||||
|
|||||||
+6
@@ -7355,6 +7355,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassAsBound.kt")
|
||||||
|
public void testNestedClassAsBound() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClassAsBound.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
||||||
public void testNestedClassInAnnotationArgument() throws Exception {
|
public void testNestedClassInAnnotationArgument() throws Exception {
|
||||||
|
|||||||
+6
@@ -337,6 +337,12 @@ public class JvmIrAgainstOldBoxTestGenerated extends AbstractJvmIrAgainstOldBoxT
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassAsBound.kt")
|
||||||
|
public void testNestedClassAsBound() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClassAsBound.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
||||||
public void testNestedClassInAnnotationArgument() throws Exception {
|
public void testNestedClassInAnnotationArgument() throws Exception {
|
||||||
|
|||||||
+6
@@ -337,6 +337,12 @@ public class JvmOldAgainstIrBoxTestGenerated extends AbstractJvmOldAgainstIrBoxT
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassAsBound.kt")
|
||||||
|
public void testNestedClassAsBound() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClassAsBound.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
||||||
public void testNestedClassInAnnotationArgument() throws Exception {
|
public void testNestedClassInAnnotationArgument() throws Exception {
|
||||||
|
|||||||
+6
@@ -5563,6 +5563,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("nestedClassAsBound.kt")
|
||||||
|
public void testNestedClassAsBound() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/nestedClassAsBound.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
@TestMetadata("nestedClassInAnnotationArgument.kt")
|
||||||
public void testNestedClassInAnnotationArgument() throws Exception {
|
public void testNestedClassInAnnotationArgument() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user