[Test] Add test for KT-63996
False-positive TYPE_MISMATCH in builder inference with captured types
This commit is contained in:
committed by
Space Team
parent
48fdeeb42d
commit
cb3d65f669
+6
@@ -17004,6 +17004,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedTypesId.kt")
|
||||
public void testCapturedTypesId() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypesId.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("commonSuperType.kt")
|
||||
public void testCommonSuperType() throws Exception {
|
||||
|
||||
+6
@@ -17004,6 +17004,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedTypesId.kt")
|
||||
public void testCapturedTypesId() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypesId.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("commonSuperType.kt")
|
||||
public void testCommonSuperType() throws Exception {
|
||||
|
||||
+6
@@ -16998,6 +16998,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedTypesId.kt")
|
||||
public void testCapturedTypesId() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypesId.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("commonSuperType.kt")
|
||||
public void testCommonSuperType() throws Exception {
|
||||
|
||||
+6
@@ -17004,6 +17004,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedTypesId.kt")
|
||||
public void testCapturedTypesId() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypesId.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("commonSuperType.kt")
|
||||
public void testCommonSuperType() throws Exception {
|
||||
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// !LANGUAGE: +UnrestrictedBuilderInference
|
||||
// !DIAGNOSTICS: -DEPRECATION -UNCHECKED_CAST -OPT_IN_IS_NOT_ENABLED
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-63996
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun <R> build(block: TestInterface<R>.() -> Unit): R = TODO()
|
||||
|
||||
interface TestInterface<R> {
|
||||
fun emit(r: R)
|
||||
fun getOut(): Inv<out R>
|
||||
}
|
||||
|
||||
class Inv<T> {
|
||||
}
|
||||
|
||||
fun <K> capture(x: Inv<K>): K = null as K
|
||||
fun <I> id(x: I): I = null as I
|
||||
|
||||
fun main() {
|
||||
build {
|
||||
emit("")
|
||||
// K is fixed into CapturedType(out NotFixed: TypeVariable(R)
|
||||
capture(id(getOut())) // unexpected TYPE_MISMATCH (KT-63996)
|
||||
// capture(getOut()) // OK!!!
|
||||
Unit
|
||||
}
|
||||
build<String> {
|
||||
emit("")
|
||||
// K is fixed into CapturedType(out NotFixed: TypeVariable(R)
|
||||
capture(id(getOut())) // OK!!!
|
||||
// capture(getOut()) // OK!!!
|
||||
Unit
|
||||
}
|
||||
}
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
// !LANGUAGE: +UnrestrictedBuilderInference
|
||||
// !DIAGNOSTICS: -DEPRECATION -UNCHECKED_CAST -OPT_IN_IS_NOT_ENABLED
|
||||
// WITH_STDLIB
|
||||
// ISSUE: KT-63996
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun <R> build(block: TestInterface<R>.() -> Unit): R = TODO()
|
||||
|
||||
interface TestInterface<R> {
|
||||
fun emit(r: R)
|
||||
fun getOut(): Inv<out R>
|
||||
}
|
||||
|
||||
class Inv<T> {
|
||||
}
|
||||
|
||||
fun <K> capture(x: Inv<K>): K = null as K
|
||||
fun <I> id(x: I): I = null as I
|
||||
|
||||
fun main() {
|
||||
build {
|
||||
emit("")
|
||||
// K is fixed into CapturedType(out NotFixed: TypeVariable(R)
|
||||
capture(id(<!TYPE_MISMATCH, TYPE_MISMATCH!>getOut()<!>)) // unexpected TYPE_MISMATCH (KT-63996)
|
||||
// capture(getOut()) // OK!!!
|
||||
Unit
|
||||
}
|
||||
build<String> {
|
||||
emit("")
|
||||
// K is fixed into CapturedType(out NotFixed: TypeVariable(R)
|
||||
capture(id(getOut())) // OK!!!
|
||||
// capture(getOut()) // OK!!!
|
||||
Unit
|
||||
}
|
||||
}
|
||||
Generated
+6
@@ -17004,6 +17004,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypes.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("capturedTypesId.kt")
|
||||
public void testCapturedTypesId() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/stubTypes/capturedTypesId.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("commonSuperType.kt")
|
||||
public void testCommonSuperType() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user