[Test] Add test for KT-54663

This commit is contained in:
Dmitriy Novozhilov
2022-10-25 13:35:23 +03:00
committed by Space Team
parent b7da00744b
commit 6bc952adff
7 changed files with 110 additions and 0 deletions
@@ -32442,6 +32442,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt");
}
@Test
@TestMetadata("inProjectedDnnParameter.kt")
public void testInProjectedDnnParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt");
}
@Test
@TestMetadata("kt42042.kt")
public void testKt42042() throws Exception {
@@ -32442,6 +32442,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt");
}
@Test
@TestMetadata("inProjectedDnnParameter.kt")
public void testInProjectedDnnParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt");
}
@Test
@TestMetadata("kt42042.kt")
public void testKt42042() throws Exception {
@@ -32442,6 +32442,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt");
}
@Test
@TestMetadata("inProjectedDnnParameter.kt")
public void testInProjectedDnnParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt");
}
@Test
@TestMetadata("kt42042.kt")
public void testKt42042() throws Exception {
@@ -0,0 +1,30 @@
// ISSUE: KT-54663
// FILE: JavaAction.java
import org.jetbrains.annotations.NotNull;
public interface JavaAction<T> {
void execute(@NotNull T t);
}
// FILE: test.kt
interface KotlinAction<T> {
fun execute(t: T & Any)
}
class A<T> {
fun checkJavaIn(element: T, action: JavaAction<in T>) {
action.execute(<!ARGUMENT_TYPE_MISMATCH!>element<!>) // OK in K1, type mismatch in K2
}
fun checkKotlinIn(element: T, action: KotlinAction<in T>) {
action.execute(<!ARGUMENT_TYPE_MISMATCH!>element<!>) // OK in K1, type mismatch in K2
}
fun checkJavaInv(element: T, action: JavaAction<T>) {
action.execute(<!ARGUMENT_TYPE_MISMATCH!>element<!>) // type mismatch in K1 and K2
}
fun checkKotlinInv(element: T, action: KotlinAction<T>) {
action.execute(<!ARGUMENT_TYPE_MISMATCH!>element<!>) // type mismatch in K1 and K2
}
}
@@ -0,0 +1,30 @@
// ISSUE: KT-54663
// FILE: JavaAction.java
import org.jetbrains.annotations.NotNull;
public interface JavaAction<T> {
void execute(@NotNull T t);
}
// FILE: test.kt
interface KotlinAction<T> {
fun execute(t: T & Any)
}
class A<T> {
fun checkJavaIn(element: T, action: JavaAction<in T>) {
action.execute(element) // OK in K1, type mismatch in K2
}
fun checkKotlinIn(element: T, action: KotlinAction<in T>) {
action.execute(element) // OK in K1, type mismatch in K2
}
fun checkJavaInv(element: T, action: JavaAction<T>) {
action.execute(<!TYPE_MISMATCH!>element<!>) // type mismatch in K1 and K2
}
fun checkKotlinInv(element: T, action: KotlinAction<T>) {
action.execute(<!TYPE_MISMATCH!>element<!>) // type mismatch in K1 and K2
}
}
@@ -0,0 +1,26 @@
package
public final class A</*0*/ T> {
public constructor A</*0*/ T>()
public final fun checkJavaIn(/*0*/ element: T, /*1*/ action: JavaAction<in T>): kotlin.Unit
public final fun checkJavaInv(/*0*/ element: T, /*1*/ action: JavaAction<T>): kotlin.Unit
public final fun checkKotlinIn(/*0*/ element: T, /*1*/ action: KotlinAction<in T>): kotlin.Unit
public final fun checkKotlinInv(/*0*/ element: T, /*1*/ action: KotlinAction<T>): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface JavaAction</*0*/ T : kotlin.Any!> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun execute(/*0*/ @org.jetbrains.annotations.NotNull t: T & Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface KotlinAction</*0*/ T> {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun execute(/*0*/ t: T & Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -32532,6 +32532,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/typeParameters/implicitNothingOnDelegates.kt");
}
@Test
@TestMetadata("inProjectedDnnParameter.kt")
public void testInProjectedDnnParameter() throws Exception {
runTest("compiler/testData/diagnostics/tests/typeParameters/inProjectedDnnParameter.kt");
}
@Test
@TestMetadata("kt42042.kt")
public void testKt42042() throws Exception {