From ba49f508c980f15a7a217ba10c36a8c4e61ee927 Mon Sep 17 00:00:00 2001 From: svtk Date: Tue, 29 Nov 2011 19:04:15 +0400 Subject: [PATCH 01/17] KT-609 Analyze not only local variables, but function parameters as well in 'unused values' analysis --- .../jet/lang/cfg/JetControlFlowProcessor.java | 51 ++++++------ .../lang/cfg/JetFlowInformationProvider.java | 23 +++++- .../jet/lang/diagnostics/Errors.java | 5 +- .../UnusedElementDiagnosticFactory.java | 23 ++++++ .../jet/lang/resolve/BindingContextUtils.java | 4 + .../ExpressionTypingVisitorDispatcher.java | 6 +- .../jetbrains/jet/plugin/JetMainDetector.java | 23 +++--- compiler/testData/cfg/Basic.instructions | 32 +++++--- compiler/testData/cfg/Finally.instructions | 24 ++++-- compiler/testData/cfg/For.instructions | 6 +- compiler/testData/cfg/If.instructions | 62 +++++++------- .../testData/cfg/LazyBooleans.instructions | 80 ++++++++++--------- .../cfg/LocalDeclarations.instructions | 6 +- .../checkerWithErrorTypes/quick/Abstract.jet | 4 +- .../quick/AutoCreatedIt.jet | 12 +-- .../quick/AutocastsForStableIdentifiers.jet | 4 +- .../checkerWithErrorTypes/quick/Basic.jet | 2 +- .../quick/BinaryCallsOnNullableValues.jet | 6 +- .../quick/BreakContinue.jet | 4 +- .../quick/ConflictingOverloads.jet | 19 +++-- .../quick/DefaultValuesTypechecking.jet | 4 +- .../quick/ExtensionFunctions.jet | 18 ++--- .../quick/FunctionCalleeExpressions.jet | 2 +- .../quick/GenericFunctionIsLessSpecific.jet | 4 +- .../quick/InferNullabilityInThenBlock.jet | 6 +- .../quick/LValueAssignment.jet | 18 ++--- .../quick/NamedArgumentsAndDefaultValues.jet | 4 +- .../quick/ResolveOfJavaGenerics.jet | 10 +-- .../quick/ResolveToJava.jet | 4 +- .../checkerWithErrorTypes/quick/Super.jet | 2 +- .../quick/TypeInference.jet | 2 +- .../UninitializedOrReassignedVariables.jet | 12 +-- .../quick/UnreachableCode.jet | 8 +- .../quick/Unresolved.jet | 2 +- .../quick/UnusedVariables.jet | 6 +- .../checkerWithErrorTypes/quick/Varargs.jet | 6 +- .../checkerWithErrorTypes/quick/Variance.jet | 12 +-- .../InfixCallNullability.jet | 10 +-- .../AmbiguityOnLazyTypeComputation.jet | 6 +- .../quick/regressions/CoercionToUnit.jet | 2 +- .../ErrorsOnIbjectExpressionsAsParameters.jet | 2 +- .../quick/regressions/Jet124.jet | 4 +- .../quick/regressions/Jet169.jet | 4 +- .../quick/regressions/Jet69.jet | 4 +- .../quick/regressions/OutProjections.jet | 4 +- .../ScopeForSecondaryConstructors.jet | 2 +- .../regressions/SpecififcityByReceiver.jet | 2 +- .../regressions/WrongTraceInCallResolver.jet | 4 +- .../{ => control-flow-analysis}/kt510.jet | 0 .../{ => control-flow-analysis}/kt607.jet | 0 .../control-flow-analysis/kt609.jet | 19 +++++ .../{ => control-flow-analysis}/kt610.jet | 0 .../quick/regressions/kt127.jet | 6 +- .../quick/regressions/kt128.jet | 2 +- .../quick/regressions/kt235.jet | 10 +-- .../quick/regressions/kt258.jet | 2 +- .../quick/regressions/kt282.jet | 6 +- .../quick/regressions/kt287.jet | 4 +- .../quick/regressions/kt335.336.jet | 4 +- .../quick/regressions/kt352.jet | 2 +- .../quick/regressions/kt399.jet | 2 +- .../quick/regressions/kt411.jet | 2 +- .../quick/regressions/kt439.jet | 4 +- .../quick/regressions/kt442.jet | 2 +- .../quick/regressions/kt455.jet | 2 +- .../quick/regressions/kt459.jet | 2 +- .../quick/regressions/kt58.jet | 4 +- .../quick/regressions/kt618.jet | 12 +-- .../quick/regressions/kt629.jet | 2 +- .../ShadowParameterInFunctionBody.jet | 5 +- .../ShadowParameterInNestedBlockInFor.jet | 4 +- .../jet/checkers/CheckerTestUtilTest.java | 8 +- .../jet/plugin/annotations/JetPsiChecker.java | 2 +- idea/testData/checker/Abstract.jet | 2 +- .../checker/BinaryCallsOnNullableValues.jet | 6 +- idea/testData/checker/BreakContinue.jet | 2 +- idea/testData/checker/ExtensionFunctions.jet | 16 ++-- idea/testData/checker/ResolveToJava.jet | 2 +- idea/testData/checker/UnreachableCode.jet | 4 +- idea/testData/checker/Unresolved.jet | 2 +- idea/testData/checker/Variance.jet | 12 +-- .../AmbiguityOnLazyTypeComputation.jet | 4 +- .../checker/regression/CoercionToUnit.jet | 2 +- idea/testData/checker/regression/Jet124.jet | 4 +- idea/testData/checker/regression/Jet169.jet | 2 +- idea/testData/checker/regression/Jet69.jet | 2 +- .../ScopeForSecondaryConstructors.jet | 2 +- .../regression/SpecififcityByReceiver.jet | 2 +- .../regression/WrongTraceInCallResolver.jet | 4 +- 89 files changed, 412 insertions(+), 322 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/UnusedElementDiagnosticFactory.java rename compiler/testData/checkerWithErrorTypes/quick/regressions/{ => control-flow-analysis}/kt510.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/regressions/{ => control-flow-analysis}/kt607.jet (100%) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt609.jet rename compiler/testData/checkerWithErrorTypes/quick/regressions/{ => control-flow-analysis}/kt610.jet (100%) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java index f5bc5122eda..7b1945f9351 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java @@ -35,26 +35,30 @@ public class JetControlFlowProcessor { this.trace = trace; } - public void generate(@NotNull JetDeclaration subroutineElement, @NotNull JetExpression body) { - generateSubroutineControlFlow(subroutineElement, Collections.singletonList(body)); - } - - public void generateSubroutineControlFlow(@NotNull JetDeclaration subroutineElement, @NotNull List body) { - builder.enterSubroutine(subroutineElement); - for (JetElement statement : body) { - statement.accept(new CFPVisitor(false)); + public void generate(@NotNull JetDeclaration subroutine) { + builder.enterSubroutine(subroutine); + if (subroutine instanceof JetDeclarationWithBody) { + JetDeclarationWithBody declarationWithBody = (JetDeclarationWithBody) subroutine; + CFPVisitor cfpVisitor = new CFPVisitor(false); + List valueParameters = declarationWithBody.getValueParameters(); + for (JetParameter valueParameter : valueParameters) { + valueParameter.accept(cfpVisitor); + } + JetExpression bodyExpression = declarationWithBody.getBodyExpression(); + if (bodyExpression != null) { + bodyExpression.accept(cfpVisitor); + } } - builder.exitSubroutine(subroutineElement); + else { + subroutine.accept(new CFPVisitor(false)); + } + builder.exitSubroutine(subroutine); } - private void processLocalDeclaration(@NotNull JetDeclaration subroutineElement, @NotNull JetExpression body) { - processLocalDeclaration(subroutineElement, Collections.singletonList(body)); - } - - private void processLocalDeclaration(@NotNull JetDeclaration subroutineElement, @NotNull List body) { + private void processLocalDeclaration(@NotNull JetDeclaration subroutine) { Label afterDeclaration = builder.createUnboundLabel(); builder.nondeterministicJump(afterDeclaration); - generateSubroutineControlFlow(subroutineElement, body); + generate(subroutine); builder.bindLabel(afterDeclaration); } @@ -569,6 +573,12 @@ public class JetControlFlowProcessor { } } + @Override + public void visitParameter(JetParameter parameter) { + builder.declare(parameter); + builder.write(parameter, parameter); + } + @Override public void visitBlockExpression(JetBlockExpression expression) { List statements = expression.getStatements(); @@ -582,20 +592,13 @@ public class JetControlFlowProcessor { @Override public void visitNamedFunction(JetNamedFunction function) { - JetExpression bodyExpression = function.getBodyExpression(); - if (bodyExpression != null) { - processLocalDeclaration(function, bodyExpression); - } + processLocalDeclaration(function); } @Override public void visitFunctionLiteralExpression(JetFunctionLiteralExpression expression) { JetFunctionLiteral functionLiteral = expression.getFunctionLiteral(); - JetBlockExpression bodyExpression = functionLiteral.getBodyExpression(); - if (bodyExpression != null) { - List statements = bodyExpression.getStatements(); - processLocalDeclaration(functionLiteral, statements); - } + processLocalDeclaration(functionLiteral); builder.read(expression); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java index 7b8f6fc2b0b..4c260399c57 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java @@ -19,6 +19,7 @@ import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.types.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lexer.JetTokens; +import org.jetbrains.jet.plugin.JetMainDetector; import java.util.*; @@ -68,7 +69,7 @@ public class JetFlowInformationProvider { } }; JetControlFlowInstructionsGenerator instructionsGenerator = new JetControlFlowInstructionsGenerator(wrappedTrace); - new JetControlFlowProcessor(trace, instructionsGenerator).generate(declaration, bodyExpression); + new JetControlFlowProcessor(trace, instructionsGenerator).generate(declaration); wrappedTrace.close(); } @@ -479,13 +480,27 @@ public class JetFlowInformationProvider { } else if (instruction instanceof VariableDeclarationInstruction) { JetDeclaration element = ((VariableDeclarationInstruction) instruction).getVariableDeclarationElement(); - if (element instanceof JetProperty) { + if (element instanceof JetNamedDeclaration) { PsiElement nameIdentifier = ((JetNamedDeclaration) element).getNameIdentifier(); PsiElement elementToMark = nameIdentifier != null ? nameIdentifier : element; if (enterData.get(variableDescriptor) == VariableStatus.UNUSED) { - trace.report(Errors.UNUSED_VARIABLE.on((JetNamedDeclaration) element, elementToMark, variableDescriptor)); + if (element instanceof JetProperty) { + trace.report(Errors.UNUSED_VARIABLE.on((JetProperty) element, elementToMark, variableDescriptor)); + } + else if (element instanceof JetParameter) { + PsiElement psiElement = element.getParent().getParent(); + if (psiElement instanceof JetFunction) { + boolean isMain = (psiElement instanceof JetNamedFunction) && JetMainDetector.isMain((JetNamedFunction) psiElement); + DeclarationDescriptor descriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, psiElement); + assert descriptor instanceof FunctionDescriptor; + FunctionDescriptor functionDescriptor = (FunctionDescriptor) descriptor; + if (!isMain && !functionDescriptor.getModality().isOverridable() && functionDescriptor.getOverriddenDescriptors().isEmpty()) { + trace.report(Errors.UNUSED_PARAMETER.on((JetParameter) element, elementToMark, variableDescriptor)); + } + } + } } - else if (enterData.get(variableDescriptor) == VariableStatus.WRITTEN) { + else if (enterData.get(variableDescriptor) == VariableStatus.WRITTEN && element instanceof JetProperty) { trace.report(Errors.ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE.on((JetNamedDeclaration) element, elementToMark, variableDescriptor)); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java index fc8ce9013f2..786acc783b2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -147,8 +147,9 @@ public interface Errors { PsiElementOnlyDiagnosticFactory3 VIRTUAL_MEMBER_HIDDEN = PsiElementOnlyDiagnosticFactory3.create(ERROR, "''{0}'' hides ''{1}'' in class {2} and needs 'override' modifier", DescriptorRenderer.TEXT); PsiElementOnlyDiagnosticFactory1 UNINITIALIZED_VARIABLE = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Variable ''{0}'' must be initialized", NAME); - PsiElementOnlyDiagnosticFactory1 UNUSED_VARIABLE = PsiElementOnlyDiagnosticFactory1.create(WARNING, "Variable ''{0}'' is never used", NAME); - PsiElementOnlyDiagnosticFactory1 ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE = PsiElementOnlyDiagnosticFactory1.create(WARNING, "Variable ''{0}'' is assigned but never accessed", NAME); + UnusedElementDiagnosticFactory UNUSED_VARIABLE = UnusedElementDiagnosticFactory.create(WARNING, "Variable ''{0}'' is never used", NAME); + UnusedElementDiagnosticFactory UNUSED_PARAMETER = UnusedElementDiagnosticFactory.create(WARNING, "Parameter ''{0}'' is never used", NAME); + UnusedElementDiagnosticFactory ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE = UnusedElementDiagnosticFactory.create(WARNING, "Variable ''{0}'' is assigned but never accessed", NAME); PsiElementOnlyDiagnosticFactory2 UNUSED_VALUE = new PsiElementOnlyDiagnosticFactory2(WARNING, "The value ''{0}'' assigned to ''{1}'' is never used", NAME) { @Override protected String makeMessageForA(@NotNull JetElement element) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/UnusedElementDiagnosticFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/UnusedElementDiagnosticFactory.java new file mode 100644 index 00000000000..d47ea66728f --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/UnusedElementDiagnosticFactory.java @@ -0,0 +1,23 @@ +package org.jetbrains.jet.lang.diagnostics; + +import com.intellij.psi.PsiElement; +/** + * @author svtk + */ +public class UnusedElementDiagnosticFactory extends PsiElementOnlyDiagnosticFactory1 { + public static UnusedElementDiagnosticFactory create(Severity severity, String messageStub) { + return new UnusedElementDiagnosticFactory(severity, messageStub); + } + + public static UnusedElementDiagnosticFactory create(Severity severity, String messageStub, Renderer renderer) { + return new UnusedElementDiagnosticFactory(severity, messageStub, renderer); + } + + public UnusedElementDiagnosticFactory(Severity severity, String message, Renderer renderer) { + super(severity, message, renderer); + } + + protected UnusedElementDiagnosticFactory(Severity severity, String message) { + super(severity, message); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java index 4b24227c3cd..9635f3edafe 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java @@ -5,6 +5,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; +import org.jetbrains.jet.lang.descriptors.VariableAsFunctionDescriptor; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.types.JetType; @@ -43,6 +44,9 @@ public class BindingContextUtils { if (descriptor instanceof VariableDescriptor) { return (VariableDescriptor) descriptor; } + if (descriptor instanceof VariableAsFunctionDescriptor) { + return ((VariableAsFunctionDescriptor) descriptor).getVariableDescriptor(); + } return null; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.java index bdd82e73b85..36db4c054db 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.java @@ -1,7 +1,6 @@ package org.jetbrains.jet.lang.types.expressions; import com.intellij.lang.ASTNode; -import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.psi.*; @@ -14,7 +13,6 @@ import org.jetbrains.jet.lang.types.ErrorUtils; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.util.lazy.ReenteringLazyValueComputationException; -import static org.jetbrains.jet.lang.diagnostics.Errors.ELSE_MISPLACED_IN_WHEN; import static org.jetbrains.jet.lang.diagnostics.Errors.TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM; /** @@ -22,11 +20,9 @@ import static org.jetbrains.jet.lang.diagnostics.Errors.TYPECHECKER_HAS_RUN_INTO */ public class ExpressionTypingVisitorDispatcher extends JetVisitor implements ExpressionTypingInternals { - private static ExpressionTypingVisitorDispatcher BASIC_DISPATCHER = new ExpressionTypingVisitorDispatcher(null); - @NotNull public static ExpressionTypingFacade create() { - return BASIC_DISPATCHER; + return new ExpressionTypingVisitorDispatcher(null); } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/jet/plugin/JetMainDetector.java b/compiler/frontend/src/org/jetbrains/jet/plugin/JetMainDetector.java index ec98c2d8eff..9e9d285bd23 100644 --- a/compiler/frontend/src/org/jetbrains/jet/plugin/JetMainDetector.java +++ b/compiler/frontend/src/org/jetbrains/jet/plugin/JetMainDetector.java @@ -17,17 +17,20 @@ public class JetMainDetector { public static boolean hasMain(List declarations) { for (JetDeclaration declaration : declarations) { if (declaration instanceof JetNamedFunction) { - JetNamedFunction function = (JetNamedFunction) declaration; - if ("main".equals(function.getName())) { - List parameters = function.getValueParameters(); - if (parameters.size() == 1) { - JetTypeReference reference = parameters.get(0).getTypeReference(); - if (reference != null && reference.getText().equals("Array")) { // TODO correct check - return true; - } - } - } + if (isMain((JetNamedFunction) declaration)) return true; + } + } + return false; + } + public static boolean isMain(JetNamedFunction function) { + if ("main".equals(function.getName())) { + List parameters = function.getValueParameters(); + if (parameters.size() == 1) { + JetTypeReference reference = parameters.get(0).getTypeReference(); + if (reference != null && reference.getText().equals("Array")) { // TODO correct check + return true; + } } } return false; diff --git a/compiler/testData/cfg/Basic.instructions b/compiler/testData/cfg/Basic.instructions index e199fb184fe..970f555349b 100644 --- a/compiler/testData/cfg/Basic.instructions +++ b/compiler/testData/cfg/Basic.instructions @@ -31,8 +31,10 @@ fun f(a : Boolean) : Unit { } --------------------- l0: - NEXT:[r(1)] PREV:[] - r(1) NEXT:[r(a)] PREV:[] + NEXT:[v(a : Boolean)] PREV:[] + v(a : Boolean) NEXT:[w(a)] PREV:[] + w(a) NEXT:[r(1)] PREV:[v(a : Boolean)] + r(1) NEXT:[r(a)] PREV:[w(a)] r(a) NEXT:[r(2)] PREV:[r(1)] r(2) NEXT:[r(lng)] PREV:[r(a)] r(lng) NEXT:[r(2.lng)] PREV:[r(2)] @@ -92,14 +94,18 @@ sink: fun foo(a : Boolean, b : Int) : Unit {} --------------------- l0: - NEXT:[read (Unit)] PREV:[] - read (Unit) NEXT:[] PREV:[] + NEXT:[v(a : Boolean)] PREV:[] + v(a : Boolean) NEXT:[w(a)] PREV:[] + w(a) NEXT:[v(b : Int)] PREV:[v(a : Boolean)] + v(b : Int) NEXT:[w(b)] PREV:[w(a)] + w(b) NEXT:[read (Unit)] PREV:[v(b : Int)] + read (Unit) NEXT:[] PREV:[w(b)] l1: - NEXT:[] PREV:[read (Unit)] + NEXT:[] PREV:[read (Unit)] error: - NEXT:[] PREV:[] + NEXT:[] PREV:[] sink: - NEXT:[] PREV:[] + NEXT:[] PREV:[] ===================== == genfun == fun genfun() : Unit {} @@ -118,12 +124,14 @@ sink: fun flfun(f : fun () : Any) : Unit {} --------------------- l0: - NEXT:[read (Unit)] PREV:[] - read (Unit) NEXT:[] PREV:[] + NEXT:[v(f : fun () : Any)] PREV:[] + v(f : fun () : Any) NEXT:[w(f)] PREV:[] + w(f) NEXT:[read (Unit)] PREV:[v(f : fun () : Any)] + read (Unit) NEXT:[] PREV:[w(f)] l1: - NEXT:[] PREV:[read (Unit)] + NEXT:[] PREV:[read (Unit)] error: - NEXT:[] PREV:[] + NEXT:[] PREV:[] sink: - NEXT:[] PREV:[] + NEXT:[] PREV:[] ===================== diff --git a/compiler/testData/cfg/Finally.instructions b/compiler/testData/cfg/Finally.instructions index b8c3f5fdf29..74f7c7177c4 100644 --- a/compiler/testData/cfg/Finally.instructions +++ b/compiler/testData/cfg/Finally.instructions @@ -388,8 +388,10 @@ fun t8(a : Int) { } --------------------- l0: - NEXT:[r(1)] PREV:[] - r(1) NEXT:[r(a)] PREV:[] + NEXT:[v(a : Int)] PREV:[] + v(a : Int) NEXT:[w(a)] PREV:[] + w(a) NEXT:[r(1)] PREV:[v(a : Int)] + r(1) NEXT:[r(a)] PREV:[w(a)] r(a) NEXT:[r(..)] PREV:[r(1)] r(..) NEXT:[r(1..a)] PREV:[r(a)] r(1..a) NEXT:[v(i)] PREV:[r(..)] @@ -439,8 +441,10 @@ fun t9(a : Int) { } --------------------- l0: - NEXT:[r(1)] PREV:[] - r(1) NEXT:[r(a)] PREV:[] + NEXT:[v(a : Int)] PREV:[] + v(a : Int) NEXT:[w(a)] PREV:[] + w(a) NEXT:[r(1)] PREV:[v(a : Int)] + r(1) NEXT:[r(a)] PREV:[w(a)] r(a) NEXT:[r(..)] PREV:[r(1)] r(..) NEXT:[r(1..a)] PREV:[r(a)] r(1..a) NEXT:[v(i)] PREV:[r(..)] @@ -489,8 +493,10 @@ fun t10(a : Int) { } --------------------- l0: - NEXT:[r(1)] PREV:[] - r(1) NEXT:[r(a)] PREV:[] + NEXT:[v(a : Int)] PREV:[] + v(a : Int) NEXT:[w(a)] PREV:[] + w(a) NEXT:[r(1)] PREV:[v(a : Int)] + r(1) NEXT:[r(a)] PREV:[w(a)] r(a) NEXT:[r(..)] PREV:[r(1)] r(..) NEXT:[r(1..a)] PREV:[r(a)] r(1..a) NEXT:[v(i)] PREV:[r(..)] @@ -747,8 +753,10 @@ fun doSmth(i: Int) { } --------------------- l0: - NEXT:[read (Unit)] PREV:[] - read (Unit) NEXT:[] PREV:[] + NEXT:[v(i: Int)] PREV:[] + v(i: Int) NEXT:[w(i)] PREV:[] + w(i) NEXT:[read (Unit)] PREV:[v(i: Int)] + read (Unit) NEXT:[] PREV:[w(i)] l1: NEXT:[] PREV:[read (Unit)] error: diff --git a/compiler/testData/cfg/For.instructions b/compiler/testData/cfg/For.instructions index 7b782c13b55..6a8ceb0d916 100644 --- a/compiler/testData/cfg/For.instructions +++ b/compiler/testData/cfg/For.instructions @@ -34,8 +34,10 @@ sink: fun doSmth(i: Int) {} --------------------- l0: - NEXT:[read (Unit)] PREV:[] - read (Unit) NEXT:[] PREV:[] + NEXT:[v(i: Int)] PREV:[] + v(i: Int) NEXT:[w(i)] PREV:[] + w(i) NEXT:[read (Unit)] PREV:[v(i: Int)] + read (Unit) NEXT:[] PREV:[w(i)] l1: NEXT:[] PREV:[read (Unit)] error: diff --git a/compiler/testData/cfg/If.instructions b/compiler/testData/cfg/If.instructions index b188c60a1a4..5d3c31f3bc1 100644 --- a/compiler/testData/cfg/If.instructions +++ b/compiler/testData/cfg/If.instructions @@ -17,8 +17,10 @@ fun t1(b: Boolean) { } --------------------- l0: - NEXT:[v(var u: String)] PREV:[] - v(var u: String) NEXT:[r(b)] PREV:[] + NEXT:[v(b: Boolean)] PREV:[] + v(b: Boolean) NEXT:[w(b)] PREV:[] + w(b) NEXT:[v(var u: String)] PREV:[v(b: Boolean)] + v(var u: String) NEXT:[r(b)] PREV:[w(b)] r(b) NEXT:[jf(l2)] PREV:[v(var u: String)] jf(l2) NEXT:[read (Unit), r("s")] PREV:[r(b)] r("s") NEXT:[w(u)] PREV:[jf(l2)] @@ -63,45 +65,49 @@ fun t2(b: Boolean) { } --------------------- l0: - NEXT:[v(val i = 3)] PREV:[] - v(val i = 3) NEXT:[r(3)] PREV:[] - r(3) NEXT:[w(i)] PREV:[v(val i = 3)] - w(i) NEXT:[r(b)] PREV:[r(3)] - r(b) NEXT:[jf(l2)] PREV:[w(i)] - jf(l2) NEXT:[read (Unit), ret l1] PREV:[r(b)] - ret l1 NEXT:[] PREV:[jf(l2)] -* jmp(l3) NEXT:[r(i)] PREV:[] + NEXT:[v(b: Boolean)] PREV:[] + v(b: Boolean) NEXT:[w(b)] PREV:[] + w(b) NEXT:[v(val i = 3)] PREV:[v(b: Boolean)] + v(val i = 3) NEXT:[r(3)] PREV:[w(b)] + r(3) NEXT:[w(i)] PREV:[v(val i = 3)] + w(i) NEXT:[r(b)] PREV:[r(3)] + r(b) NEXT:[jf(l2)] PREV:[w(i)] + jf(l2) NEXT:[read (Unit), ret l1] PREV:[r(b)] + ret l1 NEXT:[] PREV:[jf(l2)] +* jmp(l3) NEXT:[r(i)] PREV:[] l2: - read (Unit) NEXT:[r(i)] PREV:[jf(l2)] + read (Unit) NEXT:[r(i)] PREV:[jf(l2)] l3: - r(i) NEXT:[r(doSmth)] PREV:[read (Unit)] - r(doSmth) NEXT:[r(doSmth(i))] PREV:[r(i)] - r(doSmth(i)) NEXT:[r(i)] PREV:[r(doSmth)] - r(i) NEXT:[r(i is Int)] PREV:[r(doSmth(i))] - r(i is Int) NEXT:[jf(l4)] PREV:[r(i)] - jf(l4) NEXT:[read (Unit), ret l1] PREV:[r(i is Int)] - ret l1 NEXT:[] PREV:[jf(l4)] -* jmp(l5) NEXT:[] PREV:[] + r(i) NEXT:[r(doSmth)] PREV:[read (Unit)] + r(doSmth) NEXT:[r(doSmth(i))] PREV:[r(i)] + r(doSmth(i)) NEXT:[r(i)] PREV:[r(doSmth)] + r(i) NEXT:[r(i is Int)] PREV:[r(doSmth(i))] + r(i is Int) NEXT:[jf(l4)] PREV:[r(i)] + jf(l4) NEXT:[read (Unit), ret l1] PREV:[r(i is Int)] + ret l1 NEXT:[] PREV:[jf(l4)] +* jmp(l5) NEXT:[] PREV:[] l4: - read (Unit) NEXT:[] PREV:[jf(l4)] + read (Unit) NEXT:[] PREV:[jf(l4)] l1: l5: - NEXT:[] PREV:[ret l1, ret l1, read (Unit)] + NEXT:[] PREV:[ret l1, ret l1, read (Unit)] error: - NEXT:[] PREV:[] + NEXT:[] PREV:[] sink: - NEXT:[] PREV:[] + NEXT:[] PREV:[] ===================== == doSmth == fun doSmth(s: String) {} --------------------- l0: - NEXT:[read (Unit)] PREV:[] - read (Unit) NEXT:[] PREV:[] + NEXT:[v(s: String)] PREV:[] + v(s: String) NEXT:[w(s)] PREV:[] + w(s) NEXT:[read (Unit)] PREV:[v(s: String)] + read (Unit) NEXT:[] PREV:[w(s)] l1: - NEXT:[] PREV:[read (Unit)] + NEXT:[] PREV:[read (Unit)] error: - NEXT:[] PREV:[] + NEXT:[] PREV:[] sink: - NEXT:[] PREV:[] + NEXT:[] PREV:[] ===================== diff --git a/compiler/testData/cfg/LazyBooleans.instructions b/compiler/testData/cfg/LazyBooleans.instructions index 080a7519745..f204026d0a0 100644 --- a/compiler/testData/cfg/LazyBooleans.instructions +++ b/compiler/testData/cfg/LazyBooleans.instructions @@ -18,57 +18,61 @@ fun lazyBooleans(a : Boolean, b : Boolean) : Unit { } --------------------- l0: - NEXT:[r(a)] PREV:[] - r(a) NEXT:[jf(l2)] PREV:[] - jf(l2) NEXT:[r(2), r(1)] PREV:[r(a)] - r(1) NEXT:[jmp(l3)] PREV:[jf(l2)] - jmp(l3) NEXT:[r(3)] PREV:[r(1)] + NEXT:[v(a : Boolean)] PREV:[] + v(a : Boolean) NEXT:[w(a)] PREV:[] + w(a) NEXT:[v(b : Boolean)] PREV:[v(a : Boolean)] + v(b : Boolean) NEXT:[w(b)] PREV:[w(a)] + w(b) NEXT:[r(a)] PREV:[v(b : Boolean)] + r(a) NEXT:[jf(l2)] PREV:[w(b)] + jf(l2) NEXT:[r(2), r(1)] PREV:[r(a)] + r(1) NEXT:[jmp(l3)] PREV:[jf(l2)] + jmp(l3) NEXT:[r(3)] PREV:[r(1)] l2: - r(2) NEXT:[r(3)] PREV:[jf(l2)] + r(2) NEXT:[r(3)] PREV:[jf(l2)] l3: - r(3) NEXT:[r(a)] PREV:[jmp(l3), r(2)] - r(a) NEXT:[jf(l4)] PREV:[r(3)] - jf(l4) NEXT:[jf(l5), r(b)] PREV:[r(a)] - r(b) NEXT:[jf(l5)] PREV:[jf(l4)] + r(3) NEXT:[r(a)] PREV:[jmp(l3), r(2)] + r(a) NEXT:[jf(l4)] PREV:[r(3)] + jf(l4) NEXT:[jf(l5), r(b)] PREV:[r(a)] + r(b) NEXT:[jf(l5)] PREV:[jf(l4)] l4: - jf(l5) NEXT:[r(6), r(5)] PREV:[jf(l4), r(b)] - r(5) NEXT:[jmp(l6)] PREV:[jf(l5)] - jmp(l6) NEXT:[r(7)] PREV:[r(5)] + jf(l5) NEXT:[r(6), r(5)] PREV:[jf(l4), r(b)] + r(5) NEXT:[jmp(l6)] PREV:[jf(l5)] + jmp(l6) NEXT:[r(7)] PREV:[r(5)] l5: - r(6) NEXT:[r(7)] PREV:[jf(l5)] + r(6) NEXT:[r(7)] PREV:[jf(l5)] l6: - r(7) NEXT:[r(a)] PREV:[jmp(l6), r(6)] - r(a) NEXT:[jt(l7)] PREV:[r(7)] - jt(l7) NEXT:[r(b), jf(l8)] PREV:[r(a)] - r(b) NEXT:[jf(l8)] PREV:[jt(l7)] + r(7) NEXT:[r(a)] PREV:[jmp(l6), r(6)] + r(a) NEXT:[jt(l7)] PREV:[r(7)] + jt(l7) NEXT:[r(b), jf(l8)] PREV:[r(a)] + r(b) NEXT:[jf(l8)] PREV:[jt(l7)] l7: - jf(l8) NEXT:[r(9), r(8)] PREV:[jt(l7), r(b)] - r(8) NEXT:[jmp(l9)] PREV:[jf(l8)] - jmp(l9) NEXT:[r(10)] PREV:[r(8)] + jf(l8) NEXT:[r(9), r(8)] PREV:[jt(l7), r(b)] + r(8) NEXT:[jmp(l9)] PREV:[jf(l8)] + jmp(l9) NEXT:[r(10)] PREV:[r(8)] l8: - r(9) NEXT:[r(10)] PREV:[jf(l8)] + r(9) NEXT:[r(10)] PREV:[jf(l8)] l9: - r(10) NEXT:[r(a)] PREV:[jmp(l9), r(9)] - r(a) NEXT:[jf(l10)] PREV:[r(10)] - jf(l10) NEXT:[read (Unit), r(11)] PREV:[r(a)] - r(11) NEXT:[jmp(l11)] PREV:[jf(l10)] - jmp(l11) NEXT:[r(12)] PREV:[r(11)] + r(10) NEXT:[r(a)] PREV:[jmp(l9), r(9)] + r(a) NEXT:[jf(l10)] PREV:[r(10)] + jf(l10) NEXT:[read (Unit), r(11)] PREV:[r(a)] + r(11) NEXT:[jmp(l11)] PREV:[jf(l10)] + jmp(l11) NEXT:[r(12)] PREV:[r(11)] l10: - read (Unit) NEXT:[r(12)] PREV:[jf(l10)] + read (Unit) NEXT:[r(12)] PREV:[jf(l10)] l11: - r(12) NEXT:[r(a)] PREV:[jmp(l11), read (Unit)] - r(a) NEXT:[jf(l12)] PREV:[r(12)] - jf(l12) NEXT:[r(13), read (Unit)] PREV:[r(a)] - read (Unit) NEXT:[jmp(l13)] PREV:[jf(l12)] - jmp(l13) NEXT:[r(14)] PREV:[read (Unit)] + r(12) NEXT:[r(a)] PREV:[jmp(l11), read (Unit)] + r(a) NEXT:[jf(l12)] PREV:[r(12)] + jf(l12) NEXT:[r(13), read (Unit)] PREV:[r(a)] + read (Unit) NEXT:[jmp(l13)] PREV:[jf(l12)] + jmp(l13) NEXT:[r(14)] PREV:[read (Unit)] l12: - r(13) NEXT:[r(14)] PREV:[jf(l12)] + r(13) NEXT:[r(14)] PREV:[jf(l12)] l13: - r(14) NEXT:[] PREV:[jmp(l13), r(13)] + r(14) NEXT:[] PREV:[jmp(l13), r(13)] l1: - NEXT:[] PREV:[r(14)] + NEXT:[] PREV:[r(14)] error: - NEXT:[] PREV:[] + NEXT:[] PREV:[] sink: - NEXT:[] PREV:[] + NEXT:[] PREV:[] ===================== diff --git a/compiler/testData/cfg/LocalDeclarations.instructions b/compiler/testData/cfg/LocalDeclarations.instructions index 94fabadf512..179ed5fe1d7 100644 --- a/compiler/testData/cfg/LocalDeclarations.instructions +++ b/compiler/testData/cfg/LocalDeclarations.instructions @@ -80,8 +80,10 @@ sink: fun doSmth(i: Int) {} --------------------- l0: - NEXT:[read (Unit)] PREV:[] - read (Unit) NEXT:[] PREV:[] + NEXT:[v(i: Int)] PREV:[] + v(i: Int) NEXT:[w(i)] PREV:[] + w(i) NEXT:[read (Unit)] PREV:[v(i: Int)] + read (Unit) NEXT:[] PREV:[w(i)] l1: NEXT:[] PREV:[read (Unit)] error: diff --git a/compiler/testData/checkerWithErrorTypes/quick/Abstract.jet b/compiler/testData/checkerWithErrorTypes/quick/Abstract.jet index a13891668c6..d36e7769f63 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/Abstract.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Abstract.jet @@ -237,7 +237,7 @@ abstract class B3(i: Int) { this(): this(1) } -fun foo(c: B3) { +fun foo(c: B3) { val a = B3() val b = B1(2, "s") -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/AutoCreatedIt.jet b/compiler/testData/checkerWithErrorTypes/quick/AutoCreatedIt.jet index ef474b07d54..b9aa7b90c6b 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/AutoCreatedIt.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/AutoCreatedIt.jet @@ -15,18 +15,18 @@ fun text() { bar2 {it => it} } -fun bar(f : fun (Int, Int) : Int) {} -fun bar1(f : fun (Int) : Int) {} -fun bar2(f : fun () : Int) {} +fun bar(f : fun (Int, Int) : Int) {} +fun bar1(f : fun (Int) : Int) {} +fun bar2(f : fun () : Int) {} -fun String.to(dest : String) { +fun String.to(dest : String) { } -fun String.on(predicate : fun (s : URI) : Boolean) : URI { +fun String.on(predicate : fun (s : URI) : Boolean) : URI { return URI(this) } class URI(val body : Any) { - fun to(dest : String) {} + fun to(dest : String) {} } \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/AutocastsForStableIdentifiers.jet b/compiler/testData/checkerWithErrorTypes/quick/AutocastsForStableIdentifiers.jet index c46164e8c73..f6ccdfc8a0a 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/AutocastsForStableIdentifiers.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/AutocastsForStableIdentifiers.jet @@ -16,7 +16,7 @@ class AClass() { val x : Any? = 1 -fun Any?.vars(a: Any?) : Int { +fun Any?.vars(a: Any?) : Int { var b: Int = 0 if (ns.y is Int) { b = ns.y @@ -88,4 +88,4 @@ open class C { t = this@C } } -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/Basic.jet b/compiler/testData/checkerWithErrorTypes/quick/Basic.jet index 82775571c83..4dc3161b26a 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/Basic.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Basic.jet @@ -1,4 +1,4 @@ -fun foo(u : Unit) : Int = 1 +fun foo(u : Unit) : Int = 1 fun test() : Int { foo(1) diff --git a/compiler/testData/checkerWithErrorTypes/quick/BinaryCallsOnNullableValues.jet b/compiler/testData/checkerWithErrorTypes/quick/BinaryCallsOnNullableValues.jet index 5394c137aae..f32efe534f1 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/BinaryCallsOnNullableValues.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/BinaryCallsOnNullableValues.jet @@ -1,13 +1,13 @@ class A() { - fun equals(a : Any?) : Boolean = false + fun equals(a : Any?) : Boolean = false } class B() { - fun equals(a : Any?) : Boolean? = false + fun equals(a : Any?) : Boolean? = false } class C() { - fun equals(a : Any?) : Int = 0 + fun equals(a : Any?) : Int = 0 } fun f(): Unit { diff --git a/compiler/testData/checkerWithErrorTypes/quick/BreakContinue.jet b/compiler/testData/checkerWithErrorTypes/quick/BreakContinue.jet index 1cecda9dae9..4502e880282 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/BreakContinue.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/BreakContinue.jet @@ -1,6 +1,6 @@ class C { - fun f (a : Boolean, b : Boolean) { + fun f (a : Boolean, b : Boolean) { @b (while (true) @a { break@f @@ -25,7 +25,7 @@ class C { break@f } - fun containsBreak(a: String?, b: String?) { + fun containsBreak(a: String?, b: String?) { while (a == null) { break; } diff --git a/compiler/testData/checkerWithErrorTypes/quick/ConflictingOverloads.jet b/compiler/testData/checkerWithErrorTypes/quick/ConflictingOverloads.jet index b1055124354..6f13050d3ae 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/ConflictingOverloads.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ConflictingOverloads.jet @@ -1,9 +1,9 @@ // http://youtrack.jetbrains.net/issue/KT-424 class A { - fun a(a: Int): Int = 0 + fun a(a: Int): Int = 0 - fun a(a: Int) { + fun a(a: Int) { } fun b() { @@ -14,17 +14,17 @@ class A { } namespace deepSpace { - fun c(s: String) { + fun c(s: String) { } - fun c(s: String) { + fun c(s: String) { } class B { - fun d(s: String) { + fun d(s: String) { } - fun d(s: String) { + fun d(s: String) { } } } @@ -49,9 +49,9 @@ namespace ns3 { // check same rules apply for ext functions namespace extensionFunctions { - fun Int.qwe(a: Float) = 1 + fun Int.qwe(a: Float) = 1 - fun Int.qwe(a: Float) = 2 + fun Int.qwe(a: Float) = 2 fun Int.rty() = 3 @@ -94,5 +94,4 @@ namespace constructorVsFun { class ololo() { } } } -} - +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/DefaultValuesTypechecking.jet b/compiler/testData/checkerWithErrorTypes/quick/DefaultValuesTypechecking.jet index 55df425bc64..67d360888da 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/DefaultValuesTypechecking.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/DefaultValuesTypechecking.jet @@ -1,5 +1,5 @@ val x = "" -fun bar(x : Int = "", y : Int = x, z : String = y) { +fun bar(x : Int = "", y : Int = x, z : String = y) { -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/ExtensionFunctions.jet b/compiler/testData/checkerWithErrorTypes/quick/ExtensionFunctions.jet index 245be61e735..e7e3c1cebf4 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/ExtensionFunctions.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ExtensionFunctions.jet @@ -3,7 +3,7 @@ fun Int?.optint() : Unit {} val Int?.optval : Unit = () -fun T.foo(x : E, y : A) : T { +fun T.foo(x : E, y : A) : T { y.plus(1) y plus 1 y + 1.0 @@ -15,7 +15,7 @@ fun T.foo(x : E, y : A) : T { class A -fun A.plus(a : Any) { +fun A.plus(a : Any) { 1.foo() true.foo() @@ -23,11 +23,11 @@ fun A.plus(a : Any) { 1 } -fun A.plus(a : Int) { +fun A.plus(a : Int) { 1 } -fun T.minus(t : T) : Int = 1 +fun T.minus(t : T) : Int = 1 fun test() { val y = 1.abs @@ -41,15 +41,15 @@ fun Int.foo() = this namespace null_safety { - fun parse(cmd: String): Command? { return null } + fun parse(cmd: String): Command? { return null } class Command() { // fun equals(other : Any?) : Boolean val foo : Int = 0 } - fun Any.equals(other : Any?) : Boolean = true - fun Any?.equals1(other : Any?) : Boolean = true - fun Any.equals2(other : Any?) : Boolean = true + fun Any.equals(other : Any?) : Boolean = true + fun Any?.equals1(other : Any?) : Boolean = true + fun Any.equals2(other : Any?) : Boolean = true fun main(args: Array) { @@ -70,4 +70,4 @@ namespace null_safety { if (command == null) 1 } -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/FunctionCalleeExpressions.jet b/compiler/testData/checkerWithErrorTypes/quick/FunctionCalleeExpressions.jet index 15acd8ec22c..5e6ef793f1d 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/FunctionCalleeExpressions.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/FunctionCalleeExpressions.jet @@ -51,7 +51,7 @@ fun main(args : Array) { fun f() : fun Int.() : Unit = {} -fun main1(args : Array) { +fun main1() { 1.{Int.() => 1}(); {1}() {(x : Int) => x}(1) diff --git a/compiler/testData/checkerWithErrorTypes/quick/GenericFunctionIsLessSpecific.jet b/compiler/testData/checkerWithErrorTypes/quick/GenericFunctionIsLessSpecific.jet index 308a3cd08c0..868937e8397 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/GenericFunctionIsLessSpecific.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/GenericFunctionIsLessSpecific.jet @@ -1,6 +1,6 @@ // A generic funciton is always less specific than a non-generic one -fun foo(t : T) : Unit {} -fun foo(i : Int) : Int = 1 +fun foo(t : T) : Unit {} +fun foo(i : Int) : Int = 1 fun test() { foo(1) : Int diff --git a/compiler/testData/checkerWithErrorTypes/quick/InferNullabilityInThenBlock.jet b/compiler/testData/checkerWithErrorTypes/quick/InferNullabilityInThenBlock.jet index 4925867c8c6..17a21679c79 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/InferNullabilityInThenBlock.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/InferNullabilityInThenBlock.jet @@ -1,5 +1,4 @@ - -fun ff(a: String) = 1 +fun ff(a: String) = 1 fun gg() { val a: String? = "" @@ -7,5 +6,4 @@ fun gg() { if (a != null) { ff(a) } -} - +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/LValueAssignment.jet b/compiler/testData/checkerWithErrorTypes/quick/LValueAssignment.jet index fd3796e1ffd..e9551afa2fd 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/LValueAssignment.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/LValueAssignment.jet @@ -7,7 +7,7 @@ open class B() { class C() : B() { var x = 4 - fun foo(c: C) { + fun foo(c: C) { this.x = 34 this.b = 123 super.b = 23 @@ -17,7 +17,7 @@ class C() : B() { getInt() = 12 } - fun foo1(c: C) { + fun foo1(c: C) { super.c = 34 } @@ -36,7 +36,7 @@ class D() { } } -fun cannotBe(var i: Int) { +fun cannotBe(var i: Int) { z = 30; () = (); @@ -47,18 +47,18 @@ fun cannotBe(var i: Int) { } fun canBe(var i: Int, val j: Int) { - (i: Int) = 36 - (@label i) = 34 + (i: Int) = 36 + (@label i) = 34 - (j: Int) = 36 - (@label j) = 34 //repeat for j + (j: Int) = 36 + (@label j) = 34 //repeat for j val a = A() (@ a.a) = 3894 } fun canBe2(val j: Int) { - (@label j) = 34 + (@label j) = 34 } class A() { @@ -140,4 +140,4 @@ fun Array.checkThis() { abstract class Ab { abstract fun getArray() : Array -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/NamedArgumentsAndDefaultValues.jet b/compiler/testData/checkerWithErrorTypes/quick/NamedArgumentsAndDefaultValues.jet index f1d42c6b60d..8f9476575d4 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/NamedArgumentsAndDefaultValues.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/NamedArgumentsAndDefaultValues.jet @@ -1,7 +1,7 @@ -fun foo(a : Int = 1, b : String = "abc") { +fun foo(a : Int = 1, b : String = "abc") { } -fun bar(x : Int = 1, y : Int = 1, z : String) { +fun bar(x : Int = 1, y : Int = 1, z : String) { } fun test() { diff --git a/compiler/testData/checkerWithErrorTypes/quick/ResolveOfJavaGenerics.jet b/compiler/testData/checkerWithErrorTypes/quick/ResolveOfJavaGenerics.jet index 2353e215293..ae44ace8caf 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/ResolveOfJavaGenerics.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ResolveOfJavaGenerics.jet @@ -1,7 +1,7 @@ // +JDK // Fixpoint generic in Java: Enum> -fun test(a : annotation.RetentionPolicy) { +fun test(a : annotation.RetentionPolicy) { } @@ -9,14 +9,14 @@ fun test() { java.util.Collections.emptyList() } -fun test(a : java.lang.Comparable) { +fun test(a : java.lang.Comparable) { } -fun test(a : java.util.ArrayList) { +fun test(a : java.util.ArrayList) { } -fun test(a : java.lang.Class) { +fun test(a : java.lang.Class) { -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/ResolveToJava.jet b/compiler/testData/checkerWithErrorTypes/quick/ResolveToJava.jet index d404b2365ba..ff4d34b1cf7 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/ResolveToJava.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ResolveToJava.jet @@ -9,7 +9,7 @@ import java.lang.Comparable as Com val l : List = ArrayList() -fun test(l : java.util.List) { +fun test(l : java.util.List) { val x : java.List val y : java.util.List val b : java.lang.Object @@ -51,4 +51,4 @@ fun test(l : java.util.List) { namespace xxx { import java.lang.Class; -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/Super.jet b/compiler/testData/checkerWithErrorTypes/quick/Super.jet index 7a3095d820f..ca3fff3dc9e 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/Super.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Super.jet @@ -1,6 +1,6 @@ namespace example; -fun any(a : Any) {} +fun any(a : Any) {} fun notAnExpression() { any(super) // not an expression diff --git a/compiler/testData/checkerWithErrorTypes/quick/TypeInference.jet b/compiler/testData/checkerWithErrorTypes/quick/TypeInference.jet index 5f35e4d98a5..4dd8649fff0 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/TypeInference.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/TypeInference.jet @@ -2,7 +2,7 @@ class C() { fun foo() : T {} } -fun foo(c: C) {} +fun foo(c: C) {} fun bar() : C {} fun main(args : Array) { diff --git a/compiler/testData/checkerWithErrorTypes/quick/UninitializedOrReassignedVariables.jet b/compiler/testData/checkerWithErrorTypes/quick/UninitializedOrReassignedVariables.jet index f1bbe6de43b..593d34b02c4 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/UninitializedOrReassignedVariables.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/UninitializedOrReassignedVariables.jet @@ -1,7 +1,7 @@ namespace uninitialized_reassigned_variables -fun doSmth(s: String) {} -fun doSmth(i: Int) {} +fun doSmth(s: String) {} +fun doSmth(i: Int) {} // ------------------------------------------------ // uninitialized variables @@ -54,9 +54,9 @@ fun t2() { class A() {} fun t4(a: A, val b: A, var c: A) { - a = A() - b = A() - c = A() + a = A() + b = A() + c = A() } // ------------------------------------------------ @@ -191,7 +191,7 @@ class AnonymousInitializers(var a: String, val b: String) { } fun reassignFunParams(val a: Int) { - a = 1 + a = 1 } open class Open(a: Int, w: Int) {} diff --git a/compiler/testData/checkerWithErrorTypes/quick/UnreachableCode.jet b/compiler/testData/checkerWithErrorTypes/quick/UnreachableCode.jet index 36bfd0e8925..088bba18e54 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/UnreachableCode.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/UnreachableCode.jet @@ -47,7 +47,7 @@ fun t3() : Any { 1 } -fun t4(a : Boolean) : Int { +fun t4(a : Boolean) : Int { do { return 1 } @@ -55,7 +55,7 @@ fun t4(a : Boolean) : Int { 1 } -fun t4break(a : Boolean) : Int { +fun t4break(a : Boolean) : Int { do { break } @@ -162,7 +162,7 @@ fun nullIsNotNothing() : Unit { fail() } -fun returnInWhile(a: Int) { +fun returnInWhile(a: Int) { do {return} while (1 > a) -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/Unresolved.jet b/compiler/testData/checkerWithErrorTypes/quick/Unresolved.jet index a13dae7809b..b5b6018377d 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/Unresolved.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Unresolved.jet @@ -28,4 +28,4 @@ fun testUnresolved() { } } -fun foo1(i: Int) {} \ No newline at end of file +fun foo1(i: Int) {} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/UnusedVariables.jet b/compiler/testData/checkerWithErrorTypes/quick/UnusedVariables.jet index dd23f8a97d6..060ad3f83a4 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/UnusedVariables.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/UnusedVariables.jet @@ -86,8 +86,8 @@ class MyTest() { } } - fun doSmth(s: String) {} - fun doSmth(a: Any) {} + fun doSmth(s: String) {} + fun doSmth(a: Any) {} } fun testInnerFunctions() { @@ -139,4 +139,4 @@ fun testBackingFieldsNotMarked() { } } -fun doSmth(i : Int) {} +fun doSmth(i : Int) {} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/Varargs.jet b/compiler/testData/checkerWithErrorTypes/quick/Varargs.jet index 7904791df5a..5986ce0982d 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/Varargs.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Varargs.jet @@ -1,5 +1,5 @@ -fun v(x : Int, y : String, vararg f : Long) {} -fun v1(vararg f : fun (Int) : Unit) {} +fun v(x : Int, y : String, vararg f : Long) {} +fun v1(vararg f : fun (Int) : Unit) {} fun test() { v(1, "") @@ -14,4 +14,4 @@ fun test() { v1({}, {}, {it}) v1({}) {} v1 {} -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/Variance.jet b/compiler/testData/checkerWithErrorTypes/quick/Variance.jet index 1306c251f00..8785dfd87cb 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/Variance.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Variance.jet @@ -19,17 +19,17 @@ fun foo(c: Consumer, p: Producer, u: Usual) { //Arrays copy example class Array(val length : Int, val t : T) { - fun get(index : Int) : T { return t } - fun set(index : Int, value : T) { /* ... */ } + fun get(index : Int) : T { return t } + fun set(index : Int, value : T) { /* ... */ } } -fun copy1(from : Array, to : Array) {} +fun copy1(from : Array, to : Array) {} -fun copy2(from : Array, to : Array) {} +fun copy2(from : Array, to : Array) {} -fun copy3(from : Array, to : Array) {} +fun copy3(from : Array, to : Array) {} -fun copy4(from : Array, to : Array) {} +fun copy4(from : Array, to : Array) {} fun f(ints: Array, any: Array, numbers: Array) { copy1(ints, any) diff --git a/compiler/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/InfixCallNullability.jet b/compiler/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/InfixCallNullability.jet index d27f6834a73..e1eb592bc2e 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/InfixCallNullability.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/nullabilityAndAutoCasts/InfixCallNullability.jet @@ -1,11 +1,11 @@ class A() { - fun plus(i : Int) {} + fun plus(i : Int) {} fun minus() {} - fun contains(a : Any?) : Boolean = true + fun contains(a : Any?) : Boolean = true } -fun A.div(i : Int) {} -fun A?.times(i : Int) {} +fun A.div(i : Int) {} +fun A?.times(i : Int) {} fun test(x : Int?, a : A?) { x.plus(1) @@ -38,4 +38,4 @@ fun test(x : Int?, a : A?) { a contains 1 a.contains(1) a?.contains(1) -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/AmbiguityOnLazyTypeComputation.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/AmbiguityOnLazyTypeComputation.jet index 779ee4c4d97..cdced141c6a 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/AmbiguityOnLazyTypeComputation.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/AmbiguityOnLazyTypeComputation.jet @@ -7,6 +7,6 @@ val b : Foo = Foo() val a1 = b.compareTo(2) class Foo() { - fun compareTo(other : Byte) : Int = 0 - fun compareTo(other : Char) : Int = 0 -} + fun compareTo(other : Byte) : Int = 0 + fun compareTo(other : Char) : Int = 0 +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/CoercionToUnit.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/CoercionToUnit.jet index 6ce84f8c66b..765036145b7 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/CoercionToUnit.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/CoercionToUnit.jet @@ -1,4 +1,4 @@ -fun foo(u : Unit) : Int = 1 +fun foo(u : Unit) : Int = 1 fun test() : Int { foo(1) diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/ErrorsOnIbjectExpressionsAsParameters.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/ErrorsOnIbjectExpressionsAsParameters.jet index 75432316689..e5c2de37d80 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/ErrorsOnIbjectExpressionsAsParameters.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/ErrorsOnIbjectExpressionsAsParameters.jet @@ -1,4 +1,4 @@ -fun foo(a : Any) {} +fun foo(a : Any) {} fun test() { foo(object {}); diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet124.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet124.jet index 58e876a80f2..317b1438f41 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet124.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet124.jet @@ -1,8 +1,8 @@ fun foo1() : fun (Int) : Int = { (x: Int) => x } fun foo() { - val h : fun (Int) : Int = foo1(); + val h : fun (Int) : Int = foo1(); h(1) - val m : fun (Int) : Int = {(a : Int) => 1}//foo1() + val m : fun (Int) : Int = {(a : Int) => 1}//foo1() m(1) } \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet169.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet169.jet index 000536ce340..c0196a2543d 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet169.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet169.jet @@ -1,8 +1,8 @@ -fun set(key : String, value : String) { +fun set(key : String, value : String) { val a : String? = "" when (a) { "" => a.get(0) is String, is Any => a.compareTo("") else => a.toString() } -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet69.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet69.jet index dd198aa0f61..9e8c5fa83dd 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet69.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet69.jet @@ -1,10 +1,10 @@ class Command() {} -fun parse(cmd: String): Command? { return null } +fun parse(cmd: String): Command? { return null } fun Any.equals(other : Any?) : Boolean = this === other fun main(args: Array) { val command = parse("") if (command == null) 1 // error on this line, but must be OK -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/OutProjections.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/OutProjections.jet index f6c32d8f776..224e6decd93 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/OutProjections.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/OutProjections.jet @@ -3,7 +3,7 @@ class Point() { class G() {} -fun f(expression : T) : G = G +fun f(expression : T) : G = G fun foo() : G { @@ -13,7 +13,7 @@ fun foo() : G { class Out() {} -fun fout(expression : T) : Out = Out +fun fout(expression : T) : Out = Out fun fooout() : Out { val p = Point(); diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/ScopeForSecondaryConstructors.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/ScopeForSecondaryConstructors.jet index 31212378979..ae4bc37dabe 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/ScopeForSecondaryConstructors.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/ScopeForSecondaryConstructors.jet @@ -8,7 +8,7 @@ class Foo(var bar : Int, var barr : Int, var barrr : Int) { } this(var bar : Int) : this(1, 1, 1) { - bar = 1 + bar = 1 this.bar 1 : Int val a : Int =1 diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/SpecififcityByReceiver.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/SpecififcityByReceiver.jet index bbca53527c8..e0ea1063e56 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/SpecififcityByReceiver.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/SpecififcityByReceiver.jet @@ -1,4 +1,4 @@ -fun Any.equals(other : Any?) : Boolean = true +fun Any.equals(other : Any?) : Boolean = true fun main(args: Array) { diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/WrongTraceInCallResolver.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/WrongTraceInCallResolver.jet index 952ac6c3dbe..c81f9324b71 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/WrongTraceInCallResolver.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/WrongTraceInCallResolver.jet @@ -1,8 +1,8 @@ open class Foo {} open class Bar {} -fun foo(x : Int) {} -fun foo(x : Long) {} +fun foo(x : Int) {} +fun foo(x : Long) {} fun f(): Unit { foo<Int, Int>(1) diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt510.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt510.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regressions/kt510.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt510.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt607.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt607.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regressions/kt607.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt607.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt609.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt609.jet new file mode 100644 index 00000000000..56f75e247e2 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt609.jet @@ -0,0 +1,19 @@ +//KT-609 Analyze not only local variables, but function parameters as well in 'unused values' analysis + +namespace kt609 + +fun test(var a: Int) { + a = 324 //should be an 'unused value' warning here +} + +class C() { + fun foo(s: String) {} //should be an 'unused variable' warning +} + +open class A() { + open fun foo(s : String) {} //should not be a warning +} + +class B() : A() { + final override fun foo(s : String) {} //should not be a warning +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt610.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt610.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regressions/kt610.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/control-flow-analysis/kt610.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt127.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt127.jet index 19ad92b2d52..edb6f1b6d7f 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt127.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt127.jet @@ -2,8 +2,8 @@ class Foo() {} -fun Any.equals(other : Any?) : Boolean = true -fun Any?.equals1(other : Any?) : Boolean = true +fun Any.equals(other : Any?) : Boolean = true +fun Any?.equals1(other : Any?) : Boolean = true fun main(args: Array) { @@ -15,4 +15,4 @@ fun main(args: Array) { // ?.equals(null) => 1 // same here // } command.equals(null) -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt128.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt128.jet index efc005cf183..ca9b223cd02 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt128.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt128.jet @@ -1,6 +1,6 @@ // KT-128 Support passing only the last closure if all the other parameters have default values -fun div(c : String = "", f : fun()) {} +fun div(c : String = "", f : fun()) {} fun f() { div { // Nothing passed, but could have been... // ... diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet index c5a96d7c961..0f0c33183a5 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet @@ -36,15 +36,15 @@ fun main(args: Array) { } class MyArray() { - fun get(i: Int): Int = 1 - fun set(i: Int, value: Int): Int = 1 + fun get(i: Int): Int = 1 + fun set(i: Int, value: Int): Int = 1 } class MyArray1() { - fun get(i: Int): Int = 1 - fun set(i: Int, value: Int) {} + fun get(i: Int): Int = 1 + fun set(i: Int, value: Int) {} } class MyNumber() { fun inc(): MyNumber = MyNumber() -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt258.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt258.jet index 00b7e9696d4..eb77de9e665 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt258.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt258.jet @@ -8,4 +8,4 @@ fun test() { attributes["href"] = "1" // inference fails, but it shouldn't } -fun java.util.Map.set(key : K, value : V) {}//= this.put(key, value) +fun java.util.Map.set(key : K, value : V) {}//= this.put(key, value) \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt282.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt282.jet index bd6d55ce380..b9c3a16196d 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt282.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt282.jet @@ -1,12 +1,12 @@ // KT-282 Nullability in extension functions and in binary calls class Set { - fun contains(x : Int) : Boolean = true + fun contains(x : Int) : Boolean = true } -fun Set?.plus(x : Int) : Int = 1 +fun Set?.plus(x : Int) : Int = 1 -fun Int?.contains(x : Int) : Boolean = false +fun Int?.contains(x : Int) : Boolean = false fun f(): Unit { var set : Set? = null diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt287.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt287.jet index 69d2d526fb0..15cf0100499 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt287.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt287.jet @@ -6,8 +6,8 @@ import java.util.* fun attributes() : Map = HashMap() // Should be inferred; val attributes : Map = HashMap() // Should be inferred; -fun foo(m : Map) {} +fun foo(m : Map) {} fun test() { foo(HashMap()) -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt335.336.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt335.336.jet index e874d8f005d..a9007627a23 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt335.336.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt335.336.jet @@ -9,7 +9,7 @@ fun > List.sort() { Collections.sort(this) // Error here } -fun List.plus(other : List) : List { +fun List.plus(other : List) : List { val result = ArrayList(this) return result -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt352.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt352.jet index e9b4eb34e94..74f9ddecdb0 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt352.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt352.jet @@ -18,7 +18,7 @@ val g : fun() : Unit = { (): Int => 42 } val h : fun() : Unit = { doSmth() } fun doSmth(): Int = 42 -fun doSmth(a: String) {} +fun doSmth(a: String) {} val testIt : fun(Any) : Unit = { if (it is String) { diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt399.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt399.jet index 9fd7e71c393..3c52df4cc6e 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt399.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt399.jet @@ -1,6 +1,6 @@ // KT-399 Type argument inference not implemented for CALL_EXPRESSION -fun getSameTypeChecker(obj: T) : Function1 { +fun getSameTypeChecker(obj: T) : Function1 { return { (a : Any) => a is T } } diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt411.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt411.jet index 5d724d405da..0828b9a4efd 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt411.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt411.jet @@ -9,7 +9,7 @@ fun f() { } ) } -fun invoker(gen : fun() : Int) : Int = 0 +fun invoker(gen : fun() : Int) : Int = 0 //more tests fun t1() { diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt439.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt439.jet index a914cc023c5..176e3280e18 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt439.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt439.jet @@ -2,6 +2,6 @@ inline fun run1(body : fun() : T) : T = body() -fun main1(args : Array) { +fun main1(args : Array) { run1 @l{ 1 } // should not be an error -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt442.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt442.jet index 79390466a35..0618918b14a 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt442.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt442.jet @@ -6,7 +6,7 @@ fun testFunny() { val a : Int = funny {1} } -fun funny2(f : fun(t : T) : T) : T {} +fun funny2(f : fun(t : T) : T) : T {} fun testFunny2() { val a : Int = funny2 {it} diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt455.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt455.jet index d8d20b06265..0db1c1c4ae9 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt455.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt455.jet @@ -7,4 +7,4 @@ fun foo() { doSmth(a) //error doSmth(a) //no repeat error } -fun doSmth(i: Int) {} +fun doSmth(i: Int) {} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt459.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt459.jet index faa62212f38..930e9e76670 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt459.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt459.jet @@ -6,4 +6,4 @@ fun test() { attributes["href"] = "1" // inference fails, but it shouldn't } -fun java.util.Map.set(key : K, value : V) {}//= this.put(key, value) +fun java.util.Map.set(key : K, value : V) {}//= this.put(key, value) \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt58.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt58.jet index 57562a61f37..d6a0e64456f 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt58.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt58.jet @@ -88,5 +88,5 @@ fun t7() : Int { } } -fun doSmth(i: Int) { -} +fun doSmth(i: Int) { +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt618.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt618.jet index 569d286c17b..f70f921730e 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt618.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt618.jet @@ -1,19 +1,19 @@ namespace lol class B() { - fun plusAssign(other : B) : String { + fun plusAssign(other : B) : String { return "s" } - fun minusAssign(other : B) : String { + fun minusAssign(other : B) : String { return "s" } - fun modAssign(other : B) : String { + fun modAssign(other : B) : String { return "s" } - fun divAssign(other : B) : String { + fun divAssign(other : B) : String { return "s" } - fun timesAssign(other : B) : String { + fun timesAssign(other : B) : String { return "s" } } @@ -25,4 +25,4 @@ fun main(args : Array) { c /= B() c -= B() c %= B() -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt629.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt629.jet index f9a92abc839..3d52542ad7f 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt629.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt629.jet @@ -4,7 +4,7 @@ namespace kt629 class A() { var p = "yeah" - fun mod(other : A) : A { + fun mod(other : A) : A { return A(); } } diff --git a/compiler/testData/checkerWithErrorTypes/quick/shadowing/ShadowParameterInFunctionBody.jet b/compiler/testData/checkerWithErrorTypes/quick/shadowing/ShadowParameterInFunctionBody.jet index 3f99c1e45bb..943e005359e 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/shadowing/ShadowParameterInFunctionBody.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/shadowing/ShadowParameterInFunctionBody.jet @@ -1,5 +1,4 @@ - -fun f(p: Int): Int { +fun f(p: Int): Int { val p = 2 return p -} +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/shadowing/ShadowParameterInNestedBlockInFor.jet b/compiler/testData/checkerWithErrorTypes/quick/shadowing/ShadowParameterInNestedBlockInFor.jet index e3e91fbe857..303434c77a1 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/shadowing/ShadowParameterInNestedBlockInFor.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/shadowing/ShadowParameterInNestedBlockInFor.jet @@ -1,7 +1,7 @@ -fun f(i: Int) { +fun f(i: Int) { for (j in 1..100) { { var i = 12 } } -} +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java b/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java index cdf385d3158..13258e0d505 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java +++ b/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java @@ -39,7 +39,7 @@ public class CheckerTestUtilTest extends JetLiteFixture { doTest(new TheTest("Missing TYPE_MISMATCH at 56 to 57") { @Override protected void makeTestData(List diagnostics, List diagnosedRanges) { - diagnostics.remove(0); + diagnostics.remove(1); } }); } @@ -48,7 +48,7 @@ public class CheckerTestUtilTest extends JetLiteFixture { doTest(new TheTest("Unexpected TYPE_MISMATCH at 56 to 57") { @Override protected void makeTestData(List diagnostics, List diagnosedRanges) { - diagnosedRanges.remove(0); + diagnosedRanges.remove(1); } }); } @@ -57,7 +57,7 @@ public class CheckerTestUtilTest extends JetLiteFixture { doTest(new TheTest("Unexpected TYPE_MISMATCH at 56 to 57", "Missing UNRESOLVED_REFERENCE at 166 to 168") { @Override protected void makeTestData(List diagnostics, List diagnosedRanges) { - diagnosedRanges.remove(0); + diagnosedRanges.remove(1); diagnostics.remove(diagnostics.size() - 1); } }); @@ -67,7 +67,7 @@ public class CheckerTestUtilTest extends JetLiteFixture { doTest(new TheTest("Unexpected NONE_APPLICABLE at 122 to 123", "Missing TYPE_MISMATCH at 161 to 169") { @Override protected void makeTestData(List diagnostics, List diagnosedRanges) { - diagnosedRanges.remove(3); + diagnosedRanges.remove(4); diagnostics.remove(diagnostics.size() - 3); } }); diff --git a/idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java b/idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java index 5dfb0bd94e4..cb7e36c4a98 100644 --- a/idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java +++ b/idea/src/org/jetbrains/jet/plugin/annotations/JetPsiChecker.java @@ -88,7 +88,7 @@ public class JetPsiChecker implements Annotator { } else if (diagnostic.getSeverity() == Severity.WARNING) { annotation = holder.createWarningAnnotation(diagnostic.getFactory().getTextRange(diagnostic), getMessage(diagnostic)); - if (diagnostic.getFactory() == Errors.UNUSED_VARIABLE || diagnostic.getFactory() == Errors.ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE) { + if (diagnostic.getFactory() instanceof UnusedElementDiagnosticFactory) { annotation.setHighlightType(ProblemHighlightType.LIKE_UNUSED_SYMBOL); } } diff --git a/idea/testData/checker/Abstract.jet b/idea/testData/checker/Abstract.jet index 4c34620c5e5..b9ad43da2c2 100644 --- a/idea/testData/checker/Abstract.jet +++ b/idea/testData/checker/Abstract.jet @@ -160,7 +160,7 @@ abstract class B3(i: Int) { this(): this(1) } -fun foo(a: B3) { +fun foo(a: B3) { val a = B3() val b = B1(2, "s") } \ No newline at end of file diff --git a/idea/testData/checker/BinaryCallsOnNullableValues.jet b/idea/testData/checker/BinaryCallsOnNullableValues.jet index a66c709b010..31186881eea 100644 --- a/idea/testData/checker/BinaryCallsOnNullableValues.jet +++ b/idea/testData/checker/BinaryCallsOnNullableValues.jet @@ -1,13 +1,13 @@ class A() { - fun equals(a : Any?) : Boolean = false + fun equals(a : Any?) : Boolean = false } class B() { - fun equals(a : Any?) : Boolean? = false + fun equals(a : Any?) : Boolean? = false } class C() { - fun equals(a : Any?) : Int = 0 + fun equals(a : Any?) : Int = 0 } fun f(): Unit { diff --git a/idea/testData/checker/BreakContinue.jet b/idea/testData/checker/BreakContinue.jet index de5243502d8..f7e34060980 100644 --- a/idea/testData/checker/BreakContinue.jet +++ b/idea/testData/checker/BreakContinue.jet @@ -1,6 +1,6 @@ class C { - fun f (a : Boolean, b : Boolean) { + fun f (a : Boolean, b : Boolean) { @b (while (true) @a { break@f diff --git a/idea/testData/checker/ExtensionFunctions.jet b/idea/testData/checker/ExtensionFunctions.jet index 3fd3dcffbfb..4076cdfff62 100644 --- a/idea/testData/checker/ExtensionFunctions.jet +++ b/idea/testData/checker/ExtensionFunctions.jet @@ -1,7 +1,7 @@ fun Int?.optint() : Unit {} val Int?.optval : Unit = () -fun T.foo(x : E, y : A) : T { +fun T.foo(x : E, y : A) : T { y.plus(1) y plus 1 y + 1.0 @@ -13,7 +13,7 @@ fun T.foo(x : E, y : A) : T { class A -fun A.plus(a : Any) { +fun A.plus(a : Any) { 1.foo() true.foo() @@ -21,11 +21,11 @@ fun A.plus(a : Any) { 1 } -fun A.plus(a : Int) { +fun A.plus(a : Int) { 1 } -fun T.minus(t : T) : Int = 1 +fun T.minus(t : T) : Int = 1 fun test() { val y = 1.abs @@ -39,15 +39,15 @@ fun Int.foo() = this namespace null_safety { - fun parse(cmd: String): Command? { return null } + fun parse(cmd: String): Command? { return null } class Command() { // fun equals(other : Any?) : Boolean val foo : Int = 0 } - fun Any.equals(other : Any?) : Boolean = true - fun Any?.equals1(other : Any?) : Boolean = true - fun Any.equals2(other : Any?) : Boolean = true + fun Any.equals(other : Any?) : Boolean = true + fun Any?.equals1(other : Any?) : Boolean = true + fun Any.equals2(other : Any?) : Boolean = true fun main(args: Array) { diff --git a/idea/testData/checker/ResolveToJava.jet b/idea/testData/checker/ResolveToJava.jet index 17eafa7b2d8..e8cb67fceb3 100644 --- a/idea/testData/checker/ResolveToJava.jet +++ b/idea/testData/checker/ResolveToJava.jet @@ -7,7 +7,7 @@ import java.lang.Comparable as Com val l : List = ArrayList() -fun test(l : java.util.List) { +fun test(l : java.util.List) { val x : java.List val y : java.util.List val b : java.lang.Object diff --git a/idea/testData/checker/UnreachableCode.jet b/idea/testData/checker/UnreachableCode.jet index 15ba14178fc..3fdd4ffe9df 100644 --- a/idea/testData/checker/UnreachableCode.jet +++ b/idea/testData/checker/UnreachableCode.jet @@ -45,7 +45,7 @@ fun t3() : Any { 1 } -fun t4(a : Boolean) : Int { +fun t4(a : Boolean) : Int { do { return 1 } @@ -53,7 +53,7 @@ fun t4(a : Boolean) : Int { 1 } -fun t4break(a : Boolean) : Int { +fun t4break(a : Boolean) : Int { do { break } diff --git a/idea/testData/checker/Unresolved.jet b/idea/testData/checker/Unresolved.jet index 159fe931f0b..a4b85b6b54a 100644 --- a/idea/testData/checker/Unresolved.jet +++ b/idea/testData/checker/Unresolved.jet @@ -28,4 +28,4 @@ fun testUnresolved() { } } -fun foo1(i: Int) {} +fun foo1(i: Int) {} diff --git a/idea/testData/checker/Variance.jet b/idea/testData/checker/Variance.jet index da4384f88bb..756214a3145 100644 --- a/idea/testData/checker/Variance.jet +++ b/idea/testData/checker/Variance.jet @@ -19,17 +19,17 @@ fun foo(c: Consumer, p: Producer, u: Usual) { //Arrays copy example class Array(val length : Int, val t : T) { - fun get(index : Int) : T { return t } - fun set(index : Int, value : T) { /* ... */ } + fun get(index : Int) : T { return t } + fun set(index : Int, value : T) { /* ... */ } } -fun copy1(from : Array, to : Array) {} +fun copy1(from : Array, to : Array) {} -fun copy2(from : Array, to : Array) {} +fun copy2(from : Array, to : Array) {} -fun copy3(from : Array, to : Array) {} +fun copy3(from : Array, to : Array) {} -fun copy4(from : Array, to : Array) {} +fun copy4(from : Array, to : Array) {} fun f(ints: Array, any: Array, numbers: Array) { copy1(ints, any) diff --git a/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.jet b/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.jet index 779ee4c4d97..813be88472a 100644 --- a/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.jet +++ b/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.jet @@ -7,6 +7,6 @@ val b : Foo = Foo() val a1 = b.compareTo(2) class Foo() { - fun compareTo(other : Byte) : Int = 0 - fun compareTo(other : Char) : Int = 0 + fun compareTo(other : Byte) : Int = 0 + fun compareTo(other : Char) : Int = 0 } diff --git a/idea/testData/checker/regression/CoercionToUnit.jet b/idea/testData/checker/regression/CoercionToUnit.jet index ec8c8e32275..f02143657f7 100644 --- a/idea/testData/checker/regression/CoercionToUnit.jet +++ b/idea/testData/checker/regression/CoercionToUnit.jet @@ -1,4 +1,4 @@ -fun foo(u : Unit) : Int = 1 +fun foo(u : Unit) : Int = 1 fun test() : Int { foo(1) diff --git a/idea/testData/checker/regression/Jet124.jet b/idea/testData/checker/regression/Jet124.jet index 48aa4644dea..317b1438f41 100644 --- a/idea/testData/checker/regression/Jet124.jet +++ b/idea/testData/checker/regression/Jet124.jet @@ -1,8 +1,8 @@ fun foo1() : fun (Int) : Int = { (x: Int) => x } fun foo() { - val h : fun (Int) : Int = foo1(); + val h : fun (Int) : Int = foo1(); h(1) - val m : fun (Int) : Int = {(a : Int) => 1}//foo1() + val m : fun (Int) : Int = {(a : Int) => 1}//foo1() m(1) } \ No newline at end of file diff --git a/idea/testData/checker/regression/Jet169.jet b/idea/testData/checker/regression/Jet169.jet index 2bed1f918f3..0ba52f8e3cb 100644 --- a/idea/testData/checker/regression/Jet169.jet +++ b/idea/testData/checker/regression/Jet169.jet @@ -1,4 +1,4 @@ -fun set(key : String, value : String) { +fun set(key : String, value : String) { val a : String? = "" when (a) { "" => a.get(0) diff --git a/idea/testData/checker/regression/Jet69.jet b/idea/testData/checker/regression/Jet69.jet index dd198aa0f61..346a98fd25a 100644 --- a/idea/testData/checker/regression/Jet69.jet +++ b/idea/testData/checker/regression/Jet69.jet @@ -1,6 +1,6 @@ class Command() {} -fun parse(cmd: String): Command? { return null } +fun parse(cmd: String): Command? { return null } fun Any.equals(other : Any?) : Boolean = this === other diff --git a/idea/testData/checker/regression/ScopeForSecondaryConstructors.jet b/idea/testData/checker/regression/ScopeForSecondaryConstructors.jet index f4516941508..84c59da5a8a 100644 --- a/idea/testData/checker/regression/ScopeForSecondaryConstructors.jet +++ b/idea/testData/checker/regression/ScopeForSecondaryConstructors.jet @@ -8,7 +8,7 @@ } this(var bar : Int) : this(1, 1, 1) { - bar = 1 + bar = 1 this.bar 1 : Int val a : Int =1 diff --git a/idea/testData/checker/regression/SpecififcityByReceiver.jet b/idea/testData/checker/regression/SpecififcityByReceiver.jet index b25f919e597..67d6776baba 100644 --- a/idea/testData/checker/regression/SpecififcityByReceiver.jet +++ b/idea/testData/checker/regression/SpecififcityByReceiver.jet @@ -1,4 +1,4 @@ -fun Any.equals(other : Any?) : Boolean = true +fun Any.equals(other : Any?) : Boolean = true fun main(args: Array) { diff --git a/idea/testData/checker/regression/WrongTraceInCallResolver.jet b/idea/testData/checker/regression/WrongTraceInCallResolver.jet index 2c88d2450dd..30af5e2d8e8 100644 --- a/idea/testData/checker/regression/WrongTraceInCallResolver.jet +++ b/idea/testData/checker/regression/WrongTraceInCallResolver.jet @@ -1,8 +1,8 @@ open class Foo {} open class Bar {} -fun foo(x : Int) {} -fun foo(x : Long) {} +fun foo(x : Int) {} +fun foo(x : Long) {} fun f(): Unit { foo<Int, Int>(1) From 8a93421ecbe35887c7c001e1dd1759c0e1d014b5 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 29 Nov 2011 21:03:42 +0300 Subject: [PATCH 02/17] KT-597 Type inference failed Resolution rules changed: now autocast and non-autocast candidates are judged together --- .../lang/resolve/calls/TaskPrioritizer.java | 16 ++------------- .../calls/autocasts/AutoCastServiceImpl.java | 5 ++++- .../calls/autocasts/AutoCastUtils.java | 3 +++ .../resolve/calls/autocasts/DataFlowInfo.java | 2 +- .../quick/regressions/kt597.jet | 20 +++++++++++++++++++ idea/testData/checker/infos/Autocasts.jet | 2 +- 6 files changed, 31 insertions(+), 17 deletions(-) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt597.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.java index 823666d4ed2..89989f037c9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/TaskPrioritizer.java @@ -64,20 +64,8 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor scope = explicitReceiver.getType().getMemberScope(); explicitReceiver = NO_RECEIVER; } - doComputeTasks(scope, explicitReceiver, call, name, result, AutoCastService.NO_AUTO_CASTS); + doComputeTasks(scope, explicitReceiver, call, name, result, new AutoCastServiceImpl(dataFlowInfo, bindingContext)); - List receivers; - if (explicitReceiver.exists()) { - receivers = Collections.singletonList(explicitReceiver); - } - else { - receivers = Lists.newArrayList(); - scope.getImplicitReceiversHierarchy(receivers); - } - for (ReceiverDescriptor receiverToCast : receivers) { - assert receiverToCast.exists(); - doComputeTasks(scope, receiverToCast, call, name, result, new AutoCastServiceImpl(dataFlowInfo, bindingContext)); - } return result; } @@ -87,7 +75,7 @@ import static org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor scope.getImplicitReceiversHierarchy(implicitReceivers); if (receiver.exists()) { List variantsForExplicitReceiver = autoCastService.getVariantsForReceiver(receiver); - + Collection> extensionFunctions = convertWithImpliedThis(scope, variantsForExplicitReceiver, getExtensionsByName(scope, name)); List> nonlocals = Lists.newArrayList(); List> locals = Lists.newArrayList(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastServiceImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastServiceImpl.java index 5789419b22e..dbc350798d1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastServiceImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastServiceImpl.java @@ -1,5 +1,6 @@ package org.jetbrains.jet.lang.resolve.calls.autocasts; +import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; @@ -21,7 +22,9 @@ public class AutoCastServiceImpl implements AutoCastService { @NotNull @Override public List getVariantsForReceiver(@NotNull ReceiverDescriptor receiverDescriptor) { - return AutoCastUtils.getAutoCastVariants(bindingContext, dataFlowInfo, receiverDescriptor); + List variants = Lists.newArrayList(AutoCastUtils.getAutoCastVariants(bindingContext, dataFlowInfo, receiverDescriptor)); + variants.add(receiverDescriptor); + return variants; } @NotNull diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.java index e1b62313964..44bf37380a2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/AutoCastUtils.java @@ -17,6 +17,9 @@ public class AutoCastUtils { private AutoCastUtils() {} + /** + * @return variants @param receiverToCast may be cast to according to @param dataFlowInfo, @param receiverToCast itself is NOT included + */ public static List getAutoCastVariants(@NotNull final BindingContext bindingContext, @NotNull final DataFlowInfo dataFlowInfo, @NotNull ReceiverDescriptor receiverToCast) { return receiverToCast.accept(new ReceiverDescriptorVisitor, Object>() { @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java index f1148ec21d2..fb3b2db7e4a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/autocasts/DataFlowInfo.java @@ -102,7 +102,7 @@ public class DataFlowInfo { boolean changed = false; changed |= putNullability(builder, a, nullabilityOfA.refine(nullabilityOfB.invert())); - changed |= putNullability(builder, b, nullabilityOfA.refine(nullabilityOfA.invert())); + changed |= putNullability(builder, b, nullabilityOfB.refine(nullabilityOfA.invert())); return changed ? new DataFlowInfo(ImmutableMap.copyOf(builder), typeInfo) : this; } diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt597.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt597.jet new file mode 100644 index 00000000000..bb32c636edb --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt597.jet @@ -0,0 +1,20 @@ +//KT-597 Type inference failed +// +JDK + +fun Array?.get(i: Int) : T { + if (this != null) + return this.get(i) // <- inferred type is Any? but &T was excepted + else throw NullPointerException() +} + +fun Int?.inc() : Int { + if (this != null) + return this.inc() + else + throw NullPointerException() +} + +fun test() { + var i : Int? = 10 + var i_inc = i++ // <- expected Int?, but returns Any? +} \ No newline at end of file diff --git a/idea/testData/checker/infos/Autocasts.jet b/idea/testData/checker/infos/Autocasts.jet index d2acba03849..a5b716d9c05 100644 --- a/idea/testData/checker/infos/Autocasts.jet +++ b/idea/testData/checker/infos/Autocasts.jet @@ -216,7 +216,7 @@ fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is Str fun mergeAutocasts(a: Any?) { if (a is String || a is Int) { a.compareTo("") - a.toString() + a.toString() } if (a is Int || a is String) { a.compareTo("") From dd4cc1686dbbde20f16fb70990912061249f19d4 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 29 Nov 2011 22:11:42 +0300 Subject: [PATCH 03/17] Tests for recently fixed bugs --- .../checkerWithErrorTypes/quick/regressions/kt174.jet | 8 ++++++++ .../checkerWithErrorTypes/quick/regressions/kt201.jet | 9 +++++++++ .../checkerWithErrorTypes/quick/regressions/kt312.jet | 10 ++++++++++ 3 files changed, 27 insertions(+) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt174.jet create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt201.jet create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt312.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt174.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt174.jet new file mode 100644 index 00000000000..ea04148db1b --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt174.jet @@ -0,0 +1,8 @@ +// KT-174 Nullability info for extension function receivers +// +JDK +trait Tree {} + +fun Any?.TreeValue() : Tree { + if (this is Tree) return this + throw Exception() +} diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt201.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt201.jet new file mode 100644 index 00000000000..4791e550b3e --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt201.jet @@ -0,0 +1,9 @@ +// KT-201 Allow to call extension with nullable receiver with a '.' +// +JDK + +fun T?.npe() : T = if (this == null) throw NullPointerException() else this + +fun foo() { + val i : Int? = 1 + i.npe() // error! +} \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt312.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt312.jet new file mode 100644 index 00000000000..6701b24dbef --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt312.jet @@ -0,0 +1,10 @@ +// KT-312 Nullability problem when a nullable version of a generic type is returned + +fun Array.safeGet(index : Int) : T? { + return if (index < size) this[index] else null +} + +val args : Array = Array(1) +val name : String = args.safeGet(0) // No error, must be type mismatch +val name1 : String? = args.safeGet(0) + From be29dd9155879b7279a0e69c399c70bc4f4a6d05 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 29 Nov 2011 22:14:16 +0300 Subject: [PATCH 04/17] Test for kt-524 --- .../quick/regressions/kt524.jet | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt524.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt524.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt524.jet new file mode 100644 index 00000000000..9ffcd1f564a --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt524.jet @@ -0,0 +1,17 @@ +// KT-524 sure() returns T +// +JDK + +namespace StringBuilder + +import java.lang.StringBuilder + +//import std.io.* +//import java.io.* + +fun main(args : Array) { +} + +val Int.bd : StringBuilder get() = StringBuilder(this.toString()) +fun StringBuilder.plus(other : StringBuilder) : StringBuilder = this.append(other).sure1() // !!! + +fun T?.sure1() : T { return if (this != null) this else throw NullPointerException() } From 291f508edc5ee468cf8d07b3fb636634260b953b Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 29 Nov 2011 22:14:31 +0300 Subject: [PATCH 05/17] KT-604 Internal frontend error --- .../descriptors/FunctionDescriptorUtil.java | 4 ++-- .../VariableAsFunctionDescriptor.java | 2 +- .../jet/lang/resolve/calls/CallResolver.java | 2 +- .../quick/regressions/kt604.jet | 20 +++++++++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt604.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java index 6c88e27e448..e4bc91d4854 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java @@ -83,10 +83,10 @@ public class FunctionDescriptorUtil { return parameterScope; } - public static void initializeFromFunctionType(@NotNull FunctionDescriptorImpl functionDescriptor, @NotNull JetType functionType) { + public static void initializeFromFunctionType(@NotNull FunctionDescriptorImpl functionDescriptor, @NotNull JetType functionType, @NotNull ReceiverDescriptor expectedThisObject) { assert JetStandardClasses.isFunctionType(functionType); functionDescriptor.initialize(JetStandardClasses.getReceiverType(functionType), - ReceiverDescriptor.NO_RECEIVER, + expectedThisObject, Collections.emptyList(), JetStandardClasses.getValueParameters(functionDescriptor, functionType), JetStandardClasses.getReturnTypeFromFunctionType(functionType), diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.java index fb9b6fcabae..59670106531 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableAsFunctionDescriptor.java @@ -14,7 +14,7 @@ public class VariableAsFunctionDescriptor extends FunctionDescriptorImpl { JetType outType = variableDescriptor.getOutType(); assert outType != null; VariableAsFunctionDescriptor result = new VariableAsFunctionDescriptor(variableDescriptor); - FunctionDescriptorUtil.initializeFromFunctionType(result, outType); + FunctionDescriptorUtil.initializeFromFunctionType(result, outType, variableDescriptor.getExpectedThisObject()); return result; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index 68effdfba5e..8a5bf13be62 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -185,7 +185,7 @@ public class CallResolver { } FunctionDescriptorImpl functionDescriptor = new ExpressionAsFunctionDescriptor(scope.getContainingDeclaration(), "[for expression " + calleeExpression.getText() + "]"); - FunctionDescriptorUtil.initializeFromFunctionType(functionDescriptor, calleeType); + FunctionDescriptorUtil.initializeFromFunctionType(functionDescriptor, calleeType, NO_RECEIVER); ResolvedCallImpl resolvedCall = ResolvedCallImpl.create(functionDescriptor); resolvedCall.setReceiverArgument(call.getExplicitReceiver()); prioritizedTasks = Collections.singletonList(new ResolutionTask( diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt604.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt604.jet new file mode 100644 index 00000000000..02f079e6900 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt604.jet @@ -0,0 +1,20 @@ +// KT-604 Internal frontend error + +trait ChannelPipeline { + +} + +class DefaultChannelPipeline() : ChannelPipeline { +} + +trait ChannelPipelineFactory{ + fun getPipeline() : ChannelPipeline +} + +class StandardPipelineFactory(val config: fun ChannelPipeline.():Unit) : ChannelPipelineFactory { + override fun getPipeline() : ChannelPipeline { + val pipeline = DefaultChannelPipeline() + pipeline.config () + return pipeline + } +} From e9a9562efa4f84c895c6c0563fde47bfd6108528 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 29 Nov 2011 22:16:13 +0300 Subject: [PATCH 06/17] Test for KT-398 Internal error when property initializes with function --- .../checkerWithErrorTypes/quick/regressions/kt398.jet | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt398.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt398.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt398.jet new file mode 100644 index 00000000000..1babedaf8f4 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt398.jet @@ -0,0 +1,11 @@ +// KT-398 Internal error when property initializes with function + +class X() { + val check = { (a : Any) => a is T } +} + +fun box() : String { + if(X().check(10)) return "fail" + if(!X().check("lala")) return "fail" + return "OK" +} \ No newline at end of file From 60214b4f59c3ebc8ceebed7cb221f0bd002c742e Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 30 Nov 2011 02:42:56 +0400 Subject: [PATCH 07/17] safer PropertyDescriptor.getOutType() Add @NotNull annotation because getOutType must not return null for PropertyDescriptor --- .../jet/lang/descriptors/PropertyDescriptor.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java index 361eb70fbb4..27768fa2b22 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java @@ -118,6 +118,16 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab return getOutType(); } + @Override + public JetType getInType() { + return super.getInType(); + } + + @Override + @NotNull + public JetType getOutType() { + return super.getOutType(); + } public boolean isVar() { return isVar; From d984f6c4b8af8e6d359f366e0908ed83866ca86e Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 30 Nov 2011 02:43:24 +0400 Subject: [PATCH 08/17] make DeclarationDescriptor.toString safe DescriptionRenderer may throw if this is not yet completely initialized It is very inconvenient while debugging --- .../jet/lang/descriptors/DeclarationDescriptorImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java index defab1eca28..e3614e3f356 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/DeclarationDescriptorImpl.java @@ -46,6 +46,12 @@ public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements @Override public String toString() { - return DescriptorRenderer.TEXT.render(this) + "[" + getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this)) + "]"; + try { + return DescriptorRenderer.TEXT.render(this) + "[" + getClass().getSimpleName() + "@" + Integer.toHexString(System.identityHashCode(this)) + "]"; + } catch (Throwable e) { + // DescriptionRenderer may throw if this is not yet completely initialized + // It is very inconvenient while debugging + return super.toString(); + } } } From 72777733cdc50146b9a979af0a2687d86515a849 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 30 Nov 2011 02:48:20 +0400 Subject: [PATCH 09/17] validate field names in JetScope (field name must start with dollar sign) --- .../jet/lang/resolve/scopes/WritableScopeImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java index 37de89a17ca..ed1febfd63a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java @@ -299,11 +299,19 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addPropertyDescriptorByFieldName(@NotNull String fieldName, @NotNull PropertyDescriptor propertyDescriptor) { + if (!fieldName.startsWith("$")) { + throw new IllegalStateException(); + } + getPropertyDescriptorsByFieldNames().put(fieldName, propertyDescriptor); } @Override public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) { + if (!fieldName.startsWith("$")) { + throw new IllegalStateException(); + } + PropertyDescriptor descriptor = getPropertyDescriptorsByFieldNames().get(fieldName); if (descriptor != null) return descriptor; return super.getPropertyByFieldReference(fieldName); From 52dc3bb7bb4b00cfbd8cc57da662fea7c6b2c703 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 30 Nov 2011 02:52:52 +0400 Subject: [PATCH 10/17] idea settings --- .idea/inspectionProfiles/idea_default.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml index 1dfe9e84ad8..497bd6ace93 100644 --- a/.idea/inspectionProfiles/idea_default.xml +++ b/.idea/inspectionProfiles/idea_default.xml @@ -340,6 +340,11 @@ + + From 1866a245faefa5284718181b802ea17efb8323e1 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 30 Nov 2011 02:44:17 +0400 Subject: [PATCH 11/17] WritableScope.changeLockLevel() There are thress lock levels: reading, writing, both. Scope modification is not allowed in "reading" and scope data access is not allowed in "writing". --- .../descriptors/FunctionDescriptorUtil.java | 1 + .../descriptors/MutableClassDescriptor.java | 13 +++++ .../jet/lang/resolve/AnalyzingUtils.java | 1 + .../jet/lang/resolve/BodyResolver.java | 4 ++ .../jet/lang/resolve/DescriptorResolver.java | 11 ++++- .../jet/lang/resolve/TopDownAnalyzer.java | 10 ++++ .../lang/resolve/TypeHierarchyResolver.java | 5 +- .../lang/resolve/scopes/WritableScope.java | 8 +++ .../resolve/scopes/WritableScopeImpl.java | 49 +++++++++++++++++++ .../scopes/WritableScopeWithImports.java | 46 +++++++++++++++++ .../resolve/scopes/WriteThroughScope.java | 44 +++++++++++++++++ .../jet/lang/types/JetStandardClasses.java | 2 + .../jet/lang/types/JetStandardLibrary.java | 2 + .../expressions/ExpressionTypingServices.java | 1 + .../expressions/ExpressionTypingUtils.java | 5 +- .../JetDefaultModalityModifiersTest.java | 2 + .../jet/types/JetTypeCheckerTest.java | 3 ++ 17 files changed, 203 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java index e4bc91d4854..8208b807e8f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java @@ -80,6 +80,7 @@ public class FunctionDescriptorUtil { parameterScope.addVariableDescriptor(valueParameterDescriptor); } parameterScope.addLabeledDeclaration(descriptor); + parameterScope.changeLockLevel(WritableScope.LockLevel.READING); return parameterScope; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java index 669af46b9ae..525a8d93d05 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java @@ -49,8 +49,11 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme super(containingDeclaration); TraceBasedRedeclarationHandler redeclarationHandler = new TraceBasedRedeclarationHandler(trace); this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler).setDebugName("MemberLookup"); + this.scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.BOTH); this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler).setDebugName("SupertypeResolution"); + this.scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.BOTH); this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler).setDebugName("MemberResolution"); + this.scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.BOTH); this.kind = kind; } @@ -180,6 +183,7 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme this.typeParameters.add(typeParameterDescriptor); scopeForSupertypeResolution.addTypeParameterDescriptor(typeParameterDescriptor); } + scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -344,4 +348,13 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme } return implicitReceiver; } + + public void lockScopes() { + scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING); + scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.READING); + scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING); + if (classObjectDescriptor != null) { + classObjectDescriptor.lockScopes(); + } + } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java index da5cb3020b5..13cb17841bc 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java @@ -96,6 +96,7 @@ public class AnalyzingUtils { final WritableScope scope = new WritableScopeImpl(JetScope.EMPTY, owner, new TraceBasedRedeclarationHandler(bindingTraceContext)).setDebugName("Root scope in analyzeNamespace"); importingStrategy.addImports(project, semanticServices, bindingTraceContext, scope); scope.importScope(libraryScope); + scope.changeLockLevel(WritableScope.LockLevel.BOTH); TopDownAnalyzer.process(semanticServices, bindingTraceContext, scope, new NamespaceLike.Adapter(owner) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java index dd45fdd7af9..eeab159c182 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java @@ -382,6 +382,8 @@ public class BodyResolver { } constructorScope.addLabeledDeclaration(descriptor); // TODO : Labels for constructors?! + + constructorScope.changeLockLevel(WritableScope.LockLevel.READING); return constructorScope; } @@ -442,6 +444,7 @@ public class BodyResolver { if (receiver.exists()) { result.setImplicitReceiver(receiver); } + result.changeLockLevel(WritableScope.LockLevel.READING); return result; } @@ -450,6 +453,7 @@ public class BodyResolver { WritableScope accessorScope = new WritableScopeImpl(getPropertyDeclarationInnerScope(declaringScope, propertyDescriptor), declaringScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Accessor scope"); accessorScope.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor); + accessorScope.changeLockLevel(WritableScope.LockLevel.READING); JetPropertyAccessor getter = property.getGetter(); PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java index 8be709898fd..8cf81b34574 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java @@ -146,6 +146,7 @@ public class DescriptorResolver { innerScope.addLabeledDeclaration(functionDescriptor); List typeParameterDescriptors = resolveTypeParameters(functionDescriptor, innerScope, function.getTypeParameters()); + innerScope.changeLockLevel(WritableScope.LockLevel.BOTH); resolveGenericBounds(function, innerScope, typeParameterDescriptors); JetType receiverType = null; @@ -157,8 +158,10 @@ public class DescriptorResolver { : scope; receiverType = typeResolver.resolveType(scopeForReceiver, receiverTypeRef); } - + List valueParameterDescriptors = resolveValueParameters(functionDescriptor, innerScope, function.getValueParameters()); + + innerScope.changeLockLevel(WritableScope.LockLevel.READING); JetTypeReference returnTypeRef = function.getReturnTypeRef(); JetType returnType; @@ -499,8 +502,10 @@ public class DescriptorResolver { } else { WritableScope writableScope = new WritableScopeImpl(scope, containingDeclaration, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with type parameters of a property"); + writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); typeParameterDescriptors = resolveTypeParameters(containingDeclaration, writableScope, typeParameters); resolveGenericBounds(property, writableScope, typeParameterDescriptors); + writableScope.changeLockLevel(WritableScope.LockLevel.READING); scopeWithTypeParameters = writableScope; } @@ -761,11 +766,13 @@ public class DescriptorResolver { isPrimary ); trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor); + WritableScopeImpl parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with value parameters of a constructor"); + parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH); return constructorDescriptor.initialize( typeParameters, resolveValueParameters( constructorDescriptor, - new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with value parameters of a constructor"), + parameterScope, valueParameters), Modality.FINAL, resolveVisibilityFromModifiers(modifierList)); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index e6a9f31e64d..89bed40037e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -60,6 +60,7 @@ public class TopDownAnalyzer { new TypeHierarchyResolver(context).process(outerScope, owner, declarations); new DeclarationResolver(context).process(); new DelegationResolver(context).process(); + lockClasses(context); new OverrideResolver(context).process(); new OverloadResolver(context).process(); if (!context.analyzingBootstrapLibrary()) { @@ -72,6 +73,15 @@ public class TopDownAnalyzer { context.printDebugOutput(System.out); } + private static void lockClasses(TopDownAnalysisContext context) { + for (MutableClassDescriptor mutableClassDescriptor : context.getClasses().values()) { + mutableClassDescriptor.lockScopes(); + } + for (MutableClassDescriptor mutableClassDescriptor : context.getObjects().values()) { + mutableClassDescriptor.lockScopes(); + } + } + public static void processStandardLibraryNamespace( @NotNull JetSemanticServices semanticServices, @NotNull BindingTrace trace, diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java index 2585e655d35..ca5c16a1887 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java @@ -78,13 +78,16 @@ public class TypeHierarchyResolver { Collections.emptyList(), // TODO: annotations name ); - namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope")); + WritableScopeImpl memberScope = new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope"); + memberScope.changeLockLevel(WritableScope.LockLevel.BOTH); + namespaceDescriptor.initialize(memberScope); owner.addNamespace(namespaceDescriptor); context.getTrace().record(BindingContext.NAMESPACE, namespace, namespaceDescriptor); } context.getNamespaceDescriptors().put(namespace, namespaceDescriptor); WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace())); + namespaceScope.changeLockLevel(WritableScope.LockLevel.BOTH); context.getNamespaceScopes().put(namespace, namespaceScope); context.getDeclaringScopes().put(namespace, outerScope); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScope.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScope.java index f56816079fb..4716d808cc0 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScope.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScope.java @@ -9,6 +9,14 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; * @author abreslav */ public interface WritableScope extends JetScope { + enum LockLevel { + WRITING, + BOTH, + READING, + } + + void changeLockLevel(LockLevel lockLevel); + void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor); void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java index ed1febfd63a..97bd74167b8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java @@ -55,17 +55,22 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void importScope(@NotNull JetScope imported) { + checkMayWrite(); super.importScope(imported); } @Override public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) { + checkMayWrite(); + allDescriptors.add(classifierDescriptor); super.importClassifierAlias(importedClassifierName, classifierDescriptor); } @Override public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) { + checkMayWrite(); + allDescriptors.add(namespaceDescriptor); super.importNamespaceAlias(aliasName, namespaceDescriptor); } @@ -73,6 +78,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @NotNull @Override public Collection getAllDescriptors() { + checkMayRead(); + if (!allDescriptorsDone) { allDescriptorsDone = true; allDescriptors.addAll(getWorkerScope().getAllDescriptors()); @@ -94,6 +101,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @NotNull @Override public Collection getDeclarationsByLabel(@NotNull String labelName) { + checkMayRead(); + Collection superResult = super.getDeclarationsByLabel(labelName); Map> labelsToDescriptors = getLabelsToDescriptors(); List declarationDescriptors = labelsToDescriptors.get(labelName); @@ -108,6 +117,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) { + checkMayWrite(); + Map> labelsToDescriptors = getLabelsToDescriptors(); String name = descriptor.getName(); assert name != null; @@ -137,6 +148,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor) { + checkMayWrite(); + Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor existingDescriptor = variableClassOrNamespaceDescriptors.get(variableDescriptor.getName()); if (existingDescriptor != null) { @@ -149,6 +162,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public VariableDescriptor getVariable(@NotNull String name) { + checkMayRead(); + Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name); if (descriptor instanceof VariableDescriptor) { @@ -172,6 +187,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) { + checkMayWrite(); + getFunctionGroups().put(functionDescriptor.getName(), functionDescriptor); allDescriptors.add(functionDescriptor); } @@ -179,6 +196,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override @NotNull public Set getFunctions(@NotNull String name) { + checkMayRead(); + Set result = Sets.newLinkedHashSet(getFunctionGroups().get(name)); result.addAll(getWorkerScope().getFunctions(name)); @@ -190,17 +209,23 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) { + checkMayWrite(); + String name = typeParameterDescriptor.getName(); addClassifierAlias(name, typeParameterDescriptor); } @Override public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) { + checkMayWrite(); + addClassifierAlias(classDescriptor.getName(), classDescriptor); } @Override public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) { + checkMayWrite(); + checkForRedeclaration(name, classifierDescriptor); getVariableClassOrNamespaceDescriptors().put(name, classifierDescriptor); allDescriptors.add(classifierDescriptor); @@ -208,6 +233,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) { + checkMayWrite(); + checkForRedeclaration(name, namespaceDescriptor); getNamespaceAliases().put(name, namespaceDescriptor); allDescriptors.add(namespaceDescriptor); @@ -222,6 +249,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public ClassifierDescriptor getClassifier(@NotNull String name) { + checkMayRead(); + Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name); if (descriptor instanceof ClassifierDescriptor) return (ClassifierDescriptor) descriptor; @@ -234,6 +263,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) { + checkMayWrite(); + Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor oldValue = variableClassOrNamespaceDescriptors.put(namespaceDescriptor.getName(), namespaceDescriptor); if (oldValue != null) { @@ -244,6 +275,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) { + checkMayRead(); + Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor namespaceDescriptor = variableClassOrNamespaceDescriptors.get(name); if (namespaceDescriptor instanceof NamespaceDescriptor) return (NamespaceDescriptor) namespaceDescriptor; @@ -252,6 +285,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public NamespaceDescriptor getNamespace(@NotNull String name) { + checkMayRead(); + NamespaceDescriptor declaredNamespace = getDeclaredNamespace(name); if (declaredNamespace != null) return declaredNamespace; @@ -266,6 +301,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @NotNull @Override public ReceiverDescriptor getImplicitReceiver() { + checkMayRead(); + if (implicitReceiver == null) { return super.getImplicitReceiver(); } @@ -274,6 +311,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver) { + checkMayWrite(); + if (this.implicitReceiver != null) { throw new UnsupportedOperationException("Receiver redeclared"); } @@ -282,6 +321,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void getImplicitReceiversHierarchy(@NotNull List result) { + checkMayRead(); + if (implicitReceiver != null && implicitReceiver.exists()) { result.add(implicitReceiver); } @@ -303,6 +344,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { throw new IllegalStateException(); } + checkMayWrite(); + getPropertyDescriptorsByFieldNames().put(fieldName, propertyDescriptor); } @@ -312,12 +355,16 @@ public class WritableScopeImpl extends WritableScopeWithImports { throw new IllegalStateException(); } + checkMayRead(); + PropertyDescriptor descriptor = getPropertyDescriptorsByFieldNames().get(fieldName); if (descriptor != null) return descriptor; return super.getPropertyByFieldReference(fieldName); } public List getDeclaredVariables() { + checkMayRead(); + List result = Lists.newArrayList(); for (DeclarationDescriptor descriptor : getVariableClassOrNamespaceDescriptors().values()) { if (descriptor instanceof VariableDescriptor) { @@ -334,6 +381,8 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public WritableScopeImpl setDebugName(@NotNull String debugName) { + checkMayWrite(); + super.setDebugName(debugName); return this; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java index 97cdb1df602..ecca869bd2c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java @@ -31,7 +31,36 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement this.redeclarationHandler = redeclarationHandler; } + + + private LockLevel lockLevel = LockLevel.WRITING; + + @Override + public void changeLockLevel(LockLevel lockLevel) { + if (lockLevel.ordinal() < this.lockLevel.ordinal()) { + throw new IllegalStateException("cannot lower lock level from " + this.lockLevel + " to " + lockLevel); + } + this.lockLevel = lockLevel; + } + + protected void checkMayRead() { + if (lockLevel != LockLevel.READING && lockLevel != LockLevel.BOTH) { + throw new IllegalStateException("cannot read with lock level " + lockLevel); + } + } + + protected void checkMayWrite() { + if (lockLevel != LockLevel.WRITING && lockLevel != LockLevel.BOTH) { + throw new IllegalStateException("cannot write with lock level " + lockLevel); + } + } + + + + public WritableScopeWithImports setDebugName(@NotNull String debugName) { + checkMayWrite(); + assert this.debugName == null : this.debugName; this.debugName = debugName; return this; @@ -47,12 +76,16 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public void importScope(@NotNull JetScope imported) { + checkMayWrite(); + getImports().add(0, imported); currentIndividualImportScope = null; } @Override public void getImplicitReceiversHierarchy(@NotNull List result) { + checkMayRead(); + super.getImplicitReceiversHierarchy(result); // Imported scopes come with their receivers // Example: class member resolution scope imports a scope of it's class object @@ -67,6 +100,8 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public VariableDescriptor getVariable(@NotNull String name) { + checkMayRead(); + // Meaningful lookup goes here for (JetScope imported : getImports()) { VariableDescriptor importedDescriptor = imported.getVariable(name); @@ -80,6 +115,8 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @NotNull @Override public Set getFunctions(@NotNull String name) { + checkMayRead(); + if (getImports().isEmpty()) { return Collections.emptySet(); } @@ -92,6 +129,8 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public ClassifierDescriptor getClassifier(@NotNull String name) { + checkMayRead(); + for (JetScope imported : getImports()) { ClassifierDescriptor importedClassifier = imported.getClassifier(name); if (importedClassifier != null) { @@ -103,6 +142,8 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public NamespaceDescriptor getNamespace(@NotNull String name) { + checkMayRead(); + for (JetScope imported : getImports()) { NamespaceDescriptor importedDescriptor = imported.getNamespace(name); if (importedDescriptor != null) { @@ -115,6 +156,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement private WritableScope getCurrentIndividualImportScope() { if (currentIndividualImportScope == null) { WritableScopeImpl writableScope = new WritableScopeImpl(EMPTY, getContainingDeclaration(), RedeclarationHandler.DO_NOTHING).setDebugName("Individual import scope"); + writableScope.changeLockLevel(LockLevel.BOTH); importScope(writableScope); currentIndividualImportScope = writableScope; } @@ -123,12 +165,16 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) { + checkMayWrite(); + getCurrentIndividualImportScope().addClassifierAlias(importedClassifierName, classifierDescriptor); } @Override public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) { + checkMayWrite(); + getCurrentIndividualImportScope().addNamespaceAlias(aliasName, namespaceDescriptor); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java index 9c3a2abc7e6..c00a3e04547 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java @@ -25,30 +25,40 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override @Nullable public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) { + checkMayRead(); + return writableWorker.getPropertyByFieldReference(fieldName); } @Override @NotNull public Collection getDeclarationsByLabel(String labelName) { + checkMayRead(); + return writableWorker.getDeclarationsByLabel(labelName); } @Override @NotNull public DeclarationDescriptor getContainingDeclaration() { + checkMayRead(); + return writableWorker.getContainingDeclaration(); } @Override @NotNull public ReceiverDescriptor getImplicitReceiver() { + checkMayRead(); + return writableWorker.getImplicitReceiver(); } @Override @NotNull public Set getFunctions(@NotNull String name) { + checkMayRead(); + Set result = Sets.newLinkedHashSet(); result.addAll(writableWorker.getFunctions(name)); @@ -63,6 +73,8 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override @Nullable public VariableDescriptor getVariable(@NotNull String name) { + checkMayRead(); + VariableDescriptor variable = writableWorker.getVariable(name); if (variable != null) return variable; @@ -75,6 +87,8 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override @Nullable public NamespaceDescriptor getNamespace(@NotNull String name) { + checkMayRead(); + NamespaceDescriptor namespace = writableWorker.getNamespace(name); if (namespace != null) return namespace; @@ -87,6 +101,8 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override @Nullable public ClassifierDescriptor getClassifier(@NotNull String name) { + checkMayRead(); + ClassifierDescriptor classifier = writableWorker.getClassifier(name); if (classifier != null) return classifier; @@ -98,68 +114,94 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) { + checkMayWrite(); + writableWorker.addLabeledDeclaration(descriptor); // TODO : review } @Override public void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor) { + checkMayWrite(); + writableWorker.addVariableDescriptor(variableDescriptor); } @Override public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) { + checkMayWrite(); + writableWorker.addFunctionDescriptor(functionDescriptor); } @Override public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) { + checkMayWrite(); + writableWorker.addTypeParameterDescriptor(typeParameterDescriptor); } @Override public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) { + checkMayWrite(); + writableWorker.addClassifierDescriptor(classDescriptor); } @Override public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) { + checkMayWrite(); + writableWorker.addClassifierAlias(name, classifierDescriptor); } @Override public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) { + checkMayWrite(); + writableWorker.addNamespaceAlias(name, namespaceDescriptor); } @Override public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) { + checkMayWrite(); + writableWorker.addNamespace(namespaceDescriptor); } @Override @Nullable public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) { + checkMayRead(); + return writableWorker.getDeclaredNamespace(name); } @Override public void addPropertyDescriptorByFieldName(@NotNull String fieldName, @NotNull PropertyDescriptor propertyDescriptor) { + checkMayWrite(); + writableWorker.addPropertyDescriptorByFieldName(fieldName, propertyDescriptor); } @Override public void importScope(@NotNull JetScope imported) { + checkMayWrite(); + super.importScope(imported); // } @Override public void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver) { + checkMayWrite(); + writableWorker.setImplicitReceiver(implicitReceiver); } @NotNull @Override public Collection getAllDescriptors() { + checkMayRead(); + if (allDescriptors == null) { allDescriptors = Lists.newArrayList(); allDescriptors.addAll(writableWorker.getAllDescriptors()); @@ -170,6 +212,8 @@ public class WriteThroughScope extends WritableScopeWithImports { @NotNull public JetScope getOuterScope() { + checkMayRead(); + return getWorkerScope(); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java index 55908afd1b6..a6e120b1e8d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java @@ -194,6 +194,8 @@ public class JetStandardClasses { static { WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.DO_NOTHING).setDebugName("JetStandardClasses.STANDARD_CLASSES"); + writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); + STANDARD_CLASSES = writableScope; writableScope.addClassifierAlias("Unit", getTuple(0)); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java index c095764a3ab..0b99cbe5f69 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java @@ -13,6 +13,7 @@ import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler; +import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.plugin.JetFileType; @@ -133,6 +134,7 @@ public class JetStandardLibrary { JetSemanticServices bootstrappingSemanticServices = JetSemanticServices.createSemanticServices(this); BindingTraceContext bindingTraceContext = new BindingTraceContext(); WritableScopeImpl writableScope = new WritableScopeImpl(JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.THROW_EXCEPTION).setDebugName("Root bootstrap scope"); + writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); // this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations()); // bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations()); TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace()); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java index db493f27c06..a6be38a744c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java @@ -140,6 +140,7 @@ public class ExpressionTypingServices { DeclarationDescriptor containingDescriptor = outerScope.getContainingDeclaration(); WritableScope scope = new WritableScopeImpl(outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace)).setDebugName("getBlockReturnedType"); + scope.changeLockLevel(WritableScope.LockLevel.BOTH); return getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java index f9cdac37fcb..368b8e912b3 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java @@ -13,6 +13,7 @@ import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler; +import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.jet.lang.types.JetStandardClasses; @@ -42,7 +43,9 @@ public class ExpressionTypingUtils { @NotNull public static WritableScopeImpl newWritableScopeImpl(ExpressionTypingContext context) { - return new WritableScopeImpl(context.scope, context.scope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.trace)); + WritableScopeImpl scope = new WritableScopeImpl(context.scope, context.scope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.trace)); + scope.changeLockLevel(WritableScope.LockLevel.BOTH); + return scope; } public static boolean isBoolean(@NotNull JetSemanticServices semanticServices, @NotNull JetType type) { diff --git a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java index fb9556a89c3..ea1f05d8935 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java @@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorResolver; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler; +import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.lang.types.JetStandardLibrary; @@ -49,6 +50,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture { WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING); assert classDescriptor instanceof ClassifierDescriptor; scope.addClassifierDescriptor((ClassifierDescriptor) classDescriptor); + scope.changeLockLevel(WritableScope.LockLevel.READING); return scope; } diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index 1ead89fcde2..e765cef474a 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -545,6 +545,7 @@ public class JetTypeCheckerTest extends JetLiteFixture { JavaSemanticServices javaSemanticServices = new JavaSemanticServices(getProject(), semanticServices, JetTestUtils.DUMMY_TRACE); writableScope.importScope(new JavaPackageScope("", null, javaSemanticServices)); writableScope.importScope(new JavaPackageScope("java.lang", null, javaSemanticServices)); + writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); return writableScope; } @@ -641,6 +642,7 @@ public class JetTypeCheckerTest extends JetLiteFixture { trace.record(BindingContext.CLASS, classElement, classDescriptor); final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)); + parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH); // This call has side-effects on the parameterScope (fills it in) List typeParameters @@ -660,6 +662,7 @@ public class JetTypeCheckerTest extends JetLiteFixture { boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD); final WritableScope memberDeclarations = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, new TraceBasedRedeclarationHandler(trace)); + memberDeclarations.changeLockLevel(WritableScope.LockLevel.BOTH); List declarations = classElement.getDeclarations(); for (JetDeclaration declaration : declarations) { From 4b025adde96e041b31c346d020e5ed3eb18d11bc Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 30 Nov 2011 02:59:58 +0400 Subject: [PATCH 12/17] Revert "WritableScope.changeLockLevel()" This reverts commit 1866a245faefa5284718181b802ea17efb8323e1. Stupid git --- .../descriptors/FunctionDescriptorUtil.java | 1 - .../descriptors/MutableClassDescriptor.java | 13 ----- .../jet/lang/resolve/AnalyzingUtils.java | 1 - .../jet/lang/resolve/BodyResolver.java | 4 -- .../jet/lang/resolve/DescriptorResolver.java | 11 +---- .../jet/lang/resolve/TopDownAnalyzer.java | 10 ---- .../lang/resolve/TypeHierarchyResolver.java | 5 +- .../lang/resolve/scopes/WritableScope.java | 8 --- .../resolve/scopes/WritableScopeImpl.java | 49 ------------------- .../scopes/WritableScopeWithImports.java | 46 ----------------- .../resolve/scopes/WriteThroughScope.java | 44 ----------------- .../jet/lang/types/JetStandardClasses.java | 2 - .../jet/lang/types/JetStandardLibrary.java | 2 - .../expressions/ExpressionTypingServices.java | 1 - .../expressions/ExpressionTypingUtils.java | 5 +- .../JetDefaultModalityModifiersTest.java | 2 - .../jet/types/JetTypeCheckerTest.java | 3 -- 17 files changed, 4 insertions(+), 203 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java index 8208b807e8f..e4bc91d4854 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java @@ -80,7 +80,6 @@ public class FunctionDescriptorUtil { parameterScope.addVariableDescriptor(valueParameterDescriptor); } parameterScope.addLabeledDeclaration(descriptor); - parameterScope.changeLockLevel(WritableScope.LockLevel.READING); return parameterScope; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java index 525a8d93d05..669af46b9ae 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java @@ -49,11 +49,8 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme super(containingDeclaration); TraceBasedRedeclarationHandler redeclarationHandler = new TraceBasedRedeclarationHandler(trace); this.scopeForMemberLookup = new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler).setDebugName("MemberLookup"); - this.scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.BOTH); this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler).setDebugName("SupertypeResolution"); - this.scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.BOTH); this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler).setDebugName("MemberResolution"); - this.scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.BOTH); this.kind = kind; } @@ -183,7 +180,6 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme this.typeParameters.add(typeParameterDescriptor); scopeForSupertypeResolution.addTypeParameterDescriptor(typeParameterDescriptor); } - scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -348,13 +344,4 @@ public class MutableClassDescriptor extends MutableDeclarationDescriptor impleme } return implicitReceiver; } - - public void lockScopes() { - scopeForSupertypeResolution.changeLockLevel(WritableScope.LockLevel.READING); - scopeForMemberLookup.changeLockLevel(WritableScope.LockLevel.READING); - scopeForMemberResolution.changeLockLevel(WritableScope.LockLevel.READING); - if (classObjectDescriptor != null) { - classObjectDescriptor.lockScopes(); - } - } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java index 13cb17841bc..da5cb3020b5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnalyzingUtils.java @@ -96,7 +96,6 @@ public class AnalyzingUtils { final WritableScope scope = new WritableScopeImpl(JetScope.EMPTY, owner, new TraceBasedRedeclarationHandler(bindingTraceContext)).setDebugName("Root scope in analyzeNamespace"); importingStrategy.addImports(project, semanticServices, bindingTraceContext, scope); scope.importScope(libraryScope); - scope.changeLockLevel(WritableScope.LockLevel.BOTH); TopDownAnalyzer.process(semanticServices, bindingTraceContext, scope, new NamespaceLike.Adapter(owner) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java index eeab159c182..dd45fdd7af9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java @@ -382,8 +382,6 @@ public class BodyResolver { } constructorScope.addLabeledDeclaration(descriptor); // TODO : Labels for constructors?! - - constructorScope.changeLockLevel(WritableScope.LockLevel.READING); return constructorScope; } @@ -444,7 +442,6 @@ public class BodyResolver { if (receiver.exists()) { result.setImplicitReceiver(receiver); } - result.changeLockLevel(WritableScope.LockLevel.READING); return result; } @@ -453,7 +450,6 @@ public class BodyResolver { WritableScope accessorScope = new WritableScopeImpl(getPropertyDeclarationInnerScope(declaringScope, propertyDescriptor), declaringScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Accessor scope"); accessorScope.addPropertyDescriptorByFieldName("$" + propertyDescriptor.getName(), propertyDescriptor); - accessorScope.changeLockLevel(WritableScope.LockLevel.READING); JetPropertyAccessor getter = property.getGetter(); PropertyGetterDescriptor getterDescriptor = propertyDescriptor.getGetter(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java index 8cf81b34574..8be709898fd 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java @@ -146,7 +146,6 @@ public class DescriptorResolver { innerScope.addLabeledDeclaration(functionDescriptor); List typeParameterDescriptors = resolveTypeParameters(functionDescriptor, innerScope, function.getTypeParameters()); - innerScope.changeLockLevel(WritableScope.LockLevel.BOTH); resolveGenericBounds(function, innerScope, typeParameterDescriptors); JetType receiverType = null; @@ -158,10 +157,8 @@ public class DescriptorResolver { : scope; receiverType = typeResolver.resolveType(scopeForReceiver, receiverTypeRef); } - + List valueParameterDescriptors = resolveValueParameters(functionDescriptor, innerScope, function.getValueParameters()); - - innerScope.changeLockLevel(WritableScope.LockLevel.READING); JetTypeReference returnTypeRef = function.getReturnTypeRef(); JetType returnType; @@ -502,10 +499,8 @@ public class DescriptorResolver { } else { WritableScope writableScope = new WritableScopeImpl(scope, containingDeclaration, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with type parameters of a property"); - writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); typeParameterDescriptors = resolveTypeParameters(containingDeclaration, writableScope, typeParameters); resolveGenericBounds(property, writableScope, typeParameterDescriptors); - writableScope.changeLockLevel(WritableScope.LockLevel.READING); scopeWithTypeParameters = writableScope; } @@ -766,13 +761,11 @@ public class DescriptorResolver { isPrimary ); trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor); - WritableScopeImpl parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with value parameters of a constructor"); - parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH); return constructorDescriptor.initialize( typeParameters, resolveValueParameters( constructorDescriptor, - parameterScope, + new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with value parameters of a constructor"), valueParameters), Modality.FINAL, resolveVisibilityFromModifiers(modifierList)); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index 89bed40037e..e6a9f31e64d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -60,7 +60,6 @@ public class TopDownAnalyzer { new TypeHierarchyResolver(context).process(outerScope, owner, declarations); new DeclarationResolver(context).process(); new DelegationResolver(context).process(); - lockClasses(context); new OverrideResolver(context).process(); new OverloadResolver(context).process(); if (!context.analyzingBootstrapLibrary()) { @@ -73,15 +72,6 @@ public class TopDownAnalyzer { context.printDebugOutput(System.out); } - private static void lockClasses(TopDownAnalysisContext context) { - for (MutableClassDescriptor mutableClassDescriptor : context.getClasses().values()) { - mutableClassDescriptor.lockScopes(); - } - for (MutableClassDescriptor mutableClassDescriptor : context.getObjects().values()) { - mutableClassDescriptor.lockScopes(); - } - } - public static void processStandardLibraryNamespace( @NotNull JetSemanticServices semanticServices, @NotNull BindingTrace trace, diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java index ca5c16a1887..2585e655d35 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java @@ -78,16 +78,13 @@ public class TypeHierarchyResolver { Collections.emptyList(), // TODO: annotations name ); - WritableScopeImpl memberScope = new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope"); - memberScope.changeLockLevel(WritableScope.LockLevel.BOTH); - namespaceDescriptor.initialize(memberScope); + namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope")); owner.addNamespace(namespaceDescriptor); context.getTrace().record(BindingContext.NAMESPACE, namespace, namespaceDescriptor); } context.getNamespaceDescriptors().put(namespace, namespaceDescriptor); WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace())); - namespaceScope.changeLockLevel(WritableScope.LockLevel.BOTH); context.getNamespaceScopes().put(namespace, namespaceScope); context.getDeclaringScopes().put(namespace, outerScope); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScope.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScope.java index 4716d808cc0..f56816079fb 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScope.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScope.java @@ -9,14 +9,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; * @author abreslav */ public interface WritableScope extends JetScope { - enum LockLevel { - WRITING, - BOTH, - READING, - } - - void changeLockLevel(LockLevel lockLevel); - void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor); void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java index 97bd74167b8..ed1febfd63a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java @@ -55,22 +55,17 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void importScope(@NotNull JetScope imported) { - checkMayWrite(); super.importScope(imported); } @Override public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) { - checkMayWrite(); - allDescriptors.add(classifierDescriptor); super.importClassifierAlias(importedClassifierName, classifierDescriptor); } @Override public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) { - checkMayWrite(); - allDescriptors.add(namespaceDescriptor); super.importNamespaceAlias(aliasName, namespaceDescriptor); } @@ -78,8 +73,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @NotNull @Override public Collection getAllDescriptors() { - checkMayRead(); - if (!allDescriptorsDone) { allDescriptorsDone = true; allDescriptors.addAll(getWorkerScope().getAllDescriptors()); @@ -101,8 +94,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @NotNull @Override public Collection getDeclarationsByLabel(@NotNull String labelName) { - checkMayRead(); - Collection superResult = super.getDeclarationsByLabel(labelName); Map> labelsToDescriptors = getLabelsToDescriptors(); List declarationDescriptors = labelsToDescriptors.get(labelName); @@ -117,8 +108,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) { - checkMayWrite(); - Map> labelsToDescriptors = getLabelsToDescriptors(); String name = descriptor.getName(); assert name != null; @@ -148,8 +137,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor) { - checkMayWrite(); - Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor existingDescriptor = variableClassOrNamespaceDescriptors.get(variableDescriptor.getName()); if (existingDescriptor != null) { @@ -162,8 +149,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public VariableDescriptor getVariable(@NotNull String name) { - checkMayRead(); - Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name); if (descriptor instanceof VariableDescriptor) { @@ -187,8 +172,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) { - checkMayWrite(); - getFunctionGroups().put(functionDescriptor.getName(), functionDescriptor); allDescriptors.add(functionDescriptor); } @@ -196,8 +179,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override @NotNull public Set getFunctions(@NotNull String name) { - checkMayRead(); - Set result = Sets.newLinkedHashSet(getFunctionGroups().get(name)); result.addAll(getWorkerScope().getFunctions(name)); @@ -209,23 +190,17 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) { - checkMayWrite(); - String name = typeParameterDescriptor.getName(); addClassifierAlias(name, typeParameterDescriptor); } @Override public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) { - checkMayWrite(); - addClassifierAlias(classDescriptor.getName(), classDescriptor); } @Override public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) { - checkMayWrite(); - checkForRedeclaration(name, classifierDescriptor); getVariableClassOrNamespaceDescriptors().put(name, classifierDescriptor); allDescriptors.add(classifierDescriptor); @@ -233,8 +208,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) { - checkMayWrite(); - checkForRedeclaration(name, namespaceDescriptor); getNamespaceAliases().put(name, namespaceDescriptor); allDescriptors.add(namespaceDescriptor); @@ -249,8 +222,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public ClassifierDescriptor getClassifier(@NotNull String name) { - checkMayRead(); - Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor descriptor = variableClassOrNamespaceDescriptors.get(name); if (descriptor instanceof ClassifierDescriptor) return (ClassifierDescriptor) descriptor; @@ -263,8 +234,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) { - checkMayWrite(); - Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor oldValue = variableClassOrNamespaceDescriptors.put(namespaceDescriptor.getName(), namespaceDescriptor); if (oldValue != null) { @@ -275,8 +244,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) { - checkMayRead(); - Map variableClassOrNamespaceDescriptors = getVariableClassOrNamespaceDescriptors(); DeclarationDescriptor namespaceDescriptor = variableClassOrNamespaceDescriptors.get(name); if (namespaceDescriptor instanceof NamespaceDescriptor) return (NamespaceDescriptor) namespaceDescriptor; @@ -285,8 +252,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public NamespaceDescriptor getNamespace(@NotNull String name) { - checkMayRead(); - NamespaceDescriptor declaredNamespace = getDeclaredNamespace(name); if (declaredNamespace != null) return declaredNamespace; @@ -301,8 +266,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @NotNull @Override public ReceiverDescriptor getImplicitReceiver() { - checkMayRead(); - if (implicitReceiver == null) { return super.getImplicitReceiver(); } @@ -311,8 +274,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver) { - checkMayWrite(); - if (this.implicitReceiver != null) { throw new UnsupportedOperationException("Receiver redeclared"); } @@ -321,8 +282,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public void getImplicitReceiversHierarchy(@NotNull List result) { - checkMayRead(); - if (implicitReceiver != null && implicitReceiver.exists()) { result.add(implicitReceiver); } @@ -344,8 +303,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { throw new IllegalStateException(); } - checkMayWrite(); - getPropertyDescriptorsByFieldNames().put(fieldName, propertyDescriptor); } @@ -355,16 +312,12 @@ public class WritableScopeImpl extends WritableScopeWithImports { throw new IllegalStateException(); } - checkMayRead(); - PropertyDescriptor descriptor = getPropertyDescriptorsByFieldNames().get(fieldName); if (descriptor != null) return descriptor; return super.getPropertyByFieldReference(fieldName); } public List getDeclaredVariables() { - checkMayRead(); - List result = Lists.newArrayList(); for (DeclarationDescriptor descriptor : getVariableClassOrNamespaceDescriptors().values()) { if (descriptor instanceof VariableDescriptor) { @@ -381,8 +334,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Override public WritableScopeImpl setDebugName(@NotNull String debugName) { - checkMayWrite(); - super.setDebugName(debugName); return this; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java index ecca869bd2c..97cdb1df602 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java @@ -31,36 +31,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement this.redeclarationHandler = redeclarationHandler; } - - - private LockLevel lockLevel = LockLevel.WRITING; - - @Override - public void changeLockLevel(LockLevel lockLevel) { - if (lockLevel.ordinal() < this.lockLevel.ordinal()) { - throw new IllegalStateException("cannot lower lock level from " + this.lockLevel + " to " + lockLevel); - } - this.lockLevel = lockLevel; - } - - protected void checkMayRead() { - if (lockLevel != LockLevel.READING && lockLevel != LockLevel.BOTH) { - throw new IllegalStateException("cannot read with lock level " + lockLevel); - } - } - - protected void checkMayWrite() { - if (lockLevel != LockLevel.WRITING && lockLevel != LockLevel.BOTH) { - throw new IllegalStateException("cannot write with lock level " + lockLevel); - } - } - - - - public WritableScopeWithImports setDebugName(@NotNull String debugName) { - checkMayWrite(); - assert this.debugName == null : this.debugName; this.debugName = debugName; return this; @@ -76,16 +47,12 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public void importScope(@NotNull JetScope imported) { - checkMayWrite(); - getImports().add(0, imported); currentIndividualImportScope = null; } @Override public void getImplicitReceiversHierarchy(@NotNull List result) { - checkMayRead(); - super.getImplicitReceiversHierarchy(result); // Imported scopes come with their receivers // Example: class member resolution scope imports a scope of it's class object @@ -100,8 +67,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public VariableDescriptor getVariable(@NotNull String name) { - checkMayRead(); - // Meaningful lookup goes here for (JetScope imported : getImports()) { VariableDescriptor importedDescriptor = imported.getVariable(name); @@ -115,8 +80,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @NotNull @Override public Set getFunctions(@NotNull String name) { - checkMayRead(); - if (getImports().isEmpty()) { return Collections.emptySet(); } @@ -129,8 +92,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public ClassifierDescriptor getClassifier(@NotNull String name) { - checkMayRead(); - for (JetScope imported : getImports()) { ClassifierDescriptor importedClassifier = imported.getClassifier(name); if (importedClassifier != null) { @@ -142,8 +103,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public NamespaceDescriptor getNamespace(@NotNull String name) { - checkMayRead(); - for (JetScope imported : getImports()) { NamespaceDescriptor importedDescriptor = imported.getNamespace(name); if (importedDescriptor != null) { @@ -156,7 +115,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement private WritableScope getCurrentIndividualImportScope() { if (currentIndividualImportScope == null) { WritableScopeImpl writableScope = new WritableScopeImpl(EMPTY, getContainingDeclaration(), RedeclarationHandler.DO_NOTHING).setDebugName("Individual import scope"); - writableScope.changeLockLevel(LockLevel.BOTH); importScope(writableScope); currentIndividualImportScope = writableScope; } @@ -165,16 +123,12 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement @Override public void importClassifierAlias(@NotNull String importedClassifierName, @NotNull ClassifierDescriptor classifierDescriptor) { - checkMayWrite(); - getCurrentIndividualImportScope().addClassifierAlias(importedClassifierName, classifierDescriptor); } @Override public void importNamespaceAlias(String aliasName, NamespaceDescriptor namespaceDescriptor) { - checkMayWrite(); - getCurrentIndividualImportScope().addNamespaceAlias(aliasName, namespaceDescriptor); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java index c00a3e04547..9c3a2abc7e6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java @@ -25,40 +25,30 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override @Nullable public PropertyDescriptor getPropertyByFieldReference(@NotNull String fieldName) { - checkMayRead(); - return writableWorker.getPropertyByFieldReference(fieldName); } @Override @NotNull public Collection getDeclarationsByLabel(String labelName) { - checkMayRead(); - return writableWorker.getDeclarationsByLabel(labelName); } @Override @NotNull public DeclarationDescriptor getContainingDeclaration() { - checkMayRead(); - return writableWorker.getContainingDeclaration(); } @Override @NotNull public ReceiverDescriptor getImplicitReceiver() { - checkMayRead(); - return writableWorker.getImplicitReceiver(); } @Override @NotNull public Set getFunctions(@NotNull String name) { - checkMayRead(); - Set result = Sets.newLinkedHashSet(); result.addAll(writableWorker.getFunctions(name)); @@ -73,8 +63,6 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override @Nullable public VariableDescriptor getVariable(@NotNull String name) { - checkMayRead(); - VariableDescriptor variable = writableWorker.getVariable(name); if (variable != null) return variable; @@ -87,8 +75,6 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override @Nullable public NamespaceDescriptor getNamespace(@NotNull String name) { - checkMayRead(); - NamespaceDescriptor namespace = writableWorker.getNamespace(name); if (namespace != null) return namespace; @@ -101,8 +87,6 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override @Nullable public ClassifierDescriptor getClassifier(@NotNull String name) { - checkMayRead(); - ClassifierDescriptor classifier = writableWorker.getClassifier(name); if (classifier != null) return classifier; @@ -114,94 +98,68 @@ public class WriteThroughScope extends WritableScopeWithImports { @Override public void addLabeledDeclaration(@NotNull DeclarationDescriptor descriptor) { - checkMayWrite(); - writableWorker.addLabeledDeclaration(descriptor); // TODO : review } @Override public void addVariableDescriptor(@NotNull VariableDescriptor variableDescriptor) { - checkMayWrite(); - writableWorker.addVariableDescriptor(variableDescriptor); } @Override public void addFunctionDescriptor(@NotNull FunctionDescriptor functionDescriptor) { - checkMayWrite(); - writableWorker.addFunctionDescriptor(functionDescriptor); } @Override public void addTypeParameterDescriptor(@NotNull TypeParameterDescriptor typeParameterDescriptor) { - checkMayWrite(); - writableWorker.addTypeParameterDescriptor(typeParameterDescriptor); } @Override public void addClassifierDescriptor(@NotNull ClassifierDescriptor classDescriptor) { - checkMayWrite(); - writableWorker.addClassifierDescriptor(classDescriptor); } @Override public void addClassifierAlias(@NotNull String name, @NotNull ClassifierDescriptor classifierDescriptor) { - checkMayWrite(); - writableWorker.addClassifierAlias(name, classifierDescriptor); } @Override public void addNamespaceAlias(@NotNull String name, @NotNull NamespaceDescriptor namespaceDescriptor) { - checkMayWrite(); - writableWorker.addNamespaceAlias(name, namespaceDescriptor); } @Override public void addNamespace(@NotNull NamespaceDescriptor namespaceDescriptor) { - checkMayWrite(); - writableWorker.addNamespace(namespaceDescriptor); } @Override @Nullable public NamespaceDescriptor getDeclaredNamespace(@NotNull String name) { - checkMayRead(); - return writableWorker.getDeclaredNamespace(name); } @Override public void addPropertyDescriptorByFieldName(@NotNull String fieldName, @NotNull PropertyDescriptor propertyDescriptor) { - checkMayWrite(); - writableWorker.addPropertyDescriptorByFieldName(fieldName, propertyDescriptor); } @Override public void importScope(@NotNull JetScope imported) { - checkMayWrite(); - super.importScope(imported); // } @Override public void setImplicitReceiver(@NotNull ReceiverDescriptor implicitReceiver) { - checkMayWrite(); - writableWorker.setImplicitReceiver(implicitReceiver); } @NotNull @Override public Collection getAllDescriptors() { - checkMayRead(); - if (allDescriptors == null) { allDescriptors = Lists.newArrayList(); allDescriptors.addAll(writableWorker.getAllDescriptors()); @@ -212,8 +170,6 @@ public class WriteThroughScope extends WritableScopeWithImports { @NotNull public JetScope getOuterScope() { - checkMayRead(); - return getWorkerScope(); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java index a6e120b1e8d..55908afd1b6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardClasses.java @@ -194,8 +194,6 @@ public class JetStandardClasses { static { WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.DO_NOTHING).setDebugName("JetStandardClasses.STANDARD_CLASSES"); - writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); - STANDARD_CLASSES = writableScope; writableScope.addClassifierAlias("Unit", getTuple(0)); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java index 0b99cbe5f69..c095764a3ab 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java @@ -13,7 +13,6 @@ import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler; -import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.plugin.JetFileType; @@ -134,7 +133,6 @@ public class JetStandardLibrary { JetSemanticServices bootstrappingSemanticServices = JetSemanticServices.createSemanticServices(this); BindingTraceContext bindingTraceContext = new BindingTraceContext(); WritableScopeImpl writableScope = new WritableScopeImpl(JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.THROW_EXCEPTION).setDebugName("Root bootstrap scope"); - writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); // this.libraryScope = bootstrappingTDA.process(JetStandardClasses.STANDARD_CLASSES, file.getRootNamespace().getDeclarations()); // bootstrappingTDA.process(writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace().getDeclarations()); TopDownAnalyzer.processStandardLibraryNamespace(bootstrappingSemanticServices, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, file.getRootNamespace()); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java index a6be38a744c..db493f27c06 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java @@ -140,7 +140,6 @@ public class ExpressionTypingServices { DeclarationDescriptor containingDescriptor = outerScope.getContainingDeclaration(); WritableScope scope = new WritableScopeImpl(outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace)).setDebugName("getBlockReturnedType"); - scope.changeLockLevel(WritableScope.LockLevel.BOTH); return getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java index 368b8e912b3..f9cdac37fcb 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java @@ -13,7 +13,6 @@ import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.TraceBasedRedeclarationHandler; -import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.jet.lang.types.JetStandardClasses; @@ -43,9 +42,7 @@ public class ExpressionTypingUtils { @NotNull public static WritableScopeImpl newWritableScopeImpl(ExpressionTypingContext context) { - WritableScopeImpl scope = new WritableScopeImpl(context.scope, context.scope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.trace)); - scope.changeLockLevel(WritableScope.LockLevel.BOTH); - return scope; + return new WritableScopeImpl(context.scope, context.scope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.trace)); } public static boolean isBoolean(@NotNull JetSemanticServices semanticServices, @NotNull JetType type) { diff --git a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java index ea1f05d8935..fb9556a89c3 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java @@ -10,7 +10,6 @@ import org.jetbrains.jet.lang.resolve.DescriptorResolver; import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler; -import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.lang.types.JetStandardLibrary; @@ -50,7 +49,6 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture { WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING); assert classDescriptor instanceof ClassifierDescriptor; scope.addClassifierDescriptor((ClassifierDescriptor) classDescriptor); - scope.changeLockLevel(WritableScope.LockLevel.READING); return scope; } diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index e765cef474a..1ead89fcde2 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -545,7 +545,6 @@ public class JetTypeCheckerTest extends JetLiteFixture { JavaSemanticServices javaSemanticServices = new JavaSemanticServices(getProject(), semanticServices, JetTestUtils.DUMMY_TRACE); writableScope.importScope(new JavaPackageScope("", null, javaSemanticServices)); writableScope.importScope(new JavaPackageScope("java.lang", null, javaSemanticServices)); - writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); return writableScope; } @@ -642,7 +641,6 @@ public class JetTypeCheckerTest extends JetLiteFixture { trace.record(BindingContext.CLASS, classElement, classDescriptor); final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)); - parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH); // This call has side-effects on the parameterScope (fills it in) List typeParameters @@ -662,7 +660,6 @@ public class JetTypeCheckerTest extends JetLiteFixture { boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD); final WritableScope memberDeclarations = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, new TraceBasedRedeclarationHandler(trace)); - memberDeclarations.changeLockLevel(WritableScope.LockLevel.BOTH); List declarations = classElement.getDeclarations(); for (JetDeclaration declaration : declarations) { From 5075e30bb385af5d34cd533c16be03338daa6afd Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Wed, 30 Nov 2011 03:00:18 +0400 Subject: [PATCH 13/17] Revert "idea settings" This reverts commit 52dc3bb7bb4b00cfbd8cc57da662fea7c6b2c703. I hate git --- .idea/inspectionProfiles/idea_default.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml index 497bd6ace93..1dfe9e84ad8 100644 --- a/.idea/inspectionProfiles/idea_default.xml +++ b/.idea/inspectionProfiles/idea_default.xml @@ -340,11 +340,6 @@ - - From 90c4b0e74669eb4dca94147c6f143ee5c92ec9d0 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 30 Nov 2011 10:20:19 +0300 Subject: [PATCH 14/17] Raw strings: """ .. """ fixed --- .../constants/CompileTimeConstantResolver.java | 3 ++- compiler/testData/codegen/rawStrings.jet | 6 ++++++ .../tests/org/jetbrains/jet/codegen/StringsTest.java | 12 ++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/codegen/rawStrings.jet create mode 100644 compiler/tests/org/jetbrains/jet/codegen/StringsTest.java diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java index 779b35b9481..823a3183238 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/CompileTimeConstantResolver.java @@ -250,7 +250,8 @@ public class CompileTimeConstantResolver { if (error != null) { return error; } - return new StringValue(unescapedText); + + return new StringValue(unescapedText.substring(3, unescapedText.length() - 3)); } @NotNull diff --git a/compiler/testData/codegen/rawStrings.jet b/compiler/testData/codegen/rawStrings.jet new file mode 100644 index 00000000000..a2f427814ef --- /dev/null +++ b/compiler/testData/codegen/rawStrings.jet @@ -0,0 +1,6 @@ +fun box() : String { + val s = """ foo \n bar """ + if (s != " foo \\n bar ") return "Fail: '$s'" + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/codegen/StringsTest.java b/compiler/tests/org/jetbrains/jet/codegen/StringsTest.java new file mode 100644 index 00000000000..bbba589480d --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/codegen/StringsTest.java @@ -0,0 +1,12 @@ +package org.jetbrains.jet.codegen; + +/** + * @author yole + * @author alex.tkachman + */ +public class StringsTest extends CodegenTestCase { + + public void testRawStrings() throws Exception { + blackBoxFile("rawStrings.jet"); + } +} From 5293d1553b9a0be00bdce9c657ad276220f575b2 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 30 Nov 2011 11:02:03 +0300 Subject: [PATCH 15/17] // KT-630 Bad type inference --- .../jet/lang/types/inference/ConstraintSystemImpl.java | 10 ++++++++-- .../checkerWithErrorTypes/quick/regressions/kt630.jet | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt630.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java index c5aff27be5c..e9984635f3a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java @@ -267,9 +267,15 @@ public class ConstraintSystemImpl implements ConstraintSystem { @Override public boolean noCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) { - // If some of the types is an unknown, the constraint is already generated, and we should carry on + // If some of the types is an unknown, the constraint must be generated, and we should carry on // otherwise there can be no solution, and we should fail - return someUnknown(getTypeValueFor(subtype), getTypeValueFor(supertype)); + TypeValue subTypeValue = getTypeValueFor(subtype); + TypeValue superTypeValue = getTypeValueFor(supertype); + boolean someUnknown = someUnknown(subTypeValue, superTypeValue); + if (someUnknown) { + addSubtypingConstraintOnTypeValues(subTypeValue, superTypeValue); + } + return someUnknown; } private boolean someUnknown(TypeValue subtypeValue, TypeValue supertypeValue) { diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt630.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt630.jet new file mode 100644 index 00000000000..840941d9807 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt630.jet @@ -0,0 +1,3 @@ +// KT-630 Bad type inference +val x = "lala".sure() +val s : String = x \ No newline at end of file From 7fd7bdb2b8bf6994c838ed57dcdeb491a48ada55 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 30 Nov 2011 12:56:11 +0300 Subject: [PATCH 16/17] KT-668 Failed to resolve generic parameter Same lower and upper bounds cause an equality constraint to be created --- .../types/inference/ConstraintSystemImpl.java | 63 +++++++++++++------ .../quick/regressions/kt688.jet | 14 +++++ 2 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt688.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java index e9984635f3a..ed5e49d499c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java @@ -73,9 +73,11 @@ public class ConstraintSystemImpl implements ConstraintSystem { @Nullable public abstract KnownType getValue(); + + public abstract boolean equate(TypeValue other); } - private static class UnknownType extends TypeValue { + private class UnknownType extends TypeValue { private final TypeParameterDescriptor typeParameterDescriptor; private final Variance positionVariance; @@ -87,6 +89,24 @@ public class ConstraintSystemImpl implements ConstraintSystem { this.positionVariance = positionVariance; } + @Override + public void addUpperBound(@NotNull TypeValue bound) { + addBound(bound, getLowerBounds()); + super.addUpperBound(bound); + } + + @Override + public void addLowerBound(@NotNull TypeValue bound) { + addBound(bound, getUpperBounds()); + super.addLowerBound(bound); + } + + private void addBound(TypeValue bound, Set oppositeBounds) { + if (oppositeBounds.contains(bound)) { + this.equate(bound); + } + } + @NotNull public TypeParameterDescriptor getTypeParameterDescriptor() { return typeParameterDescriptor; @@ -139,6 +159,18 @@ public class ConstraintSystemImpl implements ConstraintSystem { return value; } + @Override + public boolean equate(TypeValue other) { + if (other instanceof KnownType) { + KnownType knownType = (KnownType) other; + return setValue(knownType); + } + + assert other instanceof UnknownType; + mergeUnknowns((UnknownType) other, this); + return true; + } + public boolean setValue(@NotNull KnownType value) { if (this.value != null) { // If we have already assigned a value to this unknown, @@ -186,6 +218,15 @@ public class ConstraintSystemImpl implements ConstraintSystem { public String toString() { return type.toString(); } + + @Override + public boolean equate(TypeValue other) { + if (other instanceof KnownType) { + KnownType knownType = (KnownType) other; + return TypeUtils.equalTypes(type, knownType.getType()); + } + return other.equate(this); + } } private final Map knownTypes = Maps.newHashMap(); @@ -233,25 +274,7 @@ public class ConstraintSystemImpl implements ConstraintSystem { TypeValue aValue = getTypeValueFor(a); TypeValue bValue = getTypeValueFor(b); - if (aValue instanceof UnknownType) { - UnknownType aUnknown = (UnknownType) aValue; - if (bValue instanceof UnknownType) { - UnknownType bUnknown = (UnknownType) bValue; - mergeUnknowns(aUnknown, bUnknown); - } - else { - if (!aUnknown.setValue((KnownType) bValue)) return false; - } - } - else if (bValue instanceof UnknownType) { - UnknownType bUnknown = (UnknownType) bValue; - if (!bUnknown.setValue((KnownType) aValue)) return false; - } - else { - return TypeUtils.equalTypes(a, b); - } - - return true; + return aValue.equate(bValue); } @Override diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt688.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt688.jet new file mode 100644 index 00000000000..045dddc7d8f --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt688.jet @@ -0,0 +1,14 @@ +// KT-668 Failed to resolve generic parameter +open class A() +open class B() : A() { + fun b(): B = B() +} + + +class C() { + fun a(x: fun(T):T, y: T): T { + return x(x(y)) + } + + val x: B = a({it.b()}, B()) +} \ No newline at end of file From 49c29dd323516310cfb945913f43983458bb323d Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Wed, 30 Nov 2011 15:06:55 +0300 Subject: [PATCH 17/17] KT-691 Allow to create nested namespaces with dot delimiter --- .../jetbrains/jet/codegen/CodegenUtil.java | 22 +++- .../src/org/jetbrains/jet/JetNodeTypes.java | 2 +- .../jet/lang/parsing/JetParsing.java | 20 +++- .../jet/lang/psi/JetAnnotatedExpression.java | 2 + .../jetbrains/jet/lang/psi/JetNamespace.java | 13 ++- .../jet/lang/psi/JetNamespaceHeader.java | 35 ++++++ .../lang/resolve/TypeHierarchyResolver.java | 43 ++++--- .../quick/regressions/kt691.jet | 2 + .../testData/psi/AnnotatedExpressions.txt | 2 + .../testData/psi/AnonymousInitializer.txt | 2 + compiler/testData/psi/Attributes.txt | 12 +- .../testData/psi/AttributesOnPatterns.txt | 2 + compiler/testData/psi/Attributes_ERR.txt | 12 +- compiler/testData/psi/BabySteps.txt | 6 +- compiler/testData/psi/BabySteps_ERR.txt | 6 +- compiler/testData/psi/ByCaluses.txt | 2 + .../testData/psi/CallWithManyClosures.txt | 2 + compiler/testData/psi/CallsInWhen.txt | 2 + compiler/testData/psi/Constructors.txt | 2 + compiler/testData/psi/ControlStructures.txt | 2 + compiler/testData/psi/EOLsInComments.txt | 2 + compiler/testData/psi/EOLsOnRollback.txt | 2 + compiler/testData/psi/EmptyFile.txt | 3 +- compiler/testData/psi/Enums.txt | 2 + compiler/testData/psi/Expressions_ERR.txt | 2 + compiler/testData/psi/FileStart_ERR.txt | 11 +- compiler/testData/psi/FunctionCalls.txt | 2 + compiler/testData/psi/FunctionLiterals.txt | 2 + .../testData/psi/FunctionLiterals_ERR.txt | 2 + compiler/testData/psi/FunctionTypes.txt | 2 + compiler/testData/psi/FunctionTypes_ERR.txt | 2 + compiler/testData/psi/Functions.txt | 2 + compiler/testData/psi/Functions_ERR.txt | 2 + .../testData/psi/HangOnLonelyModifier.txt | 2 + compiler/testData/psi/IfWithPropery.txt | 2 + compiler/testData/psi/ImportSoftKW.txt | 2 + compiler/testData/psi/Imports.txt | 12 +- compiler/testData/psi/Imports_ERR.txt | 12 +- compiler/testData/psi/Labels.txt | 2 + compiler/testData/psi/LocalDeclarations.txt | 2 + compiler/testData/psi/ModifierAsSelector.txt | 2 + compiler/testData/psi/NamespaceBlock.txt | 42 +++---- compiler/testData/psi/NamespaceBlockFirst.txt | 8 +- compiler/testData/psi/NamespaceBlock_ERR.txt | 56 ++++----- compiler/testData/psi/NamespaceModifiers.txt | 44 ++++---- .../testData/psi/NewLinesValidOperations.txt | 2 + .../testData/psi/NewlinesInParentheses.txt | 2 + compiler/testData/psi/NotIsAndNotIn.txt | 2 + compiler/testData/psi/Precedence.txt | 2 + compiler/testData/psi/PredicateExpression.txt | 2 + .../psi/PrimaryConstructorModifiers_ERR.txt | 2 + compiler/testData/psi/Properties.txt | 2 + .../psi/PropertiesFollowedByInitializers.txt | 2 + compiler/testData/psi/Properties_ERR.txt | 2 + compiler/testData/psi/QuotedIdentifiers.txt | 4 +- compiler/testData/psi/RootNamespace.txt | 20 ++-- compiler/testData/psi/SemicolonAfterIf.txt | 2 + compiler/testData/psi/ShortAnnotations.txt | 106 +++++++++--------- compiler/testData/psi/SimpleClassMembers.txt | 2 + .../testData/psi/SimpleClassMembers_ERR.txt | 2 + compiler/testData/psi/SimpleExpressions.txt | 2 + compiler/testData/psi/SimpleModifiers.txt | 12 +- compiler/testData/psi/SoftKeywords.txt | 12 +- .../psi/SoftKeywordsInTypeArguments.txt | 2 + compiler/testData/psi/StringTemplates.txt | 2 + compiler/testData/psi/Super.txt | 2 + compiler/testData/psi/ThisType.txt | 2 + compiler/testData/psi/TupleTypes.txt | 2 + compiler/testData/psi/TupleTypes_ERR.txt | 2 + .../testData/psi/TuplesWithLabeledEntries.txt | 2 + compiler/testData/psi/TypeAnnotations.txt | 2 + compiler/testData/psi/TypeConstraints.txt | 2 + compiler/testData/psi/TypeDef.txt | 12 +- compiler/testData/psi/TypeDef_ERR.txt | 2 + .../psi/TypeExpressionAmbiguities_ERR.txt | 2 + .../testData/psi/TypeParametersBeforeName.txt | 2 + compiler/testData/psi/When.txt | 2 + compiler/testData/psi/When_ERR.txt | 2 + .../psi/examples/AnonymousObjects.txt | 2 + compiler/testData/psi/examples/BinaryTree.txt | 2 + compiler/testData/psi/examples/BitArith.txt | 2 + compiler/testData/psi/examples/Builder.txt | 2 + compiler/testData/psi/examples/Color.txt | 2 + .../psi/examples/FunctionsAndTypes.txt | 2 + compiler/testData/psi/examples/Graph.txt | 2 + compiler/testData/psi/examples/IPushPop.txt | 2 + compiler/testData/psi/examples/LINQ.txt | 2 + .../psi/examples/PolymorphicClassObjects.txt | 2 + compiler/testData/psi/examples/Queue.txt | 2 + compiler/testData/psi/examples/Stack.txt | 2 + compiler/testData/psi/examples/UnionFind.txt | 2 + .../testData/psi/examples/UpdateOperation.txt | 2 + compiler/testData/psi/examples/With.txt | 2 + .../psi/examples/array/MutableArray.txt | 2 + .../psi/examples/collections/ArrayList.txt | 2 + .../psi/examples/collections/HashMap.txt | 2 + .../psi/examples/collections/IIterable.txt | 2 + .../psi/examples/collections/IIterator.txt | 2 + .../psi/examples/collections/IList.txt | 2 + .../examples/collections/IMutableIterable.txt | 2 + .../examples/collections/IMutableIterator.txt | 2 + .../psi/examples/collections/IMutableList.txt | 2 + .../psi/examples/collections/IMutableSet.txt | 2 + .../psi/examples/collections/ISet.txt | 2 + .../psi/examples/collections/ISized.txt | 2 + .../psi/examples/collections/LinkedList.txt | 2 + .../psi/examples/collections/List.txt | 2 + .../testData/psi/examples/io/IOSamples.txt | 2 + compiler/testData/psi/examples/map/IMap.txt | 2 + .../examples/priorityqueues/BinaryHeap.txt | 2 + .../priorityqueues/IPriorityQueue.txt | 2 + .../priorityqueues/PriorityQueueAsPushPop.txt | 2 + .../testData/psi/examples/util/Comparison.txt | 2 + .../psi/examples/util/IComparable.txt | 2 + 114 files changed, 496 insertions(+), 209 deletions(-) create mode 100644 compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespaceHeader.java create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt691.jet diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java index fc16f243eab..e597e5967aa 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java @@ -4,15 +4,13 @@ import com.intellij.psi.util.PsiTreeUtil; import gnu.trove.THashSet; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.psi.JetClass; -import org.jetbrains.jet.lang.psi.JetNamedDeclaration; -import org.jetbrains.jet.lang.psi.JetNamespace; +import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.calls.ExpressionAsFunctionDescriptor; -import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.JetStandardClasses; import org.jetbrains.jet.lang.types.JetType; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Set; @@ -115,10 +113,22 @@ public class CodegenUtil { if (parent != null) { String parentFQName = getFQName(parent); if (parentFQName.length() > 0) { - return parentFQName + "." + jetNamespace.getName(); + return parentFQName + "." + getFQName(jetNamespace.getHeader()); } } - return jetNamespace.getName(); // TODO: Must include module root namespace + return getFQName(jetNamespace.getHeader()); // TODO: Must include module root namespace + } + + private static String getFQName(JetNamespaceHeader header) { + StringBuilder builder = new StringBuilder(); + for (Iterator iterator = header.getParentNamespaceNames().iterator(); iterator.hasNext(); ) { + JetSimpleNameExpression nameExpression = iterator.next(); + builder.append(nameExpression.getReferencedName()); + builder.append("."); + } +// PsiElement nameIdentifier = header.getNameIdentifier(); + builder.append(header.getName()); + return builder.toString(); } public static String getFQName(JetClass jetClass) { diff --git a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java index 0f694b7e8e5..eebdbc8085e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java @@ -142,5 +142,5 @@ public interface JetNodeTypes { JetNodeType WHEN_CONDITION_IN_RANGE = new JetNodeType("WHEN_CONDITION_IN_RANGE", JetWhenConditionInRange.class); JetNodeType WHEN_CONDITION_IS_PATTERN = new JetNodeType("WHEN_CONDITION_IS_PATTERN", JetWhenConditionIsPattern.class); - JetNodeType NAMESPACE_NAME = new JetNodeType("NAMESPACE_NAME", JetContainerNode.class); + JetNodeType NAMESPACE_HEADER = new JetNodeType("NAMESPACE_HEADER", JetNamespaceHeader.class); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java index 814752f7eaa..479849c88c7 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java @@ -115,17 +115,18 @@ public class JetParsing extends AbstractJetParsing { * : modifiers "namespace" SimpleName{"."} SEMI? * ; */ + PsiBuilder.Marker namespaceHeader = mark(); PsiBuilder.Marker firstEntry = mark(); parseModifierList(MODIFIER_LIST, true); if (at(NAMESPACE_KEYWORD)) { advance(); // NAMESPACE_KEYWORD - parseNamespaceName(); if (at(LBRACE)) { // Because it's blocked namespace and it will be parsed as one of top level objects firstEntry.rollbackTo(); + namespaceHeader.done(NAMESPACE_HEADER); return; } @@ -135,6 +136,7 @@ public class JetParsing extends AbstractJetParsing { } else { firstEntry.rollbackTo(); } + namespaceHeader.done(NAMESPACE_HEADER); // TODO: Duplicate with parsing imports in parseToplevelDeclarations while (at(IMPORT_KEYWORD)) { @@ -145,12 +147,18 @@ public class JetParsing extends AbstractJetParsing { /* SimpleName{"."} */ private void parseNamespaceName() { PsiBuilder.Marker nsName = mark(); - expect(IDENTIFIER, "Expecting qualified name", NAMESPACE_NAME_RECOVERY_SET); - while (!eol() && at(DOT)) { - advance(); // DOT + while (true) { expect(IDENTIFIER, "Namespace name must be a '.'-separated identifier list", NAMESPACE_NAME_RECOVERY_SET); + if (at(DOT)) { + nsName.done(REFERENCE_EXPRESSION); + advance(); // DOT + nsName = mark(); + } + else { + nsName.drop(); + break; + } } - nsName.done(NAMESPACE_NAME); } /* @@ -378,6 +386,7 @@ public class JetParsing extends AbstractJetParsing { */ private JetNodeType parseNamespaceBlock() { assert _at(NAMESPACE_KEYWORD); + PsiBuilder.Marker namespaceHeader = mark(); advance(); // NAMESPACE_KEYWORD if (at(LBRACE)) { @@ -386,6 +395,7 @@ public class JetParsing extends AbstractJetParsing { else { parseNamespaceName(); } + namespaceHeader.done(NAMESPACE_HEADER); if (!at(LBRACE)) { error("A namespace block in '{...}' expected"); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.java index 139b9c20cba..66584c33157 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetAnnotatedExpression.java @@ -2,6 +2,7 @@ package org.jetbrains.jet.lang.psi; import com.intellij.lang.ASTNode; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; import java.util.ArrayList; @@ -26,6 +27,7 @@ public class JetAnnotatedExpression extends JetExpression { return visitor.visitAnnotatedExpression(this, data); } + @Nullable public JetExpression getBaseExpression() { return findChildByClass(JetExpression.class); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespace.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespace.java index 7be4847303e..aa82f6a2b35 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespace.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespace.java @@ -39,18 +39,23 @@ public class JetNamespace extends JetNamedDeclaration { } public String getName() { - PsiElement nameIdentifier = getNameIdentifier(); - return nameIdentifier != null ? nameIdentifier.getText() : ""; + String name = super.getName(); + return name == null ? "" : name; + } + + @NotNull + public JetNamespaceHeader getHeader() { + return (JetNamespaceHeader) findChildByType(JetNodeTypes.NAMESPACE_HEADER); } @Override public PsiElement getNameIdentifier() { - return findChildByType(JetNodeTypes.NAMESPACE_NAME); + return getHeader().getNameIdentifier(); } @Override public PsiElement setName(@NonNls @NotNull String name) throws IncorrectOperationException { - throw new UnsupportedOperationException(); // TODO + throw new UnsupportedOperationException(); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespaceHeader.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespaceHeader.java new file mode 100644 index 00000000000..c2f113fa3b7 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetNamespaceHeader.java @@ -0,0 +1,35 @@ +package org.jetbrains.jet.lang.psi; + +import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lexer.JetTokens; + +import java.util.List; + +/** + * @author abreslav + */ +public class JetNamespaceHeader extends JetElement { + public JetNamespaceHeader(@NotNull ASTNode node) { + super(node); + } + + @NotNull + public List getParentNamespaceNames() { + return findChildrenByType(JetNodeTypes.REFERENCE_EXPRESSION); + } + + @Nullable + public PsiElement getNameIdentifier() { + return findChildByType(JetTokens.IDENTIFIER); + } + + @Override + public String getName() { + PsiElement nameIdentifier = getNameIdentifier(); + return nameIdentifier == null ? "" : nameIdentifier.getText(); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java index 2585e655d35..61d117433f4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java @@ -69,19 +69,7 @@ public class TypeHierarchyResolver { declaration.accept(new JetVisitorVoid() { @Override public void visitNamespace(JetNamespace namespace) { - String name = JetPsiUtil.safeName(namespace.getName()); - - NamespaceDescriptorImpl namespaceDescriptor = owner.getNamespace(name); - if (namespaceDescriptor == null) { - namespaceDescriptor = new NamespaceDescriptorImpl( - owner.getOriginal(), - Collections.emptyList(), // TODO: annotations - name - ); - namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope")); - owner.addNamespace(namespaceDescriptor); - context.getTrace().record(BindingContext.NAMESPACE, namespace, namespaceDescriptor); - } + NamespaceDescriptorImpl namespaceDescriptor = createNamespaceDescriptorPathIfNeeded(namespace, owner); context.getNamespaceDescriptors().put(namespace, namespaceDescriptor); WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), new TraceBasedRedeclarationHandler(context.getTrace())); @@ -202,6 +190,35 @@ public class TypeHierarchyResolver { } } + private NamespaceDescriptorImpl createNamespaceDescriptorPathIfNeeded(JetNamespace namespace, NamespaceLike owner) { + NamespaceLike currentOwner = owner; + for (JetSimpleNameExpression nameExpression : namespace.getHeader().getParentNamespaceNames()) { + currentOwner = createNamespaceDescriptorIfNeeded(null, currentOwner, JetPsiUtil.safeName(nameExpression.getReferencedName())); + context.getTrace().record(REFERENCE_TARGET, nameExpression, currentOwner); + } + + String name = JetPsiUtil.safeName(namespace.getName()); + return createNamespaceDescriptorIfNeeded(namespace, currentOwner, name); + } + + @NotNull + private NamespaceDescriptorImpl createNamespaceDescriptorIfNeeded(@Nullable JetNamespace namespace, @NotNull NamespaceLike owner, @NotNull String name) { + NamespaceDescriptorImpl namespaceDescriptor = owner.getNamespace(name); + if (namespaceDescriptor == null) { + namespaceDescriptor = new NamespaceDescriptorImpl( + owner.getOriginal(), + Collections.emptyList(), // TODO: annotations + name + ); + namespaceDescriptor.initialize(new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, new TraceBasedRedeclarationHandler(context.getTrace())).setDebugName("Namespace member scope")); + owner.addNamespace(namespaceDescriptor); + if (namespace != null) { + context.getTrace().record(BindingContext.NAMESPACE, namespace, namespaceDescriptor); + } + } + return namespaceDescriptor; + } + @NotNull private ClassKind getClassKind(@NotNull JetClass jetClass) { if (jetClass.isTrait()) return ClassKind.TRAIT; diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt691.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt691.jet new file mode 100644 index 00000000000..e7194b099c9 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt691.jet @@ -0,0 +1,2 @@ +// KT-691 Allow to create nested namespaces with dot delimiter +namespace foo.bar.buz \ No newline at end of file diff --git a/compiler/testData/psi/AnnotatedExpressions.txt b/compiler/testData/psi/AnnotatedExpressions.txt index ff61f69c15d..e7be13766ce 100644 --- a/compiler/testData/psi/AnnotatedExpressions.txt +++ b/compiler/testData/psi/AnnotatedExpressions.txt @@ -1,5 +1,7 @@ JetFile: AnnotatedExpressions.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/AnonymousInitializer.txt b/compiler/testData/psi/AnonymousInitializer.txt index 5ef0ef3d0a3..cd55dd9b27c 100644 --- a/compiler/testData/psi/AnonymousInitializer.txt +++ b/compiler/testData/psi/AnonymousInitializer.txt @@ -1,5 +1,7 @@ JetFile: AnonymousInitializer.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Attributes.txt b/compiler/testData/psi/Attributes.txt index 150a51c535c..6cb067b94eb 100644 --- a/compiler/testData/psi/Attributes.txt +++ b/compiler/testData/psi/Attributes.txt @@ -1,11 +1,13 @@ JetFile: Attributes.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/AttributesOnPatterns.txt b/compiler/testData/psi/AttributesOnPatterns.txt index a20e639e803..545e0b1f3b1 100644 --- a/compiler/testData/psi/AttributesOnPatterns.txt +++ b/compiler/testData/psi/AttributesOnPatterns.txt @@ -1,5 +1,7 @@ JetFile: AttributesOnPatterns.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Attributes_ERR.txt b/compiler/testData/psi/Attributes_ERR.txt index 99f597d7dc9..0f8116df665 100644 --- a/compiler/testData/psi/Attributes_ERR.txt +++ b/compiler/testData/psi/Attributes_ERR.txt @@ -1,11 +1,13 @@ JetFile: Attributes_ERR.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/BabySteps.txt b/compiler/testData/psi/BabySteps.txt index 959b9d0b58b..fbdf8deeafb 100644 --- a/compiler/testData/psi/BabySteps.txt +++ b/compiler/testData/psi/BabySteps.txt @@ -1,8 +1,8 @@ JetFile: BabySteps.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiWhiteSpace('\n\n') CLASS diff --git a/compiler/testData/psi/BabySteps_ERR.txt b/compiler/testData/psi/BabySteps_ERR.txt index b6c52df6421..9f0a5ea788b 100644 --- a/compiler/testData/psi/BabySteps_ERR.txt +++ b/compiler/testData/psi/BabySteps_ERR.txt @@ -1,8 +1,8 @@ JetFile: BabySteps_ERR.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiWhiteSpace('\n\n') CLASS diff --git a/compiler/testData/psi/ByCaluses.txt b/compiler/testData/psi/ByCaluses.txt index f4e7ac5c5ef..0778b080397 100644 --- a/compiler/testData/psi/ByCaluses.txt +++ b/compiler/testData/psi/ByCaluses.txt @@ -1,5 +1,7 @@ JetFile: ByCaluses.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/CallWithManyClosures.txt b/compiler/testData/psi/CallWithManyClosures.txt index cfa70841880..d7516b299ae 100644 --- a/compiler/testData/psi/CallWithManyClosures.txt +++ b/compiler/testData/psi/CallWithManyClosures.txt @@ -1,5 +1,7 @@ JetFile: CallWithManyClosures.jet NAMESPACE + NAMESPACE_HEADER + PROPERTY PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/CallsInWhen.txt b/compiler/testData/psi/CallsInWhen.txt index c3992ac542b..4bde9526e87 100644 --- a/compiler/testData/psi/CallsInWhen.txt +++ b/compiler/testData/psi/CallsInWhen.txt @@ -1,5 +1,7 @@ JetFile: CallsInWhen.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Constructors.txt b/compiler/testData/psi/Constructors.txt index 399347a748b..1a133292303 100644 --- a/compiler/testData/psi/Constructors.txt +++ b/compiler/testData/psi/Constructors.txt @@ -1,5 +1,7 @@ JetFile: Constructors.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/ControlStructures.txt b/compiler/testData/psi/ControlStructures.txt index 8b7e70fd7d0..7f0b690968b 100644 --- a/compiler/testData/psi/ControlStructures.txt +++ b/compiler/testData/psi/ControlStructures.txt @@ -1,5 +1,7 @@ JetFile: ControlStructures.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/EOLsInComments.txt b/compiler/testData/psi/EOLsInComments.txt index c74b9a17704..5aed3791303 100644 --- a/compiler/testData/psi/EOLsInComments.txt +++ b/compiler/testData/psi/EOLsInComments.txt @@ -1,5 +1,7 @@ JetFile: EOLsInComments.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/EOLsOnRollback.txt b/compiler/testData/psi/EOLsOnRollback.txt index 57452bcd20b..6e085ffa275 100644 --- a/compiler/testData/psi/EOLsOnRollback.txt +++ b/compiler/testData/psi/EOLsOnRollback.txt @@ -1,5 +1,7 @@ JetFile: EOLsOnRollback.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/EmptyFile.txt b/compiler/testData/psi/EmptyFile.txt index 9cc81e6e40b..3630ef98bd5 100644 --- a/compiler/testData/psi/EmptyFile.txt +++ b/compiler/testData/psi/EmptyFile.txt @@ -1,3 +1,4 @@ JetFile: EmptyFile.jet NAMESPACE - \ No newline at end of file + NAMESPACE_HEADER + \ No newline at end of file diff --git a/compiler/testData/psi/Enums.txt b/compiler/testData/psi/Enums.txt index 0d99c824222..dfadca48ef1 100644 --- a/compiler/testData/psi/Enums.txt +++ b/compiler/testData/psi/Enums.txt @@ -1,5 +1,7 @@ JetFile: Enums.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(enum)('enum') diff --git a/compiler/testData/psi/Expressions_ERR.txt b/compiler/testData/psi/Expressions_ERR.txt index 456496b2c99..a9b043e82a6 100644 --- a/compiler/testData/psi/Expressions_ERR.txt +++ b/compiler/testData/psi/Expressions_ERR.txt @@ -1,5 +1,7 @@ JetFile: Expressions_ERR.jet NAMESPACE + NAMESPACE_HEADER + PROPERTY PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/FileStart_ERR.txt b/compiler/testData/psi/FileStart_ERR.txt index c1c82dcfa0e..87894ee76dd 100644 --- a/compiler/testData/psi/FileStart_ERR.txt +++ b/compiler/testData/psi/FileStart_ERR.txt @@ -1,12 +1,15 @@ JetFile: FileStart_ERR.jet NAMESPACE + NAMESPACE_HEADER + PsiErrorElement:Expecting namespace or top level declaration PsiElement(DIV)('/') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('bar') PsiErrorElement:A namespace block in '{...}' expected diff --git a/compiler/testData/psi/FunctionCalls.txt b/compiler/testData/psi/FunctionCalls.txt index c41151760ca..94f67c99444 100644 --- a/compiler/testData/psi/FunctionCalls.txt +++ b/compiler/testData/psi/FunctionCalls.txt @@ -1,5 +1,7 @@ JetFile: FunctionCalls.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/FunctionLiterals.txt b/compiler/testData/psi/FunctionLiterals.txt index 134e6ffc835..7bf48210b76 100644 --- a/compiler/testData/psi/FunctionLiterals.txt +++ b/compiler/testData/psi/FunctionLiterals.txt @@ -1,5 +1,7 @@ JetFile: FunctionLiterals.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/FunctionLiterals_ERR.txt b/compiler/testData/psi/FunctionLiterals_ERR.txt index 846d93a7a81..36f5a5db19b 100644 --- a/compiler/testData/psi/FunctionLiterals_ERR.txt +++ b/compiler/testData/psi/FunctionLiterals_ERR.txt @@ -1,5 +1,7 @@ JetFile: FunctionLiterals_ERR.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/FunctionTypes.txt b/compiler/testData/psi/FunctionTypes.txt index 1031efe47ac..47e8aa32ae6 100644 --- a/compiler/testData/psi/FunctionTypes.txt +++ b/compiler/testData/psi/FunctionTypes.txt @@ -1,5 +1,7 @@ JetFile: FunctionTypes.jet NAMESPACE + NAMESPACE_HEADER + TYPEDEF PsiElement(type)('type') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/FunctionTypes_ERR.txt b/compiler/testData/psi/FunctionTypes_ERR.txt index 2278bfb4388..80d5db63e38 100644 --- a/compiler/testData/psi/FunctionTypes_ERR.txt +++ b/compiler/testData/psi/FunctionTypes_ERR.txt @@ -1,5 +1,7 @@ JetFile: FunctionTypes_ERR.jet NAMESPACE + NAMESPACE_HEADER + TYPEDEF PsiElement(type)('type') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Functions.txt b/compiler/testData/psi/Functions.txt index 811bf8d332c..9626affdd1a 100644 --- a/compiler/testData/psi/Functions.txt +++ b/compiler/testData/psi/Functions.txt @@ -1,5 +1,7 @@ JetFile: Functions.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Functions_ERR.txt b/compiler/testData/psi/Functions_ERR.txt index 03213365ddb..9ed648f699f 100644 --- a/compiler/testData/psi/Functions_ERR.txt +++ b/compiler/testData/psi/Functions_ERR.txt @@ -1,5 +1,7 @@ JetFile: Functions_ERR.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/HangOnLonelyModifier.txt b/compiler/testData/psi/HangOnLonelyModifier.txt index 954cac7d2e8..6db3474d4f1 100644 --- a/compiler/testData/psi/HangOnLonelyModifier.txt +++ b/compiler/testData/psi/HangOnLonelyModifier.txt @@ -1,5 +1,7 @@ JetFile: HangOnLonelyModifier.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/IfWithPropery.txt b/compiler/testData/psi/IfWithPropery.txt index 6e3d344b660..96405038e50 100644 --- a/compiler/testData/psi/IfWithPropery.txt +++ b/compiler/testData/psi/IfWithPropery.txt @@ -1,5 +1,7 @@ JetFile: IfWithPropery.jet NAMESPACE + NAMESPACE_HEADER + PROPERTY PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/ImportSoftKW.txt b/compiler/testData/psi/ImportSoftKW.txt index fced8d0f720..ca54b63c6c6 100644 --- a/compiler/testData/psi/ImportSoftKW.txt +++ b/compiler/testData/psi/ImportSoftKW.txt @@ -1,5 +1,7 @@ JetFile: ImportSoftKW.jet NAMESPACE + NAMESPACE_HEADER + IMPORT_DIRECTIVE PsiElement(import)('import') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Imports.txt b/compiler/testData/psi/Imports.txt index 15bdd19d078..b80711ff1a2 100644 --- a/compiler/testData/psi/Imports.txt +++ b/compiler/testData/psi/Imports.txt @@ -1,11 +1,13 @@ JetFile: Imports.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/Imports_ERR.txt b/compiler/testData/psi/Imports_ERR.txt index 5ad833b88df..7e96a0f9b6a 100644 --- a/compiler/testData/psi/Imports_ERR.txt +++ b/compiler/testData/psi/Imports_ERR.txt @@ -1,11 +1,13 @@ JetFile: Imports_ERR.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/Labels.txt b/compiler/testData/psi/Labels.txt index 118356f871c..0a6972637ed 100644 --- a/compiler/testData/psi/Labels.txt +++ b/compiler/testData/psi/Labels.txt @@ -1,5 +1,7 @@ JetFile: Labels.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/LocalDeclarations.txt b/compiler/testData/psi/LocalDeclarations.txt index 67d9ad685fd..d9a4c472683 100644 --- a/compiler/testData/psi/LocalDeclarations.txt +++ b/compiler/testData/psi/LocalDeclarations.txt @@ -1,5 +1,7 @@ JetFile: LocalDeclarations.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/ModifierAsSelector.txt b/compiler/testData/psi/ModifierAsSelector.txt index 6f276e0dc0d..ccdf846073b 100644 --- a/compiler/testData/psi/ModifierAsSelector.txt +++ b/compiler/testData/psi/ModifierAsSelector.txt @@ -2,6 +2,8 @@ JetFile: ModifierAsSelector.jet PsiComment(EOL_COMMENT)('// JET-1') PsiWhiteSpace('\n\n') NAMESPACE + NAMESPACE_HEADER + PROPERTY PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/NamespaceBlock.txt b/compiler/testData/psi/NamespaceBlock.txt index 73f6e8c6e2d..1d32e0b59c6 100644 --- a/compiler/testData/psi/NamespaceBlock.txt +++ b/compiler/testData/psi/NamespaceBlock.txt @@ -1,11 +1,13 @@ JetFile: NamespaceBlock.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') @@ -20,9 +22,9 @@ JetFile: NamespaceBlock.jet PsiElement(IDENTIFIER)('bar') PsiWhiteSpace('\n\n') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foof') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') @@ -53,9 +55,9 @@ JetFile: NamespaceBlock.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') @@ -73,9 +75,9 @@ JetFile: NamespaceBlock.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('ns') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') @@ -116,9 +118,9 @@ JetFile: NamespaceBlock.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') @@ -127,9 +129,9 @@ JetFile: NamespaceBlock.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') diff --git a/compiler/testData/psi/NamespaceBlockFirst.txt b/compiler/testData/psi/NamespaceBlockFirst.txt index a115f637a28..daf5656d2ab 100644 --- a/compiler/testData/psi/NamespaceBlockFirst.txt +++ b/compiler/testData/psi/NamespaceBlockFirst.txt @@ -1,9 +1,11 @@ JetFile: NamespaceBlockFirst.jet NAMESPACE + NAMESPACE_HEADER + NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foobar') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') diff --git a/compiler/testData/psi/NamespaceBlock_ERR.txt b/compiler/testData/psi/NamespaceBlock_ERR.txt index 12e6c6278ae..1675b5bb0bc 100644 --- a/compiler/testData/psi/NamespaceBlock_ERR.txt +++ b/compiler/testData/psi/NamespaceBlock_ERR.txt @@ -1,11 +1,13 @@ JetFile: NamespaceBlock_ERR.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') @@ -69,9 +71,9 @@ JetFile: NamespaceBlock_ERR.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('bar') PsiWhiteSpace('\n\n') - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foof') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') @@ -190,9 +192,9 @@ JetFile: NamespaceBlock_ERR.jet PsiElement(SEMICOLON)(';') PsiWhiteSpace('\n\n ') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiErrorElement:A namespace block in '{...}' expected @@ -209,9 +211,10 @@ JetFile: NamespaceBlock_ERR.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n ') NAMESPACE - PsiElement(namespace)('namespace') - PsiErrorElement:Expecting namespace name - + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiErrorElement:Expecting namespace name + PsiWhiteSpace(' ') PsiElement(LBRACE)('{') PsiWhiteSpace('\n ') @@ -228,9 +231,9 @@ JetFile: NamespaceBlock_ERR.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n ') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('ns') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') @@ -279,17 +282,18 @@ JetFile: NamespaceBlock_ERR.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiErrorElement:A namespace block in '{...}' expected PsiWhiteSpace('\n\n') NAMESPACE - PsiElement(namespace)('namespace') - PsiErrorElement:Expecting namespace name - + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiErrorElement:Expecting namespace name + PsiWhiteSpace(' ') PsiElement(LBRACE)('{') NAMESPACE_BODY @@ -297,9 +301,9 @@ JetFile: NamespaceBlock_ERR.jet PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') diff --git a/compiler/testData/psi/NamespaceModifiers.txt b/compiler/testData/psi/NamespaceModifiers.txt index c167504da98..6dc1a3459f4 100644 --- a/compiler/testData/psi/NamespaceModifiers.txt +++ b/compiler/testData/psi/NamespaceModifiers.txt @@ -1,23 +1,23 @@ JetFile: NamespaceModifiers.jet NAMESPACE - MODIFIER_LIST - PsiElement(public)('public') + NAMESPACE_HEADER + MODIFIER_LIST + PsiElement(public)('public') + PsiWhiteSpace(' ') + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') + PsiElement(namespace)('namespace') PsiWhiteSpace(' ') - ANNOTATION - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME PsiElement(IDENTIFIER)('name') - PsiElement(SEMICOLON)(';') + PsiElement(SEMICOLON)(';') PsiWhiteSpace('\n\n') NAMESPACE MODIFIER_LIST @@ -31,9 +31,9 @@ JetFile: NamespaceModifiers.jet PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') @@ -48,9 +48,9 @@ JetFile: NamespaceModifiers.jet MODIFIER_LIST PsiElement(private)('private') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('b') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') diff --git a/compiler/testData/psi/NewLinesValidOperations.txt b/compiler/testData/psi/NewLinesValidOperations.txt index 22e86010779..7896a744e9e 100644 --- a/compiler/testData/psi/NewLinesValidOperations.txt +++ b/compiler/testData/psi/NewLinesValidOperations.txt @@ -1,5 +1,7 @@ JetFile: NewLinesValidOperations.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/NewlinesInParentheses.txt b/compiler/testData/psi/NewlinesInParentheses.txt index 2beb4a1aea6..95f9c053518 100644 --- a/compiler/testData/psi/NewlinesInParentheses.txt +++ b/compiler/testData/psi/NewlinesInParentheses.txt @@ -1,5 +1,7 @@ JetFile: NewlinesInParentheses.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/NotIsAndNotIn.txt b/compiler/testData/psi/NotIsAndNotIn.txt index 8d5c36ce4d1..e7c307344a7 100644 --- a/compiler/testData/psi/NotIsAndNotIn.txt +++ b/compiler/testData/psi/NotIsAndNotIn.txt @@ -1,5 +1,7 @@ JetFile: NotIsAndNotIn.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Precedence.txt b/compiler/testData/psi/Precedence.txt index 93567f53e3b..5ba29479d36 100644 --- a/compiler/testData/psi/Precedence.txt +++ b/compiler/testData/psi/Precedence.txt @@ -1,5 +1,7 @@ JetFile: Precedence.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/PredicateExpression.txt b/compiler/testData/psi/PredicateExpression.txt index 5992038b6fa..10bd6c000e3 100644 --- a/compiler/testData/psi/PredicateExpression.txt +++ b/compiler/testData/psi/PredicateExpression.txt @@ -1,5 +1,7 @@ JetFile: PredicateExpression.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/PrimaryConstructorModifiers_ERR.txt b/compiler/testData/psi/PrimaryConstructorModifiers_ERR.txt index 090d5cf7366..29d2758db0a 100644 --- a/compiler/testData/psi/PrimaryConstructorModifiers_ERR.txt +++ b/compiler/testData/psi/PrimaryConstructorModifiers_ERR.txt @@ -1,5 +1,7 @@ JetFile: PrimaryConstructorModifiers_ERR.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/Properties.txt b/compiler/testData/psi/Properties.txt index 17287b0a841..7a28c7ad671 100644 --- a/compiler/testData/psi/Properties.txt +++ b/compiler/testData/psi/Properties.txt @@ -1,5 +1,7 @@ JetFile: Properties.jet NAMESPACE + NAMESPACE_HEADER + PROPERTY PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/PropertiesFollowedByInitializers.txt b/compiler/testData/psi/PropertiesFollowedByInitializers.txt index d3171c40810..d297486d1ab 100644 --- a/compiler/testData/psi/PropertiesFollowedByInitializers.txt +++ b/compiler/testData/psi/PropertiesFollowedByInitializers.txt @@ -1,5 +1,7 @@ JetFile: PropertiesFollowedByInitializers.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Properties_ERR.txt b/compiler/testData/psi/Properties_ERR.txt index b4a8fc99fb2..7105c2c18b5 100644 --- a/compiler/testData/psi/Properties_ERR.txt +++ b/compiler/testData/psi/Properties_ERR.txt @@ -1,5 +1,7 @@ JetFile: Properties_ERR.jet NAMESPACE + NAMESPACE_HEADER + PROPERTY PsiElement(var)('var') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/QuotedIdentifiers.txt b/compiler/testData/psi/QuotedIdentifiers.txt index 43788d8c138..53cd3c4755d 100644 --- a/compiler/testData/psi/QuotedIdentifiers.txt +++ b/compiler/testData/psi/QuotedIdentifiers.txt @@ -1,5 +1,7 @@ JetFile: QuotedIdentifiers.jet NAMESPACE + NAMESPACE_HEADER + FUN MODIFIER_LIST ANNOTATION @@ -57,4 +59,4 @@ JetFile: QuotedIdentifiers.jet PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('`1`') TYPE_PARAMETER_LIST - + \ No newline at end of file diff --git a/compiler/testData/psi/RootNamespace.txt b/compiler/testData/psi/RootNamespace.txt index 4b1f87ba7ea..33f37629a7f 100644 --- a/compiler/testData/psi/RootNamespace.txt +++ b/compiler/testData/psi/RootNamespace.txt @@ -1,12 +1,13 @@ JetFile: RootNamespace.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('bar') - PsiElement(SEMICOLON)(';') + PsiElement(SEMICOLON)(';') PsiWhiteSpace('\n\n') CLASS PsiElement(class)('class') @@ -16,10 +17,11 @@ JetFile: RootNamespace.jet TYPE_PARAMETER_LIST NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/SemicolonAfterIf.txt b/compiler/testData/psi/SemicolonAfterIf.txt index fc8ce749f01..d986a16552b 100644 --- a/compiler/testData/psi/SemicolonAfterIf.txt +++ b/compiler/testData/psi/SemicolonAfterIf.txt @@ -1,5 +1,7 @@ JetFile: SemicolonAfterIf.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/ShortAnnotations.txt b/compiler/testData/psi/ShortAnnotations.txt index cf2cafe2284..cc795b1920f 100644 --- a/compiler/testData/psi/ShortAnnotations.txt +++ b/compiler/testData/psi/ShortAnnotations.txt @@ -1,57 +1,57 @@ JetFile: ShortAnnotations.jet NAMESPACE - MODIFIER_LIST - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + MODIFIER_LIST + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('buzz') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - VALUE_ARGUMENT - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('1') - PsiElement(RPAR)(')') + PsiElement(namespace)('namespace') PsiWhiteSpace(' ') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('buzz') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - VALUE_ARGUMENT - INTEGER_CONSTANT - PsiElement(INTEGER_LITERAL)('1') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('zoo') - PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME PsiElement(IDENTIFIER)('aa') PsiWhiteSpace('\n\n') NAMESPACE @@ -104,9 +104,9 @@ JetFile: ShortAnnotations.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') PsiElement(LBRACE)('{') diff --git a/compiler/testData/psi/SimpleClassMembers.txt b/compiler/testData/psi/SimpleClassMembers.txt index 8763cc9a78e..01652bba308 100644 --- a/compiler/testData/psi/SimpleClassMembers.txt +++ b/compiler/testData/psi/SimpleClassMembers.txt @@ -1,5 +1,7 @@ JetFile: SimpleClassMembers.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/SimpleClassMembers_ERR.txt b/compiler/testData/psi/SimpleClassMembers_ERR.txt index 5f9530a1671..b48c1f557b1 100644 --- a/compiler/testData/psi/SimpleClassMembers_ERR.txt +++ b/compiler/testData/psi/SimpleClassMembers_ERR.txt @@ -1,5 +1,7 @@ JetFile: SimpleClassMembers_ERR.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/SimpleExpressions.txt b/compiler/testData/psi/SimpleExpressions.txt index 16219eac0b0..45ce1f23b2f 100644 --- a/compiler/testData/psi/SimpleExpressions.txt +++ b/compiler/testData/psi/SimpleExpressions.txt @@ -1,5 +1,7 @@ JetFile: SimpleExpressions.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/SimpleModifiers.txt b/compiler/testData/psi/SimpleModifiers.txt index aca1212c64b..4df3f2f9c98 100644 --- a/compiler/testData/psi/SimpleModifiers.txt +++ b/compiler/testData/psi/SimpleModifiers.txt @@ -1,11 +1,13 @@ JetFile: SimpleModifiers.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/SoftKeywords.txt b/compiler/testData/psi/SoftKeywords.txt index eb76e1c326c..01fccd725d8 100644 --- a/compiler/testData/psi/SoftKeywords.txt +++ b/compiler/testData/psi/SoftKeywords.txt @@ -1,11 +1,13 @@ JetFile: SoftKeywords.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/SoftKeywordsInTypeArguments.txt b/compiler/testData/psi/SoftKeywordsInTypeArguments.txt index ebaa0fcb051..6f88bc2d16e 100644 --- a/compiler/testData/psi/SoftKeywordsInTypeArguments.txt +++ b/compiler/testData/psi/SoftKeywordsInTypeArguments.txt @@ -1,5 +1,7 @@ JetFile: SoftKeywordsInTypeArguments.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/StringTemplates.txt b/compiler/testData/psi/StringTemplates.txt index f393dac23ea..1fc2653edcb 100644 --- a/compiler/testData/psi/StringTemplates.txt +++ b/compiler/testData/psi/StringTemplates.txt @@ -1,5 +1,7 @@ JetFile: StringTemplates.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/Super.txt b/compiler/testData/psi/Super.txt index c9cd569dcaa..37b48197ade 100644 --- a/compiler/testData/psi/Super.txt +++ b/compiler/testData/psi/Super.txt @@ -2,6 +2,8 @@ JetFile: Super.jet PsiComment(EOL_COMMENT)('// KT-156 Fix the this syntax') PsiWhiteSpace('\n') NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/ThisType.txt b/compiler/testData/psi/ThisType.txt index dfbca2d3240..99abcb37b6b 100644 --- a/compiler/testData/psi/ThisType.txt +++ b/compiler/testData/psi/ThisType.txt @@ -1,5 +1,7 @@ JetFile: ThisType.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/TupleTypes.txt b/compiler/testData/psi/TupleTypes.txt index 8ed6a23a10a..cb44ded1528 100644 --- a/compiler/testData/psi/TupleTypes.txt +++ b/compiler/testData/psi/TupleTypes.txt @@ -1,5 +1,7 @@ JetFile: TupleTypes.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/TupleTypes_ERR.txt b/compiler/testData/psi/TupleTypes_ERR.txt index 5a2e46aa6eb..5b984020566 100644 --- a/compiler/testData/psi/TupleTypes_ERR.txt +++ b/compiler/testData/psi/TupleTypes_ERR.txt @@ -1,5 +1,7 @@ JetFile: TupleTypes_ERR.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/TuplesWithLabeledEntries.txt b/compiler/testData/psi/TuplesWithLabeledEntries.txt index b1f0de58d24..bb38c8417a9 100644 --- a/compiler/testData/psi/TuplesWithLabeledEntries.txt +++ b/compiler/testData/psi/TuplesWithLabeledEntries.txt @@ -1,5 +1,7 @@ JetFile: TuplesWithLabeledEntries.jet NAMESPACE + NAMESPACE_HEADER + PROPERTY PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/TypeAnnotations.txt b/compiler/testData/psi/TypeAnnotations.txt index ad5453b1cf0..573f4afb5a6 100644 --- a/compiler/testData/psi/TypeAnnotations.txt +++ b/compiler/testData/psi/TypeAnnotations.txt @@ -1,5 +1,7 @@ JetFile: TypeAnnotations.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/TypeConstraints.txt b/compiler/testData/psi/TypeConstraints.txt index a7b245da2ed..8f1d93ed4bd 100644 --- a/compiler/testData/psi/TypeConstraints.txt +++ b/compiler/testData/psi/TypeConstraints.txt @@ -1,5 +1,7 @@ JetFile: TypeConstraints.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/TypeDef.txt b/compiler/testData/psi/TypeDef.txt index 9fc34848eab..f55ffb3a657 100644 --- a/compiler/testData/psi/TypeDef.txt +++ b/compiler/testData/psi/TypeDef.txt @@ -1,11 +1,13 @@ JetFile: TypeDef.jet NAMESPACE - PsiElement(namespace)('namespace') - PsiWhiteSpace(' ') - NAMESPACE_NAME - PsiElement(IDENTIFIER)('foo') + NAMESPACE_HEADER + PsiElement(namespace)('namespace') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') PsiElement(IDENTIFIER)('goo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/TypeDef_ERR.txt b/compiler/testData/psi/TypeDef_ERR.txt index e005e0664bb..4a7f784651d 100644 --- a/compiler/testData/psi/TypeDef_ERR.txt +++ b/compiler/testData/psi/TypeDef_ERR.txt @@ -1,5 +1,7 @@ JetFile: TypeDef_ERR.jet NAMESPACE + NAMESPACE_HEADER + TYPEDEF PsiElement(type)('type') PsiErrorElement:Type name expected diff --git a/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt b/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt index 433bb1c6922..b6eea49385d 100644 --- a/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt +++ b/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt @@ -1,5 +1,7 @@ JetFile: TypeExpressionAmbiguities_ERR.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/TypeParametersBeforeName.txt b/compiler/testData/psi/TypeParametersBeforeName.txt index 7f719787d19..345481b0c8f 100644 --- a/compiler/testData/psi/TypeParametersBeforeName.txt +++ b/compiler/testData/psi/TypeParametersBeforeName.txt @@ -1,5 +1,7 @@ JetFile: TypeParametersBeforeName.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/When.txt b/compiler/testData/psi/When.txt index 7abeb1afcb3..c78e94c6686 100644 --- a/compiler/testData/psi/When.txt +++ b/compiler/testData/psi/When.txt @@ -1,5 +1,7 @@ JetFile: When.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/When_ERR.txt b/compiler/testData/psi/When_ERR.txt index 64b931828e9..08dede49af4 100644 --- a/compiler/testData/psi/When_ERR.txt +++ b/compiler/testData/psi/When_ERR.txt @@ -1,5 +1,7 @@ JetFile: When_ERR.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/AnonymousObjects.txt b/compiler/testData/psi/examples/AnonymousObjects.txt index bab77c6c07b..1847e605f81 100644 --- a/compiler/testData/psi/examples/AnonymousObjects.txt +++ b/compiler/testData/psi/examples/AnonymousObjects.txt @@ -1,5 +1,7 @@ JetFile: AnonymousObjects.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/BinaryTree.txt b/compiler/testData/psi/examples/BinaryTree.txt index 41e839f7454..af51d25fcf8 100644 --- a/compiler/testData/psi/examples/BinaryTree.txt +++ b/compiler/testData/psi/examples/BinaryTree.txt @@ -1,5 +1,7 @@ JetFile: BinaryTree.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/BitArith.txt b/compiler/testData/psi/examples/BitArith.txt index dba6f016498..0991ff593b6 100644 --- a/compiler/testData/psi/examples/BitArith.txt +++ b/compiler/testData/psi/examples/BitArith.txt @@ -1,5 +1,7 @@ JetFile: BitArith.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/Builder.txt b/compiler/testData/psi/examples/Builder.txt index 3f34447a17d..2be62e21682 100644 --- a/compiler/testData/psi/examples/Builder.txt +++ b/compiler/testData/psi/examples/Builder.txt @@ -1,5 +1,7 @@ JetFile: Builder.jet NAMESPACE + NAMESPACE_HEADER + PROPERTY PsiElement(val)('val') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/Color.txt b/compiler/testData/psi/examples/Color.txt index 76c5d33a5da..f11a62f5f02 100644 --- a/compiler/testData/psi/examples/Color.txt +++ b/compiler/testData/psi/examples/Color.txt @@ -1,5 +1,7 @@ JetFile: Color.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(enum)('enum') diff --git a/compiler/testData/psi/examples/FunctionsAndTypes.txt b/compiler/testData/psi/examples/FunctionsAndTypes.txt index 6b2c0dfd160..ca829289aac 100644 --- a/compiler/testData/psi/examples/FunctionsAndTypes.txt +++ b/compiler/testData/psi/examples/FunctionsAndTypes.txt @@ -1,5 +1,7 @@ JetFile: FunctionsAndTypes.jet NAMESPACE + NAMESPACE_HEADER + TYPEDEF PsiElement(type)('type') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/Graph.txt b/compiler/testData/psi/examples/Graph.txt index a21315c0896..2cb4dd908c6 100644 --- a/compiler/testData/psi/examples/Graph.txt +++ b/compiler/testData/psi/examples/Graph.txt @@ -1,5 +1,7 @@ JetFile: Graph.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/IPushPop.txt b/compiler/testData/psi/examples/IPushPop.txt index ba028b8aa59..5ae4e0e28fd 100644 --- a/compiler/testData/psi/examples/IPushPop.txt +++ b/compiler/testData/psi/examples/IPushPop.txt @@ -1,5 +1,7 @@ JetFile: IPushPop.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/LINQ.txt b/compiler/testData/psi/examples/LINQ.txt index e066a2a3c28..98e0b166b64 100644 --- a/compiler/testData/psi/examples/LINQ.txt +++ b/compiler/testData/psi/examples/LINQ.txt @@ -1,5 +1,7 @@ JetFile: LINQ.jet NAMESPACE + NAMESPACE_HEADER + FUN PsiElement(fun)('fun') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/PolymorphicClassObjects.txt b/compiler/testData/psi/examples/PolymorphicClassObjects.txt index 0ecb4dce0fe..9a59c5766da 100644 --- a/compiler/testData/psi/examples/PolymorphicClassObjects.txt +++ b/compiler/testData/psi/examples/PolymorphicClassObjects.txt @@ -1,5 +1,7 @@ JetFile: PolymorphicClassObjects.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/Queue.txt b/compiler/testData/psi/examples/Queue.txt index 335c7217d56..ceee4f838c4 100644 --- a/compiler/testData/psi/examples/Queue.txt +++ b/compiler/testData/psi/examples/Queue.txt @@ -1,5 +1,7 @@ JetFile: Queue.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/Stack.txt b/compiler/testData/psi/examples/Stack.txt index 6a90e15f08e..792dd9c5f01 100644 --- a/compiler/testData/psi/examples/Stack.txt +++ b/compiler/testData/psi/examples/Stack.txt @@ -1,5 +1,7 @@ JetFile: Stack.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/UnionFind.txt b/compiler/testData/psi/examples/UnionFind.txt index a349879dc7d..30d3e98e16a 100644 --- a/compiler/testData/psi/examples/UnionFind.txt +++ b/compiler/testData/psi/examples/UnionFind.txt @@ -1,5 +1,7 @@ JetFile: UnionFind.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/UpdateOperation.txt b/compiler/testData/psi/examples/UpdateOperation.txt index c624c2a4f1c..5b94e332274 100644 --- a/compiler/testData/psi/examples/UpdateOperation.txt +++ b/compiler/testData/psi/examples/UpdateOperation.txt @@ -1,5 +1,7 @@ JetFile: UpdateOperation.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/With.txt b/compiler/testData/psi/examples/With.txt index 25fdde079e5..468588f148e 100644 --- a/compiler/testData/psi/examples/With.txt +++ b/compiler/testData/psi/examples/With.txt @@ -1,5 +1,7 @@ JetFile: With.jet NAMESPACE + NAMESPACE_HEADER + FUN MODIFIER_LIST ANNOTATION diff --git a/compiler/testData/psi/examples/array/MutableArray.txt b/compiler/testData/psi/examples/array/MutableArray.txt index daa31179dbd..18940203294 100644 --- a/compiler/testData/psi/examples/array/MutableArray.txt +++ b/compiler/testData/psi/examples/array/MutableArray.txt @@ -2,6 +2,8 @@ JetFile: MutableArray.jet PsiComment(DOC_COMMENT)('/**\n These declarations are "shallow" in the sense that they are not really compiled, only the type-checker uses them\n*/') PsiWhiteSpace('\n\n') NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/ArrayList.txt b/compiler/testData/psi/examples/collections/ArrayList.txt index 4ca13335330..6bd72ad11fd 100644 --- a/compiler/testData/psi/examples/collections/ArrayList.txt +++ b/compiler/testData/psi/examples/collections/ArrayList.txt @@ -1,5 +1,7 @@ JetFile: ArrayList.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/collections/HashMap.txt b/compiler/testData/psi/examples/collections/HashMap.txt index 4b00e65faa7..e97bcd16428 100644 --- a/compiler/testData/psi/examples/collections/HashMap.txt +++ b/compiler/testData/psi/examples/collections/HashMap.txt @@ -1,5 +1,7 @@ JetFile: HashMap.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/IIterable.txt b/compiler/testData/psi/examples/collections/IIterable.txt index 8b426629e5a..a767932aab0 100644 --- a/compiler/testData/psi/examples/collections/IIterable.txt +++ b/compiler/testData/psi/examples/collections/IIterable.txt @@ -1,5 +1,7 @@ JetFile: IIterable.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/IIterator.txt b/compiler/testData/psi/examples/collections/IIterator.txt index a11d81c631e..3fd80a65235 100644 --- a/compiler/testData/psi/examples/collections/IIterator.txt +++ b/compiler/testData/psi/examples/collections/IIterator.txt @@ -1,5 +1,7 @@ JetFile: IIterator.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/IList.txt b/compiler/testData/psi/examples/collections/IList.txt index 36ff6a29f39..c7f47cd7b68 100644 --- a/compiler/testData/psi/examples/collections/IList.txt +++ b/compiler/testData/psi/examples/collections/IList.txt @@ -1,5 +1,7 @@ JetFile: IList.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/IMutableIterable.txt b/compiler/testData/psi/examples/collections/IMutableIterable.txt index 4e443c5ca4b..4e8045be4e7 100644 --- a/compiler/testData/psi/examples/collections/IMutableIterable.txt +++ b/compiler/testData/psi/examples/collections/IMutableIterable.txt @@ -1,5 +1,7 @@ JetFile: IMutableIterable.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/IMutableIterator.txt b/compiler/testData/psi/examples/collections/IMutableIterator.txt index 4a92a5971d5..25421b6ea8b 100644 --- a/compiler/testData/psi/examples/collections/IMutableIterator.txt +++ b/compiler/testData/psi/examples/collections/IMutableIterator.txt @@ -1,5 +1,7 @@ JetFile: IMutableIterator.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/IMutableList.txt b/compiler/testData/psi/examples/collections/IMutableList.txt index 0fce42fbf1f..8fc0597605e 100644 --- a/compiler/testData/psi/examples/collections/IMutableList.txt +++ b/compiler/testData/psi/examples/collections/IMutableList.txt @@ -1,5 +1,7 @@ JetFile: IMutableList.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/IMutableSet.txt b/compiler/testData/psi/examples/collections/IMutableSet.txt index 82c94b8ff19..750cc6af8d3 100644 --- a/compiler/testData/psi/examples/collections/IMutableSet.txt +++ b/compiler/testData/psi/examples/collections/IMutableSet.txt @@ -1,5 +1,7 @@ JetFile: IMutableSet.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/ISet.txt b/compiler/testData/psi/examples/collections/ISet.txt index f1736c73dee..cf51b2dcf92 100644 --- a/compiler/testData/psi/examples/collections/ISet.txt +++ b/compiler/testData/psi/examples/collections/ISet.txt @@ -1,5 +1,7 @@ JetFile: ISet.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/ISized.txt b/compiler/testData/psi/examples/collections/ISized.txt index dacafb7e2eb..96b49ef23b1 100644 --- a/compiler/testData/psi/examples/collections/ISized.txt +++ b/compiler/testData/psi/examples/collections/ISized.txt @@ -1,5 +1,7 @@ JetFile: ISized.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/collections/LinkedList.txt b/compiler/testData/psi/examples/collections/LinkedList.txt index 70ecbe15074..adf1971dab2 100644 --- a/compiler/testData/psi/examples/collections/LinkedList.txt +++ b/compiler/testData/psi/examples/collections/LinkedList.txt @@ -1,5 +1,7 @@ JetFile: LinkedList.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/collections/List.txt b/compiler/testData/psi/examples/collections/List.txt index 3fcf3bfc95b..c6ec2bd2abe 100644 --- a/compiler/testData/psi/examples/collections/List.txt +++ b/compiler/testData/psi/examples/collections/List.txt @@ -1,5 +1,7 @@ JetFile: List.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(enum)('enum') diff --git a/compiler/testData/psi/examples/io/IOSamples.txt b/compiler/testData/psi/examples/io/IOSamples.txt index 4cdd7d38a23..c06355b8788 100644 --- a/compiler/testData/psi/examples/io/IOSamples.txt +++ b/compiler/testData/psi/examples/io/IOSamples.txt @@ -1,5 +1,7 @@ JetFile: IOSamples.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/map/IMap.txt b/compiler/testData/psi/examples/map/IMap.txt index 569ba8cb241..5607459c1ec 100644 --- a/compiler/testData/psi/examples/map/IMap.txt +++ b/compiler/testData/psi/examples/map/IMap.txt @@ -1,5 +1,7 @@ JetFile: IMap.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/priorityqueues/BinaryHeap.txt b/compiler/testData/psi/examples/priorityqueues/BinaryHeap.txt index d585bc8ffed..32334433a09 100644 --- a/compiler/testData/psi/examples/priorityqueues/BinaryHeap.txt +++ b/compiler/testData/psi/examples/priorityqueues/BinaryHeap.txt @@ -1,5 +1,7 @@ JetFile: BinaryHeap.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/priorityqueues/IPriorityQueue.txt b/compiler/testData/psi/examples/priorityqueues/IPriorityQueue.txt index 626b44d7c56..ee601c3b1dc 100644 --- a/compiler/testData/psi/examples/priorityqueues/IPriorityQueue.txt +++ b/compiler/testData/psi/examples/priorityqueues/IPriorityQueue.txt @@ -1,5 +1,7 @@ JetFile: IPriorityQueue.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open') diff --git a/compiler/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.txt b/compiler/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.txt index dcc8cfb2507..e87b64f65d5 100644 --- a/compiler/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.txt +++ b/compiler/testData/psi/examples/priorityqueues/PriorityQueueAsPushPop.txt @@ -1,5 +1,7 @@ JetFile: PriorityQueueAsPushPop.jet NAMESPACE + NAMESPACE_HEADER + CLASS PsiElement(class)('class') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/util/Comparison.txt b/compiler/testData/psi/examples/util/Comparison.txt index d16d5a10c00..53e19e4cb0c 100644 --- a/compiler/testData/psi/examples/util/Comparison.txt +++ b/compiler/testData/psi/examples/util/Comparison.txt @@ -1,5 +1,7 @@ JetFile: Comparison.jet NAMESPACE + NAMESPACE_HEADER + TYPEDEF PsiElement(type)('type') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/examples/util/IComparable.txt b/compiler/testData/psi/examples/util/IComparable.txt index 9404cdf4eb1..ae8468ffb86 100644 --- a/compiler/testData/psi/examples/util/IComparable.txt +++ b/compiler/testData/psi/examples/util/IComparable.txt @@ -1,5 +1,7 @@ JetFile: IComparable.jet NAMESPACE + NAMESPACE_HEADER + CLASS MODIFIER_LIST PsiElement(open)('open')