NI: Add flexible Nothing to trivial constraints to filter it
This commit is contained in:
Generated
+5
@@ -10560,6 +10560,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("implicitInferenceTToFlexibleNothing.kt")
|
||||||
|
public void testImplicitInferenceTToFlexibleNothing() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitInferenceTToFlexibleNothing.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("implicitNothingConstraintFromReturn.kt")
|
@TestMetadata("implicitNothingConstraintFromReturn.kt")
|
||||||
public void testImplicitNothingConstraintFromReturn() throws Exception {
|
public void testImplicitNothingConstraintFromReturn() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitNothingConstraintFromReturn.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitNothingConstraintFromReturn.kt");
|
||||||
|
|||||||
+1
-1
@@ -40,7 +40,7 @@ class TrivialConstraintTypeInferenceOracle(context: TypeSystemInferenceExtension
|
|||||||
generatedConstraintType: KotlinTypeMarker,
|
generatedConstraintType: KotlinTypeMarker,
|
||||||
isSubtype: Boolean
|
isSubtype: Boolean
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (isSubtype && generatedConstraintType.isNothing()) return true
|
if (isSubtype && (generatedConstraintType.isNothing() || generatedConstraintType.isFlexibleNothing())) return true
|
||||||
if (!isSubtype && generatedConstraintType.isNullableAny()) return true
|
if (!isSubtype && generatedConstraintType.isNullableAny()) return true
|
||||||
|
|
||||||
// If types from constraints that will be used to generate new constraint already contains `Nothing(?)`,
|
// If types from constraints that will be used to generate new constraint already contains `Nothing(?)`,
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ public class Foo {
|
|||||||
// FILE: test.kt
|
// FILE: test.kt
|
||||||
|
|
||||||
fun test(e: <!UNRESOLVED_REFERENCE!>ErrorType<!>) {
|
fun test(e: <!UNRESOLVED_REFERENCE!>ErrorType<!>) {
|
||||||
Foo.foo {
|
Foo.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!> {
|
||||||
Sam.Result.create(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>e<!>)
|
Sam.Result.create(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>e<!>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNCHECKED_CAST -UNUSED_PARAMETER
|
||||||
|
// !LANGUAGE: +NewInference
|
||||||
|
// SKIP_TXT
|
||||||
|
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
fun <T> foo (f: () -> List<T>): T = null as T
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!> { Collections.<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>() }
|
||||||
|
}
|
||||||
@@ -10567,6 +10567,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("implicitInferenceTToFlexibleNothing.kt")
|
||||||
|
public void testImplicitInferenceTToFlexibleNothing() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitInferenceTToFlexibleNothing.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("implicitNothingConstraintFromReturn.kt")
|
@TestMetadata("implicitNothingConstraintFromReturn.kt")
|
||||||
public void testImplicitNothingConstraintFromReturn() throws Exception {
|
public void testImplicitNothingConstraintFromReturn() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitNothingConstraintFromReturn.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitNothingConstraintFromReturn.kt");
|
||||||
|
|||||||
Generated
+5
@@ -10562,6 +10562,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
|||||||
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("implicitInferenceTToFlexibleNothing.kt")
|
||||||
|
public void testImplicitInferenceTToFlexibleNothing() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitInferenceTToFlexibleNothing.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("implicitNothingConstraintFromReturn.kt")
|
@TestMetadata("implicitNothingConstraintFromReturn.kt")
|
||||||
public void testImplicitNothingConstraintFromReturn() throws Exception {
|
public void testImplicitNothingConstraintFromReturn() throws Exception {
|
||||||
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitNothingConstraintFromReturn.kt");
|
runTest("compiler/testData/diagnostics/tests/inference/nothingType/implicitNothingConstraintFromReturn.kt");
|
||||||
|
|||||||
@@ -248,6 +248,9 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
|||||||
|
|
||||||
fun KotlinTypeMarker.isNullableAny() = this.typeConstructor().isAnyConstructor() && this.isNullableType()
|
fun KotlinTypeMarker.isNullableAny() = this.typeConstructor().isAnyConstructor() && this.isNullableType()
|
||||||
fun KotlinTypeMarker.isNothing() = this.typeConstructor().isNothingConstructor() && !this.isNullableType()
|
fun KotlinTypeMarker.isNothing() = this.typeConstructor().isNothingConstructor() && !this.isNullableType()
|
||||||
|
fun KotlinTypeMarker.isFlexibleNothing() =
|
||||||
|
this is FlexibleTypeMarker && lowerBound().isNothing() && upperBound().isNullableNothing()
|
||||||
|
|
||||||
fun KotlinTypeMarker.isNullableNothing() = this.typeConstructor().isNothingConstructor() && this.isNullableType()
|
fun KotlinTypeMarker.isNullableNothing() = this.typeConstructor().isNothingConstructor() && this.isNullableType()
|
||||||
|
|
||||||
fun SimpleTypeMarker.isClassType(): Boolean = typeConstructor().isClassTypeConstructor()
|
fun SimpleTypeMarker.isClassType(): Boolean = typeConstructor().isClassTypeConstructor()
|
||||||
|
|||||||
Reference in New Issue
Block a user