From 936f53fcbf4ccafd7c4028f315432c6456245b07 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 20 Sep 2012 15:11:22 +0400 Subject: [PATCH] Don't complain about compareTo returning ERROR type instead of Int --- .../lang/types/expressions/BasicExpressionTypingVisitor.java | 2 +- .../testData/diagnostics/tests/CompareToWithErrorType.kt | 5 +++++ .../jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/CompareToWithErrorType.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 152c8660c90..65bc1a11294 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -974,7 +974,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } else if (OperatorConventions.COMPARISON_OPERATIONS.contains(operationType)) { JetType compareToReturnType = getTypeForBinaryCall(context.scope, Name.identifier("compareTo"), context, expression); - if (compareToReturnType != null) { + if (compareToReturnType != null && !ErrorUtils.isErrorType(compareToReturnType)) { TypeConstructor constructor = compareToReturnType.getConstructor(); JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance(); TypeConstructor intTypeConstructor = standardLibrary.getInt().getTypeConstructor(); diff --git a/compiler/testData/diagnostics/tests/CompareToWithErrorType.kt b/compiler/testData/diagnostics/tests/CompareToWithErrorType.kt new file mode 100644 index 00000000000..149d875bb6e --- /dev/null +++ b/compiler/testData/diagnostics/tests/CompareToWithErrorType.kt @@ -0,0 +1,5 @@ +fun test() { + if (x > 0) { + + } +} \ 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 07aca1ceca0..71ee5ab3b31 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -141,6 +141,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/ClassObjects.kt"); } + @TestMetadata("CompareToWithErrorType.kt") + public void testCompareToWithErrorType() throws Exception { + doTest("compiler/testData/diagnostics/tests/CompareToWithErrorType.kt"); + } + @TestMetadata("Constants.kt") public void testConstants() throws Exception { doTest("compiler/testData/diagnostics/tests/Constants.kt");