From 33a82da4933ef436fde76d45baa43c9bd67ca02b Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Thu, 10 Jan 2013 11:00:53 +0400 Subject: [PATCH] supertype of error type should be an error type, not any --- .../jet/lang/types/CommonSupertypes.java | 3 +++ .../incompleteCode/SupertypeOfErrorType.kt | 24 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 5 ++++ 3 files changed, 32 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/CommonSupertypes.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/CommonSupertypes.java index a680d862a54..24fa3a595de 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/CommonSupertypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/CommonSupertypes.java @@ -47,6 +47,9 @@ public class CommonSupertypes { if (KotlinBuiltIns.getInstance().isNothingOrNullableNothing(type)) { iterator.remove(); } + if (ErrorUtils.isErrorType(type)) { + return ErrorUtils.createErrorType("Supertype of error type " + type); + } nullable |= type.isNullable(); } diff --git a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt new file mode 100644 index 00000000000..dfc84dac01a --- /dev/null +++ b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt @@ -0,0 +1,24 @@ +package a + +import java.util.Date +import java.util.Comparator + + +fun foo() { + + val c: Comparator = comparator {(date1, date2) -> + if (date1 != null && date2 != null) { + date1.compareTo(date2) * -11 + } else { + 11 + } + } +} + +fun bar(val i: Int, val a: U) { + val r = if (true) i else a + val b: Any = r +} + +//from standard library +public inline fun comparator(fn: (T,T) -> Int): Comparator {} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 69c3ef8d7f8..0316a6b98a3 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -1913,6 +1913,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/incompleteCode/senselessComparisonWithNull.kt"); } + @TestMetadata("SupertypeOfErrorType.kt") + public void testSupertypeOfErrorType() throws Exception { + doTest("compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt"); + } + @TestMetadata("compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError") public static class DiagnosticWithSyntaxError extends AbstractDiagnosticsTestWithEagerResolve { public void testAllFilesPresentInDiagnosticWithSyntaxError() throws Exception {