FIR: Fix overridability of Kotlin vararg from Java

This commit is contained in:
Denis.Zharkov
2021-10-25 13:35:30 +03:00
parent 4b1ce6c1a7
commit 5690a9f21b
6 changed files with 45 additions and 2 deletions
@@ -17991,6 +17991,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
public void testTypeParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt");
}
@Test
@TestMetadata("varargOverride.kt")
public void testVarargOverride() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/types/varargOverride.kt");
}
}
}
@@ -17991,6 +17991,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
public void testTypeParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt");
}
@Test
@TestMetadata("varargOverride.kt")
public void testVarargOverride() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/types/varargOverride.kt");
}
}
}
@@ -17991,6 +17991,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
public void testTypeParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt");
}
@Test
@TestMetadata("varargOverride.kt")
public void testVarargOverride() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/types/varargOverride.kt");
}
}
}
@@ -94,8 +94,7 @@ class JavaOverrideChecker internal constructor(
): Boolean =
when {
candidateTypeProjection is ConeKotlinTypeProjection && baseTypeProjection is ConeKotlinTypeProjection ->
candidateTypeProjection.kind == baseTypeProjection.kind &&
isEqualTypes(candidateTypeProjection.type, baseTypeProjection.type, substitutor)
isEqualTypes(candidateTypeProjection.type, baseTypeProjection.type, substitutor)
candidateTypeProjection is ConeStarProjection && baseTypeProjection is ConeStarProjection -> true
else -> false
}
@@ -0,0 +1,20 @@
// SKIP_TXT
// FIR_IDENTICAL
// FILE: A.java
import org.jetbrains.annotations.NotNull;
public interface A extends B {
void foo(@NotNull String... value);
}
// FILE: main.kt
interface B {
fun foo(vararg x: String) {}
}
fun main(a: A) {
a.foo()
a.foo("1")
a.foo("2", "3")
}
@@ -17997,6 +17997,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
public void testTypeParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/types/typeParameter.kt");
}
@Test
@TestMetadata("varargOverride.kt")
public void testVarargOverride() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/types/varargOverride.kt");
}
}
}