[FIR] Resolve statuses of supertypes for all non-source classes

Previously we forced computation only for java and precompiled classes,
  assuming, that binary class can not extend source class, but it's not
  true in two cases:
1. Classpath substitution: class with same name declared in library and
   the source (more rare case)
2. Metadata compilation: depends-on dependcies are passed in binary
   format, so `expect class` may be a binary one and corresponding
   `actual class` may be a source. So if some class in `common` module
   extend this expect class, actual class will be substituted instead of it

^KT-65669 Fixed
This commit is contained in:
Dmitriy Novozhilov
2024-02-14 08:42:59 +02:00
committed by Space Team
parent 9219a8f485
commit 84f0f6e099
22 changed files with 149 additions and 4 deletions
@@ -20048,6 +20048,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
@@ -20048,6 +20048,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
@@ -19977,6 +19977,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
@@ -19977,6 +19977,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
@@ -19977,6 +19977,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
@@ -364,11 +364,11 @@ abstract class AbstractFirStatusResolveTransformer(
}
private fun forceResolveStatusesOfClass(regularClass: FirRegularClass) {
if (regularClass.origin is FirDeclarationOrigin.Java || regularClass.origin == FirDeclarationOrigin.Precompiled) {
if (regularClass.origin != FirDeclarationOrigin.Source) {
/*
* If regular class has no corresponding file then it is platform class,
* If regular class has no corresponding file then it is platform or binary class,
* so we need to resolve supertypes of this class because they could
* come from kotlin sources
* come from kotlin sources (e.g. for java classes or cases of classpath substitution)
*/
val statusComputationStatus = statusComputationSession[regularClass]
if (!statusComputationStatus.requiresComputation) return
@@ -380,7 +380,6 @@ abstract class AbstractFirStatusResolveTransformer(
return
}
if (regularClass.origin != FirDeclarationOrigin.Source) return
val statusComputationStatus = statusComputationSession[regularClass]
if (!statusComputationStatus.requiresComputation) return
if (!resolveClassForSuperType(regularClass)) return
+27
View File
@@ -0,0 +1,27 @@
// IGNORE_BACKEND: JS, JS_IR, JS_IR_ES6
// KT-65822: JS targets are ignored, as they doesn't support source-binary-source dependencies
// IGNORE_BACKEND_K2: WASM
// Reason: KT-65794
// IGNORE_NATIVE: cacheMode=STATIC_EVERYWHERE && target=linux_x64
// ISSUE: KT-65669
// MODULE: a
// FILE: a.kt
abstract class Base {
open fun foo() {}
}
open class Derived : Base()
// MODULE: b(a)
// FILE: first.kt
class Impl : Derived() {
override fun foo() {}
}
// FILE: second.kt
abstract class Base {
open fun foo() {}
}
fun box(): String = "OK"
@@ -19977,6 +19977,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
@@ -18909,6 +18909,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -19977,6 +19977,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
@@ -19977,6 +19977,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
@@ -16645,6 +16645,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@TestMetadata("StackOverflowInAnnotationLoader.kt")
public void testStackOverflowInAnnotationLoader() throws Exception {
runTest("compiler/testData/codegen/box/fir/StackOverflowInAnnotationLoader.kt");
@@ -14769,6 +14769,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -14769,6 +14769,12 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -14769,6 +14769,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -14769,6 +14769,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -15905,6 +15905,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -16273,6 +16273,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -15537,6 +15537,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -15906,6 +15906,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -14745,6 +14745,12 @@ public class FirWasmJsCodegenBoxTestGenerated extends AbstractFirWasmJsCodegenBo
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {
@@ -14745,6 +14745,12 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest
runTest("compiler/testData/codegen/box/fir/smartCastToInvisibleClassMember.kt");
}
@Test
@TestMetadata("sourceBinarySource.kt")
public void testSourceBinarySource() throws Exception {
runTest("compiler/testData/codegen/box/fir/sourceBinarySource.kt");
}
@Test
@TestMetadata("starProjectionLambdaNullReturn.kt")
public void testStarProjectionLambdaNullReturn() throws Exception {