[Tests] Add test for KT-59493

This is to record the red->green change in behavior between K1 and K2,
when K2 correctly handles resolution/inference of an extension function
with definitely non-nullable type.
This commit is contained in:
marat.akhin
2023-10-30 15:18:49 +01:00
committed by Space Team
parent f8ee8adfde
commit d5fe86559d
7 changed files with 104 additions and 0 deletions
@@ -12358,6 +12358,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/isAsOperatorsEnabled.kt");
}
@Test
@TestMetadata("kt59493.kt")
public void testKt59493() throws Exception {
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/kt59493.kt");
}
@Test
@TestMetadata("notApplicable.kt")
public void testNotApplicable() throws Exception {
@@ -12358,6 +12358,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/isAsOperatorsEnabled.kt");
}
@Test
@TestMetadata("kt59493.kt")
public void testKt59493() throws Exception {
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/kt59493.kt");
}
@Test
@TestMetadata("notApplicable.kt")
public void testNotApplicable() throws Exception {
@@ -12352,6 +12352,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/isAsOperatorsEnabled.kt");
}
@Test
@TestMetadata("kt59493.kt")
public void testKt59493() throws Exception {
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/kt59493.kt");
}
@Test
@TestMetadata("notApplicable.kt")
public void testNotApplicable() throws Exception {
@@ -12358,6 +12358,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/isAsOperatorsEnabled.kt");
}
@Test
@TestMetadata("kt59493.kt")
public void testKt59493() throws Exception {
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/kt59493.kt");
}
@Test
@TestMetadata("notApplicable.kt")
public void testNotApplicable() throws Exception {
@@ -0,0 +1,37 @@
// !LANGUAGE: +DefinitelyNonNullableTypes
import kotlin.reflect.KProperty1
class Mem
class Ext
class Foo<T> {
fun foo(prop: KProperty1<T & Any, *>): Mem = Mem()
}
fun <T> Foo<T>.bar(prop: KProperty1<T & Any, *>): Ext = Ext()
class Bar<T> {
fun bar(prop: KProperty1<T & Any, *>): Mem = Mem()
}
fun <T> Bar<T>.bar(prop: KProperty1<T & Any, *>): Ext = Ext()
class Baz<T> {
fun baz(prop: KProperty1<T, *>): Mem = Mem()
}
fun <T> Baz<T>.baz(prop: KProperty1<T & Any, *>): Ext = Ext()
fun <T> id(t: T): T = t
fun main() {
val r01: Mem = Foo<String?>().foo(String::length)
val r02: Mem = Foo<String?>().foo(id(String::length))
val r03: Ext = Foo<String?>().bar(String::length)
val r04: Ext = Foo<String?>().bar(id(String::length))
val r05: Mem = Bar<String?>().bar(String::length)
val r06: Mem = Bar<String?>().bar(id(String::length))
val r07 = <!DEBUG_INFO_EXPRESSION_TYPE("Ext")!>Baz<String?>().baz(String::length)<!>
val r08: Ext = Baz<String?>().baz(id(String::length))
}
@@ -0,0 +1,37 @@
// !LANGUAGE: +DefinitelyNonNullableTypes
import kotlin.reflect.KProperty1
class Mem
class Ext
class Foo<T> {
fun foo(prop: KProperty1<T & Any, *>): Mem = Mem()
}
fun <T> Foo<T>.bar(prop: KProperty1<T & Any, *>): Ext = Ext()
class Bar<T> {
fun bar(prop: KProperty1<T & Any, *>): Mem = Mem()
}
fun <T> Bar<T>.<!EXTENSION_SHADOWED_BY_MEMBER!>bar<!>(prop: KProperty1<T & Any, *>): Ext = Ext()
class Baz<T> {
fun baz(prop: KProperty1<T, *>): Mem = Mem()
}
fun <T> Baz<T>.baz(prop: KProperty1<T & Any, *>): Ext = Ext()
fun <T> id(t: T): T = t
fun main() {
val r01: Mem = Foo<String?>().foo(String::length)
val r02: Mem = Foo<String?>().foo(id(String::length))
val r03: Ext = Foo<String?>().bar(<!TYPE_MISMATCH!>String::length<!>)
val r04: Ext = Foo<String?>().bar(id(String::length))
val r05: Mem = Bar<String?>().bar(String::length)
val r06: Mem = Bar<String?>().bar(id(String::length))
val r07 = <!DEBUG_INFO_EXPRESSION_TYPE("Mem")!>Baz<String?>().baz(<!TYPE_MISMATCH!>String::length<!>)<!>
val r08: Ext = Baz<String?>().baz(id(String::length))
}
@@ -12358,6 +12358,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/isAsOperatorsEnabled.kt");
}
@Test
@TestMetadata("kt59493.kt")
public void testKt59493() throws Exception {
runTest("compiler/testData/diagnostics/tests/explicitDefinitelyNotNullableViaIntersection/kt59493.kt");
}
@Test
@TestMetadata("notApplicable.kt")
public void testNotApplicable() throws Exception {