[NI] Do not incorporate constraints that are needed only for nullability

This commit is contained in:
Mikhail Zarechenskiy
2020-01-28 12:13:28 +03:00
parent ce690d8a1d
commit 35f6810b58
7 changed files with 49 additions and 1 deletions
@@ -10841,6 +10841,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/inference/nothingType/discriminatedNothingAndSmartCast.kt");
}
@TestMetadata("discriminatedNothingInsideComplexNestedCall.kt")
public void testDiscriminatedNothingInsideComplexNestedCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/discriminatedNothingInsideComplexNestedCall.kt");
}
@TestMetadata("generateConstraintWithInnerNothingType.kt")
public void testGenerateConstraintWithInnerNothingType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");
@@ -82,7 +82,9 @@ class ConstraintInjector(
// it is important, that we add constraint here(not inside TypeCheckerContext), because inside incorporation we read constraints
constraints.addConstraint(constraint)?.let {
constraintIncorporator.incorporate(typeCheckerContext, typeVariable, it)
if (!constraint.isNullabilityConstraint) {
constraintIncorporator.incorporate(typeCheckerContext, typeVariable, it)
}
}
}
}
@@ -0,0 +1,12 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun expanded(maxCapacity: Int, newCapacity: Int, buffer: Array<Any?>) {
select(buffer.copyOf(newCapacity), toArray(arrayOfNulls(newCapacity)))
}
fun <K> select(x: K, y: K): K = x
fun <T> Array<T>.copyOf(newSize: Int): Array<T?> = TODO()
inline fun <reified V> arrayOfNulls(size: Int): Array<V?> = TODO()
fun <S> toArray(array: Array<S>): Array<S> = TODO()
@@ -0,0 +1,12 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun expanded(maxCapacity: Int, newCapacity: Int, buffer: Array<Any?>) {
select(buffer.copyOf(newCapacity), toArray(arrayOfNulls(newCapacity)))
}
fun <K> select(x: K, y: K): K = x
fun <T> Array<T>.copyOf(newSize: Int): Array<T?> = TODO()
inline fun <reified V> arrayOfNulls(size: Int): Array<V?> = TODO()
fun <S> toArray(array: Array<S>): Array<S> = TODO()
@@ -0,0 +1,7 @@
package
public inline fun </*0*/ reified V> arrayOfNulls(/*0*/ size: kotlin.Int): kotlin.Array<V?>
public fun expanded(/*0*/ maxCapacity: kotlin.Int, /*1*/ newCapacity: kotlin.Int, /*2*/ buffer: kotlin.Array<kotlin.Any?>): kotlin.Unit
public fun </*0*/ K> select(/*0*/ x: K, /*1*/ y: K): K
public fun </*0*/ S> toArray(/*0*/ array: kotlin.Array<S>): kotlin.Array<S>
public fun </*0*/ T> kotlin.Array<T>.copyOf(/*0*/ newSize: kotlin.Int): kotlin.Array<T?>
@@ -10848,6 +10848,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/discriminatedNothingAndSmartCast.kt");
}
@TestMetadata("discriminatedNothingInsideComplexNestedCall.kt")
public void testDiscriminatedNothingInsideComplexNestedCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/discriminatedNothingInsideComplexNestedCall.kt");
}
@TestMetadata("generateConstraintWithInnerNothingType.kt")
public void testGenerateConstraintWithInnerNothingType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");
@@ -10843,6 +10843,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/inference/nothingType/discriminatedNothingAndSmartCast.kt");
}
@TestMetadata("discriminatedNothingInsideComplexNestedCall.kt")
public void testDiscriminatedNothingInsideComplexNestedCall() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/discriminatedNothingInsideComplexNestedCall.kt");
}
@TestMetadata("generateConstraintWithInnerNothingType.kt")
public void testGenerateConstraintWithInnerNothingType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/nothingType/generateConstraintWithInnerNothingType.kt");