From 95ef417ee81d7edbf95894a5691debde93d0517d Mon Sep 17 00:00:00 2001 From: svtk Date: Fri, 8 Nov 2013 14:57:43 +0400 Subject: [PATCH] KT-4170 Compiler hangs (or works too long) #KT-4170 Fixed --- .../lang/diagnostics/PositioningStrategy.java | 3 -- .../resolve/resolveWithRedeclarationError.kt | 34 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 5 +++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategy.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategy.java index 4e54884790a..a149ef32b69 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategy.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/PositioningStrategy.java @@ -53,9 +53,6 @@ public class PositioningStrategy { protected static boolean hasSyntaxErrors(@NotNull PsiElement psiElement) { if (psiElement instanceof PsiErrorElement) return true; - PsiElement lastChild = psiElement.getLastChild(); - if (lastChild != null && hasSyntaxErrors(lastChild)) return true; - PsiElement[] children = psiElement.getChildren(); if (children.length > 0 && hasSyntaxErrors(children[children.length - 1])) return true; diff --git a/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.kt b/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.kt new file mode 100644 index 00000000000..dd5e6721d8a --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.kt @@ -0,0 +1,34 @@ +package c + +fun z(view: () -> Unit) {} + +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } +fun x() = z { z { z { z { z { z { z { z { } } } } } } } } + +class x() {} + diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 3e61475106b..d8339459aa4 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -5202,6 +5202,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/resolve/resolveWithGenerics.kt"); } + @TestMetadata("resolveWithRedeclarationError.kt") + public void testResolveWithRedeclarationError() throws Exception { + doTest("compiler/testData/diagnostics/tests/resolve/resolveWithRedeclarationError.kt"); + } + @TestMetadata("resolveWithSpecifiedFunctionLiteralWithId.kt") public void testResolveWithSpecifiedFunctionLiteralWithId() throws Exception { doTest("compiler/testData/diagnostics/tests/resolve/resolveWithSpecifiedFunctionLiteralWithId.kt");