Not get supertypes of Nothing
(exception EA-37833)
This commit is contained in:
+3
@@ -27,6 +27,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedure;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.TypeConstraintsImpl.ConstraintKind;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -190,6 +191,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
}
|
||||
switch (constraintKind) {
|
||||
case SUPER_TYPE: {
|
||||
if (JetStandardClasses.isNothingOrNullableNothing(constrainingType)) break;
|
||||
JetType correspondingSupertype = TypeCheckingProcedure.findCorrespondingSupertype(constrainingType, subjectType);
|
||||
if (correspondingSupertype != null) {
|
||||
constrainingType = correspondingSupertype;
|
||||
@@ -197,6 +199,7 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
break;
|
||||
}
|
||||
case SUB_TYPE: {
|
||||
if (JetStandardClasses.isNothingOrNullableNothing(subjectType)) break;
|
||||
JetType correspondingSupertype = TypeCheckingProcedure.findCorrespondingSupertype(subjectType, constrainingType);
|
||||
if (correspondingSupertype != null) {
|
||||
subjectType = correspondingSupertype;
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package d
|
||||
|
||||
trait A<T>
|
||||
|
||||
fun infer<T>(<!UNUSED_PARAMETER!>a<!>: A<T>) : T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun test(nothing: Nothing?) {
|
||||
val <!UNUSED_VARIABLE!>i<!> = <!TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH!>infer<!>(nothing)
|
||||
}
|
||||
|
||||
fun sum(<!UNUSED_PARAMETER!>a<!> : IntArray) : Int {
|
||||
for (<!UNREACHABLE_CODE!>n<!><!SYNTAX!><!>
|
||||
<!ITERATOR_AMBIGUITY!>return <!TYPE_MISMATCH!>"?"<!><!><!SYNTAX!><!>
|
||||
<!SYNTAX!><!>}
|
||||
@@ -1304,6 +1304,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/incompleteCode/arrayBracketsRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkNothingIsSubtype.kt")
|
||||
public void testCheckNothingIsSubtype() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/incompleteCode/checkNothingIsSubtype.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("incompleteAssignment.kt")
|
||||
public void testIncompleteAssignment() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/incompleteCode/incompleteAssignment.kt");
|
||||
|
||||
Reference in New Issue
Block a user