[NI] Preserve nullability of resulting type from CST if it's possible

Consider common supertype of `S` and `Nothing`, where `S` has nullable
 upper bound or it's flexible. Before the fix, result was `S?`, which
 is correct but too conservative. Now, we'll preserve nullability of
 resulting type if it's already nullable.

 This happened because we were failing to find path of not-nullable
 types from `Nothing` to `S`, which should obviously exists by
 semantics of Nothing
This commit is contained in:
Mikhail Zarechenskiy
2019-03-04 01:18:07 +03:00
parent 9b3e17f0d7
commit 93e79afab4
5 changed files with 59 additions and 1 deletions
@@ -9823,6 +9823,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.kt");
}
@TestMetadata("cstFromNullableChildAndNonParameterizedType.kt")
public void testCstFromNullableChildAndNonParameterizedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/cstFromNullableChildAndNonParameterizedType.kt");
}
@TestMetadata("dontCaptureTypeVariable.kt")
public void testDontCaptureTypeVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.kt");
@@ -9818,6 +9818,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/boundOnNullableVariable.kt");
}
@TestMetadata("cstFromNullableChildAndNonParameterizedType.kt")
public void testCstFromNullableChildAndNonParameterizedType() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/cstFromNullableChildAndNonParameterizedType.kt");
}
@TestMetadata("dontCaptureTypeVariable.kt")
public void testDontCaptureTypeVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/commonSystem/dontCaptureTypeVariable.kt");