[IR] Don't check annotations on expect/actual fake overrides

^KT-58551
This commit is contained in:
Roman Efremov
2023-06-23 13:06:21 +02:00
committed by Space Team
parent 2980179bd7
commit 454756a2b5
5 changed files with 57 additions and 0 deletions
@@ -256,6 +256,12 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/differentOrder.kt");
}
@Test
@TestMetadata("fakeOverrides.kt")
public void testFakeOverrides() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/fakeOverrides.kt");
}
@Test
@TestMetadata("floatNumbersComparison.kt")
public void testFloatNumbersComparison() throws Exception {
@@ -256,6 +256,12 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/differentOrder.kt");
}
@Test
@TestMetadata("fakeOverrides.kt")
public void testFakeOverrides() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/fakeOverrides.kt");
}
@Test
@TestMetadata("floatNumbersComparison.kt")
public void testFloatNumbersComparison() throws Exception {
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.symbols.IrTypeAliasSymbol
import org.jetbrains.kotlin.ir.types.IrTypeSystemContext
import org.jetbrains.kotlin.ir.util.classIdOrFail
import org.jetbrains.kotlin.ir.util.isFakeOverride
import org.jetbrains.kotlin.resolve.calls.mpp.AbstractExpectActualAnnotationMatchChecker
internal class IrExpectActualAnnotationMatchingChecker(
@@ -34,6 +35,9 @@ internal class IrExpectActualAnnotationMatchingChecker(
fun check() {
for ((expectSymbol, actualSymbol) in matchedExpectToActual.entries) {
if (expectSymbol.isFakeOverride || actualSymbol.isFakeOverride) {
continue
}
val incompatibility =
AbstractExpectActualAnnotationMatchChecker.areAnnotationsCompatible(expectSymbol, actualSymbol, context) ?: continue
@@ -46,6 +50,9 @@ internal class IrExpectActualAnnotationMatchingChecker(
}
}
private val IrSymbol.isFakeOverride: Boolean
get() = (owner as IrDeclaration).isFakeOverride
private fun getTypealiasSymbolIfActualizedViaTypealias(expectSymbol: IrSymbol): IrTypeAliasSymbol? {
val expectDeclaration = expectSymbol.owner as IrDeclaration
val topLevelExpectClass = expectDeclaration.parentsWithSelf.filterIsInstance<IrClass>().lastOrNull() ?: return null
@@ -0,0 +1,32 @@
// FIR_IDENTICAL
// MODULE: m1-common
// FILE: common.kt
annotation class Ann
interface I {
@Ann
fun noAnnotationOnActual()
}
expect class FakeOverrideExpect : I
interface I2 {
fun noAnnotationOnActual()
}
expect class FakeOverrideActual : I2 {
@Ann
override fun noAnnotationOnActual()
}
// MODULE: m1-jvm()()(m1-common)
// FILE: jvm.kt
actual class FakeOverrideExpect : I {
override fun noAnnotationOnActual() {}
}
abstract class Intermediate : I2 {
override fun noAnnotationOnActual() {}
}
actual class FakeOverrideActual : Intermediate(), I2
@@ -22801,6 +22801,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/differentOrder.kt");
}
@Test
@TestMetadata("fakeOverrides.kt")
public void testFakeOverrides() throws Exception {
runTest("compiler/testData/diagnostics/tests/multiplatform/annotationMatching/fakeOverrides.kt");
}
@Test
@TestMetadata("floatNumbersComparison.kt")
public void testFloatNumbersComparison() throws Exception {