Add variance test for nullable and function types.
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
trait In<in T>
|
||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
trait Test<in I, out O, P> {
|
||||||
|
fun ok1(i: (O) -> I) : (I) -> O
|
||||||
|
fun ok2(i: (P) -> P) : (P) -> P
|
||||||
|
fun ok3(i: (In<I>) -> In<O>) = getT<(In<O>) -> In<I>>()
|
||||||
|
|
||||||
|
fun neOk1(i: (<!TYPE_VARIANCE_CONFLICT!>I<!>) -> <!TYPE_VARIANCE_CONFLICT!>O<!>): (<!TYPE_VARIANCE_CONFLICT!>O<!>) -> <!TYPE_VARIANCE_CONFLICT!>I<!>
|
||||||
|
fun neOk2(i: (In<<!TYPE_VARIANCE_CONFLICT!>O<!>>) -> In<<!TYPE_VARIANCE_CONFLICT!>I<!>>)
|
||||||
|
<!TYPE_VARIANCE_CONFLICT, TYPE_VARIANCE_CONFLICT!>fun neOk3()<!> = getT<(In<I>) -> In<O>>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal fun </*0*/ T> getT(): T
|
||||||
|
|
||||||
|
internal trait In</*0*/ in T> {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
internal trait Test</*0*/ in I, /*1*/ out O, /*2*/ P> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
internal abstract fun neOk1(/*0*/ i: (I) -> O): (O) -> I
|
||||||
|
internal abstract fun neOk2(/*0*/ i: (In<O>) -> In<I>): kotlin.Unit
|
||||||
|
internal open fun neOk3(): (In<I>) -> In<O>
|
||||||
|
internal abstract fun ok1(/*0*/ i: (O) -> I): (I) -> O
|
||||||
|
internal abstract fun ok2(/*0*/ i: (P) -> P): (P) -> P
|
||||||
|
internal open fun ok3(/*0*/ i: (In<I>) -> In<O>): (In<O>) -> In<I>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
trait In<in I>
|
||||||
|
trait Out<out O>
|
||||||
|
trait Inv<P>
|
||||||
|
fun <T> getT(): T = null!!
|
||||||
|
|
||||||
|
|
||||||
|
trait Test<in I : Any, out O : Any, P : Any> {
|
||||||
|
fun ok1(i: I?) : O?
|
||||||
|
fun ok2(i: In<O?>?) : Out<O?>?
|
||||||
|
fun ok3(i: Inv<in O?>) = getT<Inv<in I?>>()
|
||||||
|
|
||||||
|
fun neOk1(i: <!TYPE_VARIANCE_CONFLICT(O; out; in; O?)!>O?<!>) : <!TYPE_VARIANCE_CONFLICT(I; in; out; I?)!>I?<!>
|
||||||
|
fun neOk(i: Out<<!TYPE_VARIANCE_CONFLICT(O; out; in; Out<O?>?)!>O?<!>>?) : In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O?>?)!>O?<!>>?
|
||||||
|
fun neOk3(i: Inv<in <!TYPE_VARIANCE_CONFLICT(I; in; out; Inv<in I?>)!>I?<!>>)
|
||||||
|
<!TYPE_VARIANCE_CONFLICT(O; out; in; Inv<in O?>?)!>fun neOk4()<!> = getT<Inv<in O?>?>()
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal fun </*0*/ T> getT(): T
|
||||||
|
|
||||||
|
internal trait In</*0*/ in I> {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
internal trait Inv</*0*/ P> {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
internal trait Out</*0*/ out O> {
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
internal trait Test</*0*/ in I : kotlin.Any, /*1*/ out O : kotlin.Any, /*2*/ P : kotlin.Any> {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
internal abstract fun neOk(/*0*/ i: Out<O?>?): In<O?>?
|
||||||
|
internal abstract fun neOk1(/*0*/ i: O?): I?
|
||||||
|
internal abstract fun neOk3(/*0*/ i: Inv<in I?>): kotlin.Unit
|
||||||
|
internal open fun neOk4(): Inv<in O?>?
|
||||||
|
internal abstract fun ok1(/*0*/ i: I?): O?
|
||||||
|
internal abstract fun ok2(/*0*/ i: In<O?>?): Out<O?>?
|
||||||
|
internal open fun ok3(/*0*/ i: Inv<in O?>): Inv<in I?>
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -10304,6 +10304,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("FunctionTypes.kt")
|
||||||
|
public void testFunctionTypes() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/FunctionTypes.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("InPosition.kt")
|
@TestMetadata("InPosition.kt")
|
||||||
public void testInPosition() throws Exception {
|
public void testInPosition() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/InPosition.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/InPosition.kt");
|
||||||
@@ -10316,6 +10322,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("NullableTypes.kt")
|
||||||
|
public void testNullableTypes() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/NullableTypes.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("OutPosition.kt")
|
@TestMetadata("OutPosition.kt")
|
||||||
public void testOutPosition() throws Exception {
|
public void testOutPosition() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/OutPosition.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/variance/OutPosition.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user