[FIR] Reproduce one more failure for KT-65972 #2

And refactor another related test to
explain the desired behavior.

^KT-65972
This commit is contained in:
Nikolay Lunyak
2024-02-21 13:53:48 +02:00
committed by Space Team
parent e929ed8f8c
commit ee20d979cb
8 changed files with 128 additions and 13 deletions
@@ -633,6 +633,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJava.kt");
}
@Test
@TestMetadata("intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt")
public void testIntersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin() {
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt");
}
@Test
@TestMetadata("invalidTargetCrashesCompiler.kt")
public void testInvalidTargetCrashesCompiler() {
@@ -633,6 +633,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJava.kt");
}
@Test
@TestMetadata("intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt")
public void testIntersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin() {
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt");
}
@Test
@TestMetadata("invalidTargetCrashesCompiler.kt")
public void testInvalidTargetCrashesCompiler() {
@@ -633,6 +633,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJava.kt");
}
@Test
@TestMetadata("intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt")
public void testIntersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin() {
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt");
}
@Test
@TestMetadata("invalidTargetCrashesCompiler.kt")
public void testInvalidTargetCrashesCompiler() {
@@ -633,6 +633,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJava.kt");
}
@Test
@TestMetadata("intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt")
public void testIntersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin() {
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt");
}
@Test
@TestMetadata("invalidTargetCrashesCompiler.kt")
public void testInvalidTargetCrashesCompiler() {
@@ -0,0 +1,35 @@
// FILE: ColoredTextContainer.java
public interface ColoredTextContainer {
default void setToolTipText(String text) {}
}
// FILE: JComponent.java
public abstract class JComponent {
public void setToolTipText(String text) {}
}
// FILE: SimpleColoredComponent.java
// IDEALLY:
// Provides `IO SimpleColoredComponent::setToolTipText`, because inherits
// `JComponent::setToolTipText` and `ColoredTextContainer::setToolTipText`,
// which don't sumbsume one another, but Java allows picking the class-based one in this case.
// REALITY:
// Contains an IO for the above. We check if this is green Java via a
// modified check that accounts for this case.
public class SimpleColoredComponent extends JComponent implements ColoredTextContainer {}
// FILE: Main.kt
// Not important, left for the record
interface TextFragment : ColoredTextContainer
// IDEALLY:
// Provides `JComponent::setToolTipText`, because inherits
// `ColoredTextContainer::setToolTipText` and `IO SimpleColoredComponent::setToolTipText`,
// and the latter subsumes the former.
// REALITY:
// Contains IO between `ColoredTextContainer::setToolTipText` and `IO SimpleColoredComponent::setToolTipText`.
// In this case `IO SimpleColoredComponent::setToolTipText` should not be unwrapped, otherwise
// we miss `nonSubsumed()` check and since this is a Kotlin class we are not allowed to implicitly choose
// between `JComponent::setToolTipText` and `ColoredTextContainer::setToolTipText`.
private <!CANNOT_INFER_VISIBILITY!>class TextFragmentImpl<!> : TextFragment, SimpleColoredComponent()
@@ -0,0 +1,35 @@
// FILE: ColoredTextContainer.java
public interface ColoredTextContainer {
default void setToolTipText(String text) {}
}
// FILE: JComponent.java
public abstract class JComponent {
public void setToolTipText(String text) {}
}
// FILE: SimpleColoredComponent.java
// IDEALLY:
// Provides `IO SimpleColoredComponent::setToolTipText`, because inherits
// `JComponent::setToolTipText` and `ColoredTextContainer::setToolTipText`,
// which don't sumbsume one another, but Java allows picking the class-based one in this case.
// REALITY:
// Contains an IO for the above. We check if this is green Java via a
// modified check that accounts for this case.
public class SimpleColoredComponent extends JComponent implements ColoredTextContainer {}
// FILE: Main.kt
// Not important, left for the record
interface TextFragment : ColoredTextContainer
// IDEALLY:
// Provides `JComponent::setToolTipText`, because inherits
// `ColoredTextContainer::setToolTipText` and `IO SimpleColoredComponent::setToolTipText`,
// and the latter subsumes the former.
// REALITY:
// Contains IO between `ColoredTextContainer::setToolTipText` and `IO SimpleColoredComponent::setToolTipText`.
// In this case `IO SimpleColoredComponent::setToolTipText` should not be unwrapped, otherwise
// we miss `nonSubsumed()` check and since this is a Kotlin class we are not allowed to implicitly choose
// between `JComponent::setToolTipText` and `ColoredTextContainer::setToolTipText`.
private class TextFragmentImpl : TextFragment, SimpleColoredComponent()
@@ -1,21 +1,36 @@
// FIR_IDENTICAL
// inherits accept from FirDeclarationStatusImpl and FirResolvedDeclarationStatus
class FirResolvedDeclarationStatusImpl : FirDeclarationStatusImpl(), FirResolvedDeclarationStatus
// inherits accept from FirElement and FirDeclarationStatus
open class FirDeclarationStatusImpl : FirPureAbstractElement(), FirDeclarationStatus
abstract class FirPureAbstractElement : FirElement
interface FirResolvedDeclarationStatus : FirDeclarationStatus {
override fun accept() {}
interface FirElement {
fun accept() {}
}
// Provides `FirElement::accept`, because has no override for it
abstract class FirPureAbstractElement : FirElement
interface FirDeclarationStatus : FirElement {
override fun accept() {}
}
interface FirElement {
fun accept() {}
}
interface FirResolvedDeclarationStatus : FirDeclarationStatus {
override fun accept() {}
}
// IDEALLY:
// Provides `FirDeclarationStatus::accept`, because interits
// `FirElement::accept` and `FirDeclarationStatus::accept`,
// and the latter subsumes the former.
// REALLY:
// Contains an IO, which is an override. So, unlike `FirPureAbstractElement`,
// this class does have some override. We make sure this IO is green Kotlin
// by calculating `nonSubsumed()` for the base functions
open class FirDeclarationStatusImpl : FirPureAbstractElement(), FirDeclarationStatus
// IDEALLY:
// Provides `FirResolvedDeclarationStatus::accept`, because
// inherits `FirDeclarationStatus::accept` and `FirResolvedDeclarationStatus::accept`,
// and the latter subsumes the former.
// REALLY:
// Inherits `IO FirDeclarationStatusImpl::accept` and `FirResolvedDeclarationStatus::accept`.
// Contains an IO for the above 2 functions. To check if this is green, we unwrap the IO in
// the base and then check `nonSubsumed()`, thus doing what is written in "IDEALLY".
class FirResolvedDeclarationStatusImpl : FirDeclarationStatusImpl(), FirResolvedDeclarationStatus
@@ -633,6 +633,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJava.kt");
}
@Test
@TestMetadata("intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt")
public void testIntersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin() {
runTest("compiler/testData/diagnostics/tests/intersectionWithMultipleDefaultsInJavaOverriddenByIntersectionInKotlin.kt");
}
@Test
@TestMetadata("invalidTargetCrashesCompiler.kt")
public void testInvalidTargetCrashesCompiler() {