From 25af9bbcad41db5f463312e791048115325249af Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Thu, 24 Nov 2011 22:42:15 +0300 Subject: [PATCH 01/11] By Sergey Ignatov: creating JetParameters in JetPsiFactory --- .../src/org/jetbrains/jet/lang/psi/JetPsiFactory.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java index 4c0dced694d..e01dfdaeee4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiFactory.java @@ -87,6 +87,11 @@ public class JetPsiFactory { return function.getBodyExpression(); } + public static JetParameter createParameter(Project project, String name, String type) { + JetNamedFunction function = createFunction(project, "fun foo(" + name + " : " + type + ") {}"); + return function.getValueParameters().get(0); + } + public static JetNamespace createNamespace(Project project, String text) { JetFile file = createFile(project, text); return file.getRootNamespace(); @@ -96,7 +101,7 @@ public class JetPsiFactory { JetNamespace namespace = createNamespace(project, "import " + classPath); return namespace.getImportDirectives().iterator().next(); } - + public static PsiElement createPrimaryConstructor(Project project) { JetClass aClass = createClass(project, "class A()"); return aClass.findElementAt(7).getParent(); From c3447c35767d911d2d428d78898f15196ece6a04 Mon Sep 17 00:00:00 2001 From: svtk Date: Fri, 25 Nov 2011 15:14:38 +0400 Subject: [PATCH 02/11] refactoring & KT-607 Val reassignment is not marked as an error --- .../cfg/JetControlFlowGraphTraverser.java | 12 +- .../lang/cfg/JetFlowInformationProvider.java | 342 ++++++++++-------- .../jetbrains/jet/lang/psi/JetPsiUtil.java | 6 +- .../jet/lang/resolve/BindingContextUtils.java | 1 + .../jet/lang/resolve/ControlFlowAnalyzer.java | 10 +- .../jet/lang/resolve/TopDownAnalyzer.java | 4 +- .../UninitializedOrReassignedVariables.jet | 4 +- .../quick/regressions/kt607.jet | 18 + 8 files changed, 228 insertions(+), 169 deletions(-) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt607.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser.java index d9b090ff885..9eda16b291a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowGraphTraverser.java @@ -31,7 +31,7 @@ public class JetControlFlowGraphTraverser { } public void collectInformationFromInstructionGraph( - InstructionsMergeStrategy instructionsMergeStrategy, + InstructionDataMergeStrategy instructionDataMergeStrategy, D initialDataValue, D initialDataValueForEnterInstruction, boolean straightDirection) { @@ -43,7 +43,7 @@ public class JetControlFlowGraphTraverser { changed[0] = true; while (changed[0]) { changed[0] = false; - traverseSubGraph(pseudocode, instructionsMergeStrategy, Collections.emptyList(), straightDirection, changed, false); + traverseSubGraph(pseudocode, instructionDataMergeStrategy, Collections.emptyList(), straightDirection, changed, false); } } @@ -62,7 +62,7 @@ public class JetControlFlowGraphTraverser { private void traverseSubGraph( Pseudocode pseudocode, - InstructionsMergeStrategy instructionsMergeStrategy, + InstructionDataMergeStrategy instructionDataMergeStrategy, Collection previousSubGraphInstructions, boolean straightDirection, boolean[] changed, @@ -87,7 +87,7 @@ public class JetControlFlowGraphTraverser { if (lookInside && instruction instanceof LocalDeclarationInstruction) { Pseudocode subroutinePseudocode = ((LocalDeclarationInstruction) instruction).getBody(); - traverseSubGraph(subroutinePseudocode, instructionsMergeStrategy, previousInstructions, straightDirection, changed, true); + traverseSubGraph(subroutinePseudocode, instructionDataMergeStrategy, previousInstructions, straightDirection, changed, true); } Pair previousDataValue = dataMap.get(instruction); @@ -99,7 +99,7 @@ public class JetControlFlowGraphTraverser { incomingEdgesData.add(previousData.getSecond()); } } - Pair mergedData = instructionsMergeStrategy.execute(instruction, incomingEdgesData); + Pair mergedData = instructionDataMergeStrategy.execute(instruction, incomingEdgesData); if (!mergedData.equals(previousDataValue)) { changed[0] = true; dataMap.put(instruction, mergedData); @@ -132,7 +132,7 @@ public class JetControlFlowGraphTraverser { return dataMap.get(pseudocode.getSinkInstruction()).getFirst(); } - interface InstructionsMergeStrategy { + interface InstructionDataMergeStrategy { Pair execute(Instruction instruction, @NotNull Collection incomingEdgesData); } 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 426048e91fb..c88b2264c5d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java @@ -187,176 +187,204 @@ public class JetFlowInformationProvider { return JetPsiUtil.findRootExpressions(unreachableElements); } - public void markUninitializedVariables(@NotNull JetElement subroutine, final boolean inAnonymousInitializers, final boolean inLocalDeclaration) { +//////////////////////////////////////////////////////////////////////////////// +// Uninitialized variables analysis + + public void markUninitializedVariables(@NotNull JetElement subroutine, final boolean processLocalDeclaration) { final Pseudocode pseudocode = pseudocodeMap.get(subroutine); assert pseudocode != null; - JetControlFlowGraphTraverser> traverser = JetControlFlowGraphTraverser.create(pseudocode, false); - - JetControlFlowGraphTraverser.InstructionsMergeStrategy> instructionsMergeStrategy = - new JetControlFlowGraphTraverser.InstructionsMergeStrategy>() { - @Override - public Pair, Map> execute( - Instruction instruction, - @NotNull Collection> incomingEdgesData) { - - Set variablesInScope = Sets.newHashSet(); - for (Map edgePointsMap : incomingEdgesData) { - variablesInScope.addAll(edgePointsMap.keySet()); - } - - Map enterInstructionPointsMap = Maps.newHashMap(); - for (VariableDescriptor variable : variablesInScope) { - Set edgesDataForVariable = Sets.newHashSet(); - for (Map edgePointsMap : incomingEdgesData) { - InitializationPoints points = edgePointsMap.get(variable); - if (points != null) { - edgesDataForVariable.add(points); - } - } - enterInstructionPointsMap.put(variable, new InitializationPoints(edgesDataForVariable)); - } - - Map exitInstructionPointsMap = Maps.newHashMap(enterInstructionPointsMap); - if (instruction instanceof WriteValueInstruction) { - VariableDescriptor variable = extractVariableDescriptorIfAny(instruction, false); - InitializationPoints initializationAtThisPoint = new InitializationPoints(((WriteValueInstruction) instruction).getElement()); - exitInstructionPointsMap.put(variable, initializationAtThisPoint); - } - - return Pair.create(enterInstructionPointsMap, exitInstructionPointsMap); - } - }; + JetControlFlowGraphTraverser> traverser = JetControlFlowGraphTraverser.create(pseudocode, false); Collection usedVariables = collectUsedVariables(pseudocode); final Collection declaredVariables = collectDeclaredVariables(subroutine); - Map initialMapForStartInstruction = prepareInitialMapForStartInstruction(usedVariables, declaredVariables); - - traverser.collectInformationFromInstructionGraph(instructionsMergeStrategy, - Collections.emptyMap(), - initialMapForStartInstruction, - true); + Map initialMapForStartInstruction = prepareInitialMapForStartInstruction(usedVariables, declaredVariables); + + JetControlFlowGraphTraverser.InstructionDataMergeStrategy> variableInitializersMergeStrategy = + new JetControlFlowGraphTraverser.InstructionDataMergeStrategy>() { + @Override + public Pair, Map> execute( + Instruction instruction, + @NotNull Collection> incomingEdgesData) { + + Map enterInstructionData = mergeIncomingEdgesData(incomingEdgesData); + Map exitInstructionData = addVariableInitializerFromCurrentInstructionIfAny(instruction, enterInstructionData); + return Pair.create(enterInstructionData, exitInstructionData); + } + }; + + traverser.collectInformationFromInstructionGraph(variableInitializersMergeStrategy, Collections.emptyMap(), initialMapForStartInstruction, true); final Collection varWithUninitializedErrorGenerated = Sets.newHashSet(); final Collection varWithValReassignErrorGenerated = Sets.newHashSet(); - traverser.traverseAndAnalyzeInstructionGraph(new JetControlFlowGraphTraverser.InstructionDataAnalyzeStrategy>() { + final boolean processClassOrObject = subroutine instanceof JetClassOrObject; + traverser.traverseAndAnalyzeInstructionGraph(new JetControlFlowGraphTraverser.InstructionDataAnalyzeStrategy>() { @Override - public void execute(Instruction instruction, @Nullable Map enterData, @Nullable Map exitData) { + public void execute(Instruction instruction, @Nullable Map enterData, @Nullable Map exitData) { assert enterData != null && exitData != null; if (instruction instanceof ReadValueInstruction) { VariableDescriptor variableDescriptor = extractVariableDescriptorIfAny(instruction, false); - JetElement element = ((ReadValueInstruction) instruction).getElement(); - if (element instanceof JetSimpleNameExpression && variableDescriptor != null && declaredVariables.contains(variableDescriptor)) { - - InitializationPoints exitInitializationPoints = exitData.get(variableDescriptor); - assert exitInitializationPoints != null; - - boolean isInitialized = exitInitializationPoints.isInitialized(); - if (variableDescriptor instanceof PropertyDescriptor) { - if (!trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor)) { - isInitialized = true; - } - } - if (!inLocalDeclaration && !isInitialized && !varWithUninitializedErrorGenerated.contains(variableDescriptor)) { - varWithUninitializedErrorGenerated.add(variableDescriptor); - trace.report(Errors.UNINITIALIZED_VARIABLE.on((JetSimpleNameExpression) element, variableDescriptor)); - } + if (variableDescriptor != null && declaredVariables.contains(variableDescriptor)) { + checkIsInitialized(variableDescriptor, ((ReadValueInstruction) instruction).getElement(), exitData.get(variableDescriptor), varWithUninitializedErrorGenerated); } } else if (instruction instanceof WriteValueInstruction) { - JetElement element = ((WriteValueInstruction) instruction).getlValue(); VariableDescriptor variableDescriptor = extractVariableDescriptorIfAny(instruction, true); - if (element instanceof JetExpression && variableDescriptor != null) { - InitializationPoints enterInitializationPoints = enterData.get(variableDescriptor); - assert enterInitializationPoints != null; - InitializationPoints exitInitializationPoints = exitData.get(variableDescriptor); - assert exitInitializationPoints != null; - Set possiblePoints = enterInitializationPoints.getPossiblePoints(); - boolean hasInitializer = !possiblePoints.isEmpty() || enterInitializationPoints.isInitialized(); - if (possiblePoints.size() == 1) { - JetElement initializer = possiblePoints.iterator().next(); - if (initializer instanceof JetProperty && initializer == element.getParent()) { - hasInitializer = false; - } + JetElement element = ((WriteValueInstruction) instruction).getlValue(); + if (variableDescriptor != null && element instanceof JetExpression) { + if (!processLocalDeclaration) { // error has been generated before while processing outer function of this local declaration + checkValReassignment(variableDescriptor, (JetExpression) element, enterData.get(variableDescriptor), varWithValReassignErrorGenerated); } - JetExpression expression = (JetExpression) element; - if (!inLocalDeclaration && hasInitializer && !variableDescriptor.isVar() && !varWithValReassignErrorGenerated.contains(variableDescriptor)) { - PsiElement psiElement = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, variableDescriptor); - JetProperty property = psiElement instanceof JetProperty ? (JetProperty) psiElement : null; - varWithValReassignErrorGenerated.add(variableDescriptor); - boolean hasReassignMethodReturningUnit = false; - JetSimpleNameExpression operationReference = null; - PsiElement parent = expression.getParent(); - if (parent instanceof JetBinaryExpression) { - operationReference = ((JetBinaryExpression) parent).getOperationReference(); - } - else if (parent instanceof JetUnaryExpression) { - operationReference = ((JetUnaryExpression) parent).getOperationSign(); - } - if (operationReference != null) { - DeclarationDescriptor descriptor = trace.get(BindingContext.REFERENCE_TARGET, operationReference); - if (descriptor instanceof FunctionDescriptor) { - if (JetStandardClasses.isUnit(((FunctionDescriptor) descriptor).getReturnType())) { - hasReassignMethodReturningUnit = true; - } - } - } - if (!hasReassignMethodReturningUnit) { - trace.report(Errors.VAL_REASSIGNMENT.on(expression, variableDescriptor, property == null ? new JetProperty[0] : new JetProperty[]{property})); - } - } - if (inAnonymousInitializers && variableDescriptor instanceof PropertyDescriptor && !enterInitializationPoints.isInitialized() && - exitInitializationPoints.isInitialized()) { - JetExpression variable = expression; - if (expression instanceof JetDotQualifiedExpression) { - if (((JetDotQualifiedExpression) expression).getReceiverExpression() instanceof JetThisExpression) { - variable = ((JetDotQualifiedExpression) expression).getSelectorExpression(); - } - } - if (variable instanceof JetSimpleNameExpression) { - JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) variable; - if (simpleNameExpression.getReferencedNameElementType() != JetTokens.FIELD_IDENTIFIER) { - trace.report(Errors.INITIALIZATION_USING_BACKING_FIELD.on(simpleNameExpression, expression, variableDescriptor)); - } - } + if (processClassOrObject) { + checkInitializationUsingBackingField(variableDescriptor, (JetExpression) element, enterData.get(variableDescriptor), exitData.get(variableDescriptor)); } } } } }); - Map lastInfo = traverser.getResultInfo(); - for (Map.Entry entry : lastInfo.entrySet()) { - VariableDescriptor variable = entry.getKey(); - if (variable instanceof PropertyDescriptor && declaredVariables.contains(variable)) { - InitializationPoints initializationPoints = entry.getValue(); - trace.record(BindingContext.IS_INITIALIZED, (PropertyDescriptor) variable, initializationPoints.isInitialized()); + recordInitializedVariables(declaredVariables, traverser.getResultInfo()); + analyzeLocalDeclarations(processLocalDeclaration, pseudocode); + } + + private void checkIsInitialized(@NotNull VariableDescriptor variableDescriptor, @NotNull JetElement element, @NotNull VariableInitializers variableInitializers, @NotNull Collection varWithUninitializedErrorGenerated) { + if (!(element instanceof JetSimpleNameExpression)) return; + + boolean isInitialized = variableInitializers.isInitialized(); + if (variableDescriptor instanceof PropertyDescriptor) { + if (!trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor)) { + isInitialized = true; } } - for (Instruction instruction : pseudocode.getInstructions()) { - if (instruction instanceof LocalDeclarationInstruction) { - JetElement element = ((LocalDeclarationInstruction) instruction).getElement(); - markUninitializedVariables(element, false, inLocalDeclaration); + if (!isInitialized && !varWithUninitializedErrorGenerated.contains(variableDescriptor)) { + varWithUninitializedErrorGenerated.add(variableDescriptor); + trace.report(Errors.UNINITIALIZED_VARIABLE.on((JetSimpleNameExpression) element, variableDescriptor)); + } + } + + private void checkValReassignment(@NotNull VariableDescriptor variableDescriptor, @NotNull JetExpression expression, @NotNull VariableInitializers enterInitializers, @NotNull Collection varWithValReassignErrorGenerated) { + boolean isInitializedNotHere = enterInitializers.isInitialized(); + Set possibleLocalInitializers = enterInitializers.getPossibleLocalInitializers(); + if (possibleLocalInitializers.size() == 1) { + JetElement initializer = possibleLocalInitializers.iterator().next(); + if (initializer instanceof JetProperty && initializer == expression.getParent()) { + isInitializedNotHere = false; + } + } + boolean hasBackingField = true; + if (variableDescriptor instanceof PropertyDescriptor) { + hasBackingField = trace.get(BindingContext.BACKING_FIELD_REQUIRED, (PropertyDescriptor) variableDescriptor); + } + if ((isInitializedNotHere || !hasBackingField) && !variableDescriptor.isVar() && !varWithValReassignErrorGenerated.contains(variableDescriptor)) { + varWithValReassignErrorGenerated.add(variableDescriptor); + + boolean hasReassignMethodReturningUnit = false; + JetSimpleNameExpression operationReference = null; + PsiElement parent = expression.getParent(); + if (parent instanceof JetBinaryExpression) { + operationReference = ((JetBinaryExpression) parent).getOperationReference(); + } + else if (parent instanceof JetUnaryExpression) { + operationReference = ((JetUnaryExpression) parent).getOperationSign(); + } + if (operationReference != null) { + DeclarationDescriptor descriptor = trace.get(BindingContext.REFERENCE_TARGET, operationReference); + if (descriptor instanceof FunctionDescriptor) { + if (JetStandardClasses.isUnit(((FunctionDescriptor) descriptor).getReturnType())) { + hasReassignMethodReturningUnit = true; + } + } + } + if (!hasReassignMethodReturningUnit) { + trace.report(Errors.VAL_REASSIGNMENT.on(expression, variableDescriptor)); + } + } + } + + private void checkInitializationUsingBackingField(@NotNull VariableDescriptor variableDescriptor, @NotNull JetExpression expression, @NotNull VariableInitializers enterInitializers, @NotNull VariableInitializers exitInitializers) { + if (variableDescriptor instanceof PropertyDescriptor && !enterInitializers.isInitialized() && exitInitializers.isInitialized()) { + JetExpression variable = expression; + if (expression instanceof JetDotQualifiedExpression) { + if (((JetDotQualifiedExpression) expression).getReceiverExpression() instanceof JetThisExpression) { + variable = ((JetDotQualifiedExpression) expression).getSelectorExpression(); + } + } + if (variable instanceof JetSimpleNameExpression) { + JetSimpleNameExpression simpleNameExpression = (JetSimpleNameExpression) variable; + if (simpleNameExpression.getReferencedNameElementType() != JetTokens.FIELD_IDENTIFIER) { + trace.report(Errors.INITIALIZATION_USING_BACKING_FIELD.on(simpleNameExpression, expression, variableDescriptor)); + } } } } - private Map prepareInitialMapForStartInstruction(Collection usedVariables, Collection declaredVariables) { - Map initialMapForStartInstruction = Maps.newHashMap(); - InitializationPoints initialPointsForDeclaredVariable = new InitializationPoints(false); - InitializationPoints initialPointsForExternalVariable = new InitializationPoints(true); + private void recordInitializedVariables(Collection declaredVariables, Map resultInfo) { + for (Map.Entry entry : resultInfo.entrySet()) { + VariableDescriptor variable = entry.getKey(); + if (variable instanceof PropertyDescriptor && declaredVariables.contains(variable)) { + VariableInitializers initializers = entry.getValue(); + trace.record(BindingContext.IS_INITIALIZED, (PropertyDescriptor) variable, initializers.isInitialized()); + } + } + } + + private void analyzeLocalDeclarations(boolean processLocalDeclaration, Pseudocode pseudocode) { + for (Instruction instruction : pseudocode.getInstructions()) { + if (instruction instanceof LocalDeclarationInstruction) { + JetElement element = ((LocalDeclarationInstruction) instruction).getElement(); + markUninitializedVariables(element, processLocalDeclaration); + } + } + } + + private Map addVariableInitializerFromCurrentInstructionIfAny(Instruction instruction, Map enterInstructionData) { + Map exitInstructionData = Maps.newHashMap(enterInstructionData); + if (instruction instanceof WriteValueInstruction) { + VariableDescriptor variable = extractVariableDescriptorIfAny(instruction, false); + VariableInitializers initializationAtThisElement = new VariableInitializers(((WriteValueInstruction) instruction).getElement()); + exitInstructionData.put(variable, initializationAtThisElement); + } + return exitInstructionData; + } + + private Map mergeIncomingEdgesData(Collection> incomingEdgesData) { + Set variablesInScope = Sets.newHashSet(); + for (Map edgeData : incomingEdgesData) { + variablesInScope.addAll(edgeData.keySet()); + } + + Map enterInstructionData = Maps.newHashMap(); + for (VariableDescriptor variable : variablesInScope) { + Set edgesDataForVariable = Sets.newHashSet(); + for (Map edgeData : incomingEdgesData) { + VariableInitializers initializers = edgeData.get(variable); + if (initializers != null) { + edgesDataForVariable.add(initializers); + } + } + enterInstructionData.put(variable, new VariableInitializers(edgesDataForVariable)); + } + return enterInstructionData; + } + + private Map prepareInitialMapForStartInstruction(Collection usedVariables, Collection declaredVariables) { + Map initialMapForStartInstruction = Maps.newHashMap(); + VariableInitializers isInitializedForExternalVariable = new VariableInitializers(true); + VariableInitializers isNotInitializedForDeclaredVariable = new VariableInitializers(false); for (VariableDescriptor variable : usedVariables) { if (declaredVariables.contains(variable)) { - initialMapForStartInstruction.put(variable, initialPointsForDeclaredVariable); + initialMapForStartInstruction.put(variable, isNotInitializedForDeclaredVariable); } else { - initialMapForStartInstruction.put(variable, initialPointsForExternalVariable); + initialMapForStartInstruction.put(variable, isInitializedForExternalVariable); } } return initialMapForStartInstruction; } +//////////////////////////////////////////////////////////////////////////////// + public void markNotOnlyInvokedFunctionVariables(@NotNull JetElement subroutine, List variables) { final List functionVariables = Lists.newArrayList(); for (VariableDescriptor variable : variables) { @@ -384,7 +412,10 @@ public class JetFlowInformationProvider { } }); } - + +//////////////////////////////////////////////////////////////////////////////// +// "Unused variable" & "unused value" analyses + public void markUnusedVariables(@NotNull JetElement subroutine) { Pseudocode pseudocode = pseudocodeMap.get(subroutine); assert pseudocode != null; @@ -403,10 +434,11 @@ public class JetFlowInformationProvider { for (VariableDescriptor declaredVariable : declaredVariables) { if (!usedVariables.contains(declaredVariable)) { PsiElement element = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, declaredVariable); - if (element instanceof JetProperty && JetPsiUtil.isLocal((JetProperty) element)) { - PsiElement nameIdentifier = ((JetProperty) element).getNameIdentifier(); + //todo + if (element instanceof JetProperty && JetPsiUtil.isLocal((JetNamedDeclaration) element)) { + PsiElement nameIdentifier = ((JetNamedDeclaration) element).getNameIdentifier(); PsiElement elementToMark = nameIdentifier != null ? nameIdentifier : element; - trace.report(Errors.UNUSED_VARIABLE.on((JetProperty)element, elementToMark, declaredVariable)); + trace.report(Errors.UNUSED_VARIABLE.on((JetNamedDeclaration)element, elementToMark, declaredVariable)); } } } @@ -416,7 +448,7 @@ public class JetFlowInformationProvider { private void markUnusedValues(@NotNull JetElement subroutine, Pseudocode pseudocode, final Collection declaredVariables) { JetControlFlowGraphTraverser> traverser = JetControlFlowGraphTraverser.create(pseudocode, true); - traverser.collectInformationFromInstructionGraph(new JetControlFlowGraphTraverser.InstructionsMergeStrategy>() { + traverser.collectInformationFromInstructionGraph(new JetControlFlowGraphTraverser.InstructionDataMergeStrategy>() { @Override public Pair, Set> execute(Instruction instruction, @NotNull Collection> incomingEdgesData) { Set enterResult = Sets.newHashSet(); @@ -448,8 +480,10 @@ public class JetFlowInformationProvider { if (variableDescriptor != null && declaredVariables.contains(variableDescriptor)) { if (!enterData.contains(variableDescriptor)) { PsiElement variableDeclarationElement = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, variableDescriptor); - assert variableDeclarationElement instanceof JetProperty || variableDeclarationElement instanceof JetParameter; - boolean isLocal = !(variableDeclarationElement instanceof JetProperty) || JetPsiUtil.isLocal((JetProperty) variableDeclarationElement); +// assert variableDeclarationElement instanceof JetProperty || variableDeclarationElement instanceof JetParameter; +// boolean isLocal = !(variableDeclarationElement instanceof JetProperty) || JetPsiUtil.isLocal((JetProperty) variableDeclarationElement); + assert variableDeclarationElement instanceof JetDeclaration; + boolean isLocal = JetPsiUtil.isLocal((JetDeclaration) variableDeclarationElement); if (isLocal) { JetElement element = ((WriteValueInstruction) instruction).getElement(); if (element instanceof JetBinaryExpression && ((JetBinaryExpression) element).getOperationToken() == JetTokens.EQ) { @@ -472,6 +506,9 @@ public class JetFlowInformationProvider { }); } +//////////////////////////////////////////////////////////////////////////////// +// Util methods + @Nullable private VariableDescriptor extractVariableDescriptorIfAny(Instruction instruction, boolean onlyReference) { VariableDescriptor variableDescriptor = null; @@ -521,31 +558,34 @@ public class JetFlowInformationProvider { return declaredVariables; } - private static class InitializationPoints { - private Set possiblePoints = Sets.newHashSet(); +//////////////////////////////////////////////////////////////////////////////// +// Local class for uninitialized variables analysis + + private static class VariableInitializers { + private Set possibleLocalInitializers = Sets.newHashSet(); private boolean isInitialized; - public InitializationPoints(boolean isInitialized) { + public VariableInitializers(boolean isInitialized) { this.isInitialized = isInitialized; } - public InitializationPoints(JetElement element) { + public VariableInitializers(JetElement element) { isInitialized = true; - possiblePoints.add(element); + possibleLocalInitializers.add(element); } - public InitializationPoints(Set edgesData) { + public VariableInitializers(Set edgesData) { isInitialized = true; - for (InitializationPoints edgeData : edgesData) { + for (VariableInitializers edgeData : edgesData) { if (!edgeData.isInitialized) { isInitialized = false; } - possiblePoints.addAll(edgeData.possiblePoints); + possibleLocalInitializers.addAll(edgeData.possibleLocalInitializers); } } - public Set getPossiblePoints() { - return possiblePoints; + public Set getPossibleLocalInitializers() { + return possibleLocalInitializers; } public boolean isInitialized() { @@ -555,12 +595,12 @@ public class JetFlowInformationProvider { @Override public boolean equals(Object o) { if (this == o) return true; - if (!(o instanceof InitializationPoints)) return false; + if (!(o instanceof VariableInitializers)) return false; - InitializationPoints that = (InitializationPoints) o; + VariableInitializers that = (VariableInitializers) o; if (isInitialized != that.isInitialized) return false; - if (possiblePoints != null ? !possiblePoints.equals(that.possiblePoints) : that.possiblePoints != null) { + if (possibleLocalInitializers != null ? !possibleLocalInitializers.equals(that.possibleLocalInitializers) : that.possibleLocalInitializers != null) { return false; } @@ -569,7 +609,7 @@ public class JetFlowInformationProvider { @Override public int hashCode() { - int result = possiblePoints != null ? possiblePoints.hashCode() : 0; + int result = possibleLocalInitializers != null ? possibleLocalInitializers.hashCode() : 0; result = 31 * result + (isInitialized ? 1 : 0); return result; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java index 0fb77fc8703..bdd55b0b25e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetPsiUtil.java @@ -104,9 +104,9 @@ public class JetPsiUtil { } } - public static boolean isLocal(@NotNull JetProperty property) { - JetClassOrObject classOrObject = PsiTreeUtil.getParentOfType(property, JetClassOrObject.class); - JetDeclarationWithBody function = PsiTreeUtil.getParentOfType(property, JetDeclarationWithBody.class); + public static boolean isLocal(@NotNull JetDeclaration declaration) { + JetClassOrObject classOrObject = PsiTreeUtil.getParentOfType(declaration, JetClassOrObject.class); + JetDeclarationWithBody function = PsiTreeUtil.getParentOfType(declaration, JetDeclarationWithBody.class); if (function != null && PsiTreeUtil.isAncestor(classOrObject, function, false)) { return true; } 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 1fdff1d39fb..4b24227c3cd 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java @@ -13,6 +13,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.DECLARATION_TO_DESCR /** * @author abreslav + * @author svtk */ public class BindingContextUtils { private BindingContextUtils() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java index 96d09dce0bc..82e31375232 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ControlFlowAnalyzer.java @@ -19,12 +19,12 @@ import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE; public class ControlFlowAnalyzer { private TopDownAnalysisContext context; private final JetControlFlowDataTraceFactory flowDataTraceFactory; - private final boolean inLocalDeclaration; + private final boolean processLocalDeclaration; - public ControlFlowAnalyzer(TopDownAnalysisContext context, JetControlFlowDataTraceFactory flowDataTraceFactory, boolean inLocalDeclaration) { + public ControlFlowAnalyzer(TopDownAnalysisContext context, JetControlFlowDataTraceFactory flowDataTraceFactory, boolean processLocalDeclaration) { this.context = context; this.flowDataTraceFactory = flowDataTraceFactory; - this.inLocalDeclaration = inLocalDeclaration; + this.processLocalDeclaration = processLocalDeclaration; } public void process() { @@ -53,7 +53,7 @@ public class ControlFlowAnalyzer { private void checkClassOrObject(JetClassOrObject klass) { JetFlowInformationProvider flowInformationProvider = new JetFlowInformationProvider((JetDeclaration) klass, (JetExpression) klass, flowDataTraceFactory, context.getTrace()); - flowInformationProvider.markUninitializedVariables((JetElement) klass, true, inLocalDeclaration); + flowInformationProvider.markUninitializedVariables((JetElement) klass, processLocalDeclaration); List declarations = klass.getDeclarations(); for (JetDeclaration declaration : declarations) { @@ -82,7 +82,7 @@ public class ControlFlowAnalyzer { flowInformationProvider.checkDefiniteReturn(function, expectedReturnType); - flowInformationProvider.markUninitializedVariables(function.asElement(), false, inLocalDeclaration); + flowInformationProvider.markUninitializedVariables(function.asElement(), processLocalDeclaration); flowInformationProvider.markUnusedVariables(function.asElement()); } 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 fc27060c882..e6a9f31e64d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -53,7 +53,7 @@ public class TopDownAnalyzer { NamespaceLike owner, Collection declarations, JetControlFlowDataTraceFactory flowDataTraceFactory, - boolean declaredLocally) { + boolean processLocalDeclaration) { // context.enableDebugOutput(); context.debug("Enter"); @@ -64,7 +64,7 @@ public class TopDownAnalyzer { new OverloadResolver(context).process(); if (!context.analyzingBootstrapLibrary()) { new BodyResolver(context).resolveBehaviorDeclarationBodies(); - new ControlFlowAnalyzer(context, flowDataTraceFactory, declaredLocally).process(); + new ControlFlowAnalyzer(context, flowDataTraceFactory, processLocalDeclaration).process(); new DeclarationsChecker(context).process(); } diff --git a/compiler/testData/checkerWithErrorTypes/quick/UninitializedOrReassignedVariables.jet b/compiler/testData/checkerWithErrorTypes/quick/UninitializedOrReassignedVariables.jet index 63739b20d4b..eb7807c0797 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/UninitializedOrReassignedVariables.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/UninitializedOrReassignedVariables.jet @@ -137,8 +137,8 @@ class AnonymousInitializers(var a: String, val b: String) { { $i = 13 - $j = 30 - j = 34 + $j = 30 + j = 34 } val k: String diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt607.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt607.jet new file mode 100644 index 00000000000..238661318d1 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt607.jet @@ -0,0 +1,18 @@ +//KT-607 Val reassignment is not marked as an error + +namespace kt607 + +fun foo(a: A) { + val o = object { + val y : Int + get() = 42 + } + + a.z = 23 + o.y = 11 //Should be an error here +} + +class A() { + val z : Int + get() = 3 +} \ No newline at end of file From 4c2b0b9444c15badf503868bf3c7aa711470e1cb Mon Sep 17 00:00:00 2001 From: svtk Date: Fri, 25 Nov 2011 15:15:51 +0400 Subject: [PATCH 03/11] some quick fixes refactoring --- .../jet/lang/diagnostics/Errors.java | 14 +--- .../quickfix/ChangeVariableMutabilityFix.java | 80 +++++++++++-------- .../jet/plugin/quickfix/QuickFixes.java | 7 +- 3 files changed, 53 insertions(+), 48 deletions(-) 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 98f7f7d5d69..742245b2263 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -144,7 +144,7 @@ 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 UNUSED_VARIABLE = PsiElementOnlyDiagnosticFactory1.create(WARNING, "Variable ''{0}'' is never used", NAME); PsiElementOnlyDiagnosticFactory2 UNUSED_VALUE = new PsiElementOnlyDiagnosticFactory2(WARNING, "The value ''{0}'' assigned to ''{1}'' is never used", NAME) { @Override protected String makeMessageForA(@NotNull JetElement element) { @@ -158,17 +158,7 @@ public interface Errors { } }; - PsiElementOnlyDiagnosticFactory2 VAL_REASSIGNMENT = new PsiElementOnlyDiagnosticFactory2(ERROR, "Val can not be reassigned", NAME) { - @NotNull - @Override - public DiagnosticWithPsiElement on(@NotNull JetExpression elementToBlame, @NotNull ASTNode nodeToMark, @NotNull DeclarationDescriptor declarationDescriptor, @NotNull JetProperty[] property) { - DiagnosticWithPsiElement diagnostic = super.on(elementToBlame, nodeToMark, declarationDescriptor, property); - if (property.length == 1) { - return diagnostic.add(DiagnosticParameters.PROPERTY, property[0]); - } - return diagnostic; - } - }; + PsiElementOnlyDiagnosticFactory1 VAL_REASSIGNMENT = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Val can not be reassigned", NAME); SimplePsiElementOnlyDiagnosticFactory VARIABLE_EXPECTED = new SimplePsiElementOnlyDiagnosticFactory(ERROR, "Variable expected"); PsiElementOnlyDiagnosticFactory1 INITIALIZATION_USING_BACKING_FIELD = PsiElementOnlyDiagnosticFactory1.create(ERROR, "Initialization using backing field required", NAME); diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/ChangeVariableMutabilityFix.java b/idea/src/org/jetbrains/jet/plugin/quickfix/ChangeVariableMutabilityFix.java index ace862bb542..23a01d37acf 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/ChangeVariableMutabilityFix.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/ChangeVariableMutabilityFix.java @@ -1,21 +1,25 @@ package org.jetbrains.jet.plugin.quickfix; +import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.project.Project; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.source.codeStyle.CodeEditUtil; +import com.intellij.psi.util.PsiTreeUtil; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.diagnostics.DiagnosticParameter; import org.jetbrains.jet.lang.diagnostics.DiagnosticParameters; import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters; import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement; -import org.jetbrains.jet.lang.psi.JetElement; -import org.jetbrains.jet.lang.psi.JetProperty; -import org.jetbrains.jet.lang.psi.JetPsiFactory; -import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; +import org.jetbrains.jet.lang.psi.*; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.BindingContextUtils; +import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade; import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.plugin.JetBundle; @@ -24,15 +28,21 @@ import java.util.Arrays; /** * @author svtk */ -public class ChangeVariableMutabilityFix extends JetIntentionAction { - public ChangeVariableMutabilityFix(@NotNull JetProperty element) { - super(element); +public class ChangeVariableMutabilityFix implements IntentionAction { + private boolean isVar; + + public ChangeVariableMutabilityFix(boolean isVar) { + this.isVar = isVar; } + public ChangeVariableMutabilityFix() { + this(false); + } + @NotNull @Override public String getText() { - return element.isVar() ? JetBundle.message("make.variable.immutable") : JetBundle.message("make.variable.mutable"); + return isVar ? JetBundle.message("make.variable.immutable") : JetBundle.message("make.variable.mutable"); } @NotNull @@ -41,8 +51,34 @@ public class ChangeVariableMutabilityFix extends JetIntentionAction return JetBundle.message("change.variable.mutability.family"); } + @Override + public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) { + if (!(file instanceof JetFile)) return false; + JetProperty property = getCorrespondingProperty(editor, (JetFile) file); + return property != null && !property.isVar(); + } + + private static JetProperty getCorrespondingProperty(Editor editor, JetFile file) { + final PsiElement elementAtCaret = file.findElementAt(editor.getCaretModel().getOffset()); + JetProperty property = PsiTreeUtil.getParentOfType(elementAtCaret, JetProperty.class); + if (property != null) return property; + JetSimpleNameExpression simpleNameExpression = PsiTreeUtil.getParentOfType(elementAtCaret, JetSimpleNameExpression.class); + if (simpleNameExpression != null) { + BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(file, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER); + VariableDescriptor descriptor = BindingContextUtils.extractVariableDescriptorIfAny(bindingContext, simpleNameExpression, true); + if (descriptor != null) { + PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor); + if (declaration instanceof JetProperty) { + return (JetProperty) declaration; + } + } + } + return null; + } + @Override public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException { + JetProperty element = getCorrespondingProperty(editor, (JetFile)file); JetProperty newElement = (JetProperty) element.copy(); if (newElement.isVar()) { PsiElement varElement = newElement.getNode().findChildByType(JetTokens.VAR_KEYWORD).getPsi(); @@ -61,30 +97,8 @@ public class ChangeVariableMutabilityFix extends JetIntentionAction element.replace(newElement); } - public static JetIntentionActionFactory createFactory() { - return new JetIntentionActionFactory() { - @Nullable - @Override - public JetIntentionAction createAction(DiagnosticWithPsiElement diagnostic) { - assert diagnostic.getPsiElement() instanceof JetProperty; - return new ChangeVariableMutabilityFix((JetProperty) diagnostic.getPsiElement()); - } - }; - } - - public static JetIntentionActionFactory createFromSimpleNameFactory() { - return new JetIntentionActionFactory() { - @Override - public JetIntentionAction createAction(DiagnosticWithPsiElement diagnostic) { - if (diagnostic instanceof DiagnosticWithParameters) { - DiagnosticWithParameters diagnosticWithParameters = assertAndCastToDiagnosticWithParameters(diagnostic, DiagnosticParameters.PROPERTY); - JetProperty property = diagnosticWithParameters.getParameter(DiagnosticParameters.PROPERTY); - if (diagnostic.getPsiElement().getContainingFile() == property.getContainingFile()) { - return (JetIntentionAction) new ChangeVariableMutabilityFix(property); - } - } - return null; - } - }; + @Override + public boolean startInWriteAction() { + return true; } } diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/QuickFixes.java b/idea/src/org/jetbrains/jet/plugin/quickfix/QuickFixes.java index 8c816241a4c..3a98d0803ac 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/QuickFixes.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/QuickFixes.java @@ -78,9 +78,6 @@ public class QuickFixes { add(Errors.NOTHING_TO_OVERRIDE, RemoveModifierFix.createRemoveModifierFromListFactory(JetTokens.OVERRIDE_KEYWORD)); add(Errors.VIRTUAL_MEMBER_HIDDEN, AddModifierFix.createFactory(JetTokens.OVERRIDE_KEYWORD, new JetToken[] {JetTokens.OPEN_KEYWORD})); - add(Errors.VAL_WITH_SETTER, ChangeVariableMutabilityFix.createFactory()); - add(Errors.VAL_REASSIGNMENT, ChangeVariableMutabilityFix.createFromSimpleNameFactory()); - add(Errors.USELESS_CAST_STATIC_ASSERT_IS_FINE, ReplaceOperationInBinaryExpressionFix.createChangeCastToStaticAssertFactory()); add(Errors.USELESS_CAST, RemoveRightPartOfBinaryExpressionFix.createRemoveCastFactory()); @@ -120,5 +117,9 @@ public class QuickFixes { ImplementMethodsHandler implementMethodsHandler = new ImplementMethodsHandler(); actionMap.put(Errors.ABSTRACT_MEMBER_NOT_IMPLEMENTED, implementMethodsHandler); actionMap.put(Errors.MANY_IMPL_MEMBER_NOT_IMPLEMENTED, implementMethodsHandler); + + ChangeVariableMutabilityFix changeVariableMutabilityFix = new ChangeVariableMutabilityFix(); + actionMap.put(Errors.VAL_WITH_SETTER, changeVariableMutabilityFix); + actionMap.put(Errors.VAL_REASSIGNMENT, changeVariableMutabilityFix); } } \ No newline at end of file From 7bc2736568c7bbee87dabb7ad51c2a54baa7fb81 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Fri, 25 Nov 2011 18:22:40 +0400 Subject: [PATCH 04/11] merge FullJetPsiCheckerTest into QuickJetPsiCheckerTest --- .../full/regression/Jet53.jet | 4 - .../{full => quick}/Abstract.jet | 4 +- .../{full => quick}/AnonymousInitializers.jet | 0 .../quick/AutocastsForStableIdentifiers.jet | 2 +- .../BinaryCallsOnNullableValues.jet | 0 .../{full => quick}/Bounds.jet | 0 .../{full => quick}/BreakContinue.jet | 0 .../{full => quick}/Builders.jet | 2 + .../{full => quick}/Casts.jet | 0 .../{full => quick}/ClassObjects.jet | 4 +- .../{full => quick}/Constants.jet | 0 .../{full => quick}/Constructors.jet | 0 .../{full => quick}/CovariantOverrideType.jet | 2 + .../{full => quick}/CyclicHierarchy.jet | 0 .../{full => quick}/Enums.jet | 0 .../{full => quick}/ExtensionFunctions.jet | 4 +- .../{full => quick}/ForRangeConventions.jet | 2 + .../{full => quick}/FunctionReturnTypes.jet | 4 +- .../GenericArgumentConsistency.jet | 0 .../{full => quick}/IllegalModifiers.jet | 0 .../{full => quick}/IncDec.jet | 0 .../{full => quick}/IsExpressions.jet | 0 .../{full => quick}/MultipleBounds.jet | 0 .../{full => quick}/NamespaceAsExpression.jet | 0 .../NamespaceInExpressionPosition.jet | 2 + .../{full => quick}/NamespaceQualified.jet | 4 +- .../{full => quick}/Nullability.jet | 4 +- .../{full => quick}/Objects.jet | 0 .../{full => quick}/PrimaryConstructors.jet | 0 .../ProjectionsInSupertypes.jet | 0 .../{full => quick}/Properties.jet | 0 .../{full => quick}/QualifiedExpressions.jet | 0 .../{full => quick}/QualifiedThis.jet | 0 .../RecursiveTypeInference.jet | 0 .../{full => quick}/Redeclarations.jet | 0 .../{full => quick}/ResolveOfJavaGenerics.jet | 4 +- .../{full => quick}/ResolveToJava.jet | 4 +- .../{full => quick}/Return.jet | 0 .../{full => quick}/StringTemplates.jet | 0 .../{full => quick}/SupertypeListChecks.jet | 0 .../{full => quick}/TraitSupertypeList.jet | 0 .../{full => quick}/UnreachableCode.jet | 2 + .../{full => quick}/Unresolved.jet | 0 .../ValAndFunOverrideCompatibilityClash.jet | 2 + .../{full => quick}/VarargTypes.jet | 3 +- .../{full => quick}/Variance.jet | 0 .../{full => quick}/When.jet | 0 .../{full => quick}/cast/AsErasedError.jet | 2 + .../{full => quick}/cast/AsErasedFine.jet | 2 + .../{full => quick}/cast/AsErasedStar.jet | 2 + .../{full => quick}/cast/AsErasedWarning.jet | 2 + .../{full => quick}/cast/IsErasedAllow.jet | 2 + .../cast/IsErasedAllowParameterSubtype.jet | 2 + .../cast/IsErasedDisallowFromAny.jet | 2 + .../{full => quick}/cast/IsErasedStar.jet | 2 + .../{full => quick}/cast/IsReified.jet | 0 .../{full => quick}/cast/IsTraits.jet | 0 .../cast/WhenErasedDisallowFromAny.jet | 2 + .../{full => quick}/infos/Autocasts.jet | 0 .../infos/PropertiesWithBackingFields.jet | 0 .../{full => quick}/kt600.jet | 3 +- .../AmbiguityOnLazyTypeComputation.jet | 0 .../regression/AssignmentsUnderOperators.jet | 0 .../regression/CoercionToUnit.jet | 0 .../regression/DoubleDefine.jet | 4 +- .../ErrorsOnIbjectExpressionsAsParameters.jet | 0 .../{full => quick}/regression/Jet11.jet | 0 .../{full => quick}/regression/Jet121.jet | 0 .../{full => quick}/regression/Jet124.jet | 0 .../{full => quick}/regression/Jet169.jet | 0 .../{full => quick}/regression/Jet17.jet | 0 .../{full => quick}/regression/Jet183-1.jet | 0 .../{full => quick}/regression/Jet183.jet | 0 .../quick/regression/Jet53.jet | 6 + .../{full => quick}/regression/Jet67.jet | 0 .../{full => quick}/regression/Jet68.jet | 0 .../{full => quick}/regression/Jet69.jet | 0 .../{full => quick}/regression/Jet72.jet | 1 + .../{full => quick}/regression/Jet81.jet | 0 .../regression/OverrideResolution.jet | 0 .../ScopeForSecondaryConstructors.jet | 0 .../regression/SpecififcityByReceiver.jet | 0 .../ThisConstructorInGenericClass.jet | 0 .../regression/WrongTraceInCallResolver.jet | 0 .../{full => quick}/regression/kt251.jet | 0 .../{full => quick}/regression/kt258.jet | 1 + .../{full => quick}/regression/kt287.jet | 2 + .../{full => quick}/regression/kt303.jet | 0 .../{full => quick}/regression/kt313.jet | 1 + .../{full => quick}/regression/kt335.336.jet | 1 + .../regression/kt385.109.441.jet | 3 +- .../{full => quick}/regression/kt402.jet | 0 .../{full => quick}/regression/kt459.jet | 3 +- .../{full => quick}/regression/kt469.jet | 2 + .../{full => quick}/regression/kt549.jet | 2 + .../{full => quick}/regression/kt58.jet | 3 +- .../{full => quick}/regression/kt580.jet | 4 +- .../{full => quick}/regression/kt588.jet | 4 +- .../quick/regressions/kt235.jet | 3 +- .../jet/checkers/FullJetPsiCheckerTest.java | 119 ------------------ 100 files changed, 92 insertions(+), 141 deletions(-) delete mode 100644 compiler/testData/checkerWithErrorTypes/full/regression/Jet53.jet rename compiler/testData/checkerWithErrorTypes/{full => quick}/Abstract.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/AnonymousInitializers.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/BinaryCallsOnNullableValues.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Bounds.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/BreakContinue.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Builders.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Casts.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/ClassObjects.jet (97%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Constants.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Constructors.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/CovariantOverrideType.jet (98%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/CyclicHierarchy.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Enums.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/ExtensionFunctions.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/ForRangeConventions.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/FunctionReturnTypes.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/GenericArgumentConsistency.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/IllegalModifiers.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/IncDec.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/IsExpressions.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/MultipleBounds.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/NamespaceAsExpression.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/NamespaceInExpressionPosition.jet (97%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/NamespaceQualified.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Nullability.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Objects.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/PrimaryConstructors.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/ProjectionsInSupertypes.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Properties.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/QualifiedExpressions.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/QualifiedThis.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/RecursiveTypeInference.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Redeclarations.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/ResolveOfJavaGenerics.jet (96%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/ResolveToJava.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Return.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/StringTemplates.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/SupertypeListChecks.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/TraitSupertypeList.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/UnreachableCode.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Unresolved.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/ValAndFunOverrideCompatibilityClash.jet (93%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/VarargTypes.jet (98%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/Variance.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/When.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/AsErasedError.jet (93%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/AsErasedFine.jet (91%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/AsErasedStar.jet (85%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/AsErasedWarning.jet (89%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/IsErasedAllow.jet (92%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/IsErasedAllowParameterSubtype.jet (93%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/IsErasedDisallowFromAny.jet (90%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/IsErasedStar.jet (85%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/IsReified.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/IsTraits.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/cast/WhenErasedDisallowFromAny.jet (92%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/infos/Autocasts.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/infos/PropertiesWithBackingFields.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/kt600.jet (96%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/AmbiguityOnLazyTypeComputation.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/AssignmentsUnderOperators.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/CoercionToUnit.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/DoubleDefine.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/ErrorsOnIbjectExpressionsAsParameters.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet11.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet121.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet124.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet169.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet17.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet183-1.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet183.jet (100%) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regression/Jet53.jet rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet67.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet68.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet69.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet72.jet (97%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/Jet81.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/OverrideResolution.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/ScopeForSecondaryConstructors.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/SpecififcityByReceiver.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/ThisConstructorInGenericClass.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/WrongTraceInCallResolver.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt251.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt258.jet (97%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt287.jet (96%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt303.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt313.jet (97%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt335.336.jet (98%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt385.109.441.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt402.jet (100%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt459.jet (92%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt469.jet (98%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt549.jet (97%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt58.jet (99%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt580.jet (90%) rename compiler/testData/checkerWithErrorTypes/{full => quick}/regression/kt588.jet (95%) delete mode 100644 compiler/tests/org/jetbrains/jet/checkers/FullJetPsiCheckerTest.java diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet53.jet b/compiler/testData/checkerWithErrorTypes/full/regression/Jet53.jet deleted file mode 100644 index e880fe25bbd..00000000000 --- a/compiler/testData/checkerWithErrorTypes/full/regression/Jet53.jet +++ /dev/null @@ -1,4 +0,0 @@ -import java.util.Collections -import java.util.List - -val ab = Collections.emptyList() : List? \ No newline at end of file diff --git a/compiler/testData/checkerWithErrorTypes/full/Abstract.jet b/compiler/testData/checkerWithErrorTypes/quick/Abstract.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/Abstract.jet rename to compiler/testData/checkerWithErrorTypes/quick/Abstract.jet index ce355f02045..1ab361db8d8 100644 --- a/compiler/testData/checkerWithErrorTypes/full/Abstract.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Abstract.jet @@ -1,3 +1,5 @@ +// +JDK + namespace abstract class MyClass() { @@ -238,4 +240,4 @@ abstract class B3(i: Int) { fun foo(a: B3) { val a = B3() val b = B1(2, "s") -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/AnonymousInitializers.jet b/compiler/testData/checkerWithErrorTypes/quick/AnonymousInitializers.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/AnonymousInitializers.jet rename to compiler/testData/checkerWithErrorTypes/quick/AnonymousInitializers.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/AutocastsForStableIdentifiers.jet b/compiler/testData/checkerWithErrorTypes/quick/AutocastsForStableIdentifiers.jet index 37ff349686f..afd0622ba41 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/AutocastsForStableIdentifiers.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/AutocastsForStableIdentifiers.jet @@ -88,4 +88,4 @@ open class C { t = this@C } } -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/BinaryCallsOnNullableValues.jet b/compiler/testData/checkerWithErrorTypes/quick/BinaryCallsOnNullableValues.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/BinaryCallsOnNullableValues.jet rename to compiler/testData/checkerWithErrorTypes/quick/BinaryCallsOnNullableValues.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/Bounds.jet b/compiler/testData/checkerWithErrorTypes/quick/Bounds.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Bounds.jet rename to compiler/testData/checkerWithErrorTypes/quick/Bounds.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/BreakContinue.jet b/compiler/testData/checkerWithErrorTypes/quick/BreakContinue.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/BreakContinue.jet rename to compiler/testData/checkerWithErrorTypes/quick/BreakContinue.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/Builders.jet b/compiler/testData/checkerWithErrorTypes/quick/Builders.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/Builders.jet rename to compiler/testData/checkerWithErrorTypes/quick/Builders.jet index 1d26cbbc8b2..10791f68875 100644 --- a/compiler/testData/checkerWithErrorTypes/full/Builders.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Builders.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.* namespace html { diff --git a/compiler/testData/checkerWithErrorTypes/full/Casts.jet b/compiler/testData/checkerWithErrorTypes/quick/Casts.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Casts.jet rename to compiler/testData/checkerWithErrorTypes/quick/Casts.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/ClassObjects.jet b/compiler/testData/checkerWithErrorTypes/quick/ClassObjects.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/ClassObjects.jet rename to compiler/testData/checkerWithErrorTypes/quick/ClassObjects.jet index 5be76d57e39..f933004a4d5 100644 --- a/compiler/testData/checkerWithErrorTypes/full/ClassObjects.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ClassObjects.jet @@ -1,3 +1,5 @@ +// +JDK + namespace Jet86 class A { @@ -27,4 +29,4 @@ val s = System // error fun test() { System.out?.println() java.lang.System.out?.println() -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/Constants.jet b/compiler/testData/checkerWithErrorTypes/quick/Constants.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Constants.jet rename to compiler/testData/checkerWithErrorTypes/quick/Constants.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/Constructors.jet b/compiler/testData/checkerWithErrorTypes/quick/Constructors.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Constructors.jet rename to compiler/testData/checkerWithErrorTypes/quick/Constructors.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/CovariantOverrideType.jet b/compiler/testData/checkerWithErrorTypes/quick/CovariantOverrideType.jet similarity index 98% rename from compiler/testData/checkerWithErrorTypes/full/CovariantOverrideType.jet rename to compiler/testData/checkerWithErrorTypes/quick/CovariantOverrideType.jet index 1ffd989245c..ca0116bf983 100644 --- a/compiler/testData/checkerWithErrorTypes/full/CovariantOverrideType.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/CovariantOverrideType.jet @@ -1,3 +1,5 @@ +// +JDK + trait A { fun foo() : Int = 1 fun foo2() : Int = 1 diff --git a/compiler/testData/checkerWithErrorTypes/full/CyclicHierarchy.jet b/compiler/testData/checkerWithErrorTypes/quick/CyclicHierarchy.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/CyclicHierarchy.jet rename to compiler/testData/checkerWithErrorTypes/quick/CyclicHierarchy.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/Enums.jet b/compiler/testData/checkerWithErrorTypes/quick/Enums.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Enums.jet rename to compiler/testData/checkerWithErrorTypes/quick/Enums.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/ExtensionFunctions.jet b/compiler/testData/checkerWithErrorTypes/quick/ExtensionFunctions.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/ExtensionFunctions.jet rename to compiler/testData/checkerWithErrorTypes/quick/ExtensionFunctions.jet index 141e47ae591..245be61e735 100644 --- a/compiler/testData/checkerWithErrorTypes/full/ExtensionFunctions.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ExtensionFunctions.jet @@ -1,3 +1,5 @@ +// +JDK + fun Int?.optint() : Unit {} val Int?.optval : Unit = () @@ -68,4 +70,4 @@ namespace null_safety { if (command == null) 1 } -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/ForRangeConventions.jet b/compiler/testData/checkerWithErrorTypes/quick/ForRangeConventions.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/ForRangeConventions.jet rename to compiler/testData/checkerWithErrorTypes/quick/ForRangeConventions.jet index 1f14e587fcd..66142d55fbb 100644 --- a/compiler/testData/checkerWithErrorTypes/full/ForRangeConventions.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ForRangeConventions.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.*; class NotRange1() { diff --git a/compiler/testData/checkerWithErrorTypes/full/FunctionReturnTypes.jet b/compiler/testData/checkerWithErrorTypes/quick/FunctionReturnTypes.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/FunctionReturnTypes.jet rename to compiler/testData/checkerWithErrorTypes/quick/FunctionReturnTypes.jet index 850cb2fd5e0..27d52fb227b 100644 --- a/compiler/testData/checkerWithErrorTypes/full/FunctionReturnTypes.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/FunctionReturnTypes.jet @@ -1,3 +1,5 @@ +// +JDK + fun none() {} fun unitEmptyInfer() {} @@ -209,4 +211,4 @@ fun testFunctionLiterals() { object A {} } -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/GenericArgumentConsistency.jet b/compiler/testData/checkerWithErrorTypes/quick/GenericArgumentConsistency.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/GenericArgumentConsistency.jet rename to compiler/testData/checkerWithErrorTypes/quick/GenericArgumentConsistency.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/IllegalModifiers.jet b/compiler/testData/checkerWithErrorTypes/quick/IllegalModifiers.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/IllegalModifiers.jet rename to compiler/testData/checkerWithErrorTypes/quick/IllegalModifiers.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/IncDec.jet b/compiler/testData/checkerWithErrorTypes/quick/IncDec.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/IncDec.jet rename to compiler/testData/checkerWithErrorTypes/quick/IncDec.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/IsExpressions.jet b/compiler/testData/checkerWithErrorTypes/quick/IsExpressions.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/IsExpressions.jet rename to compiler/testData/checkerWithErrorTypes/quick/IsExpressions.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/MultipleBounds.jet b/compiler/testData/checkerWithErrorTypes/quick/MultipleBounds.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/MultipleBounds.jet rename to compiler/testData/checkerWithErrorTypes/quick/MultipleBounds.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/NamespaceAsExpression.jet b/compiler/testData/checkerWithErrorTypes/quick/NamespaceAsExpression.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/NamespaceAsExpression.jet rename to compiler/testData/checkerWithErrorTypes/quick/NamespaceAsExpression.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/NamespaceInExpressionPosition.jet b/compiler/testData/checkerWithErrorTypes/quick/NamespaceInExpressionPosition.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/NamespaceInExpressionPosition.jet rename to compiler/testData/checkerWithErrorTypes/quick/NamespaceInExpressionPosition.jet index 863f25630cc..f8520b087f1 100644 --- a/compiler/testData/checkerWithErrorTypes/full/NamespaceInExpressionPosition.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/NamespaceInExpressionPosition.jet @@ -1,3 +1,5 @@ +// +JDK + namespace foo class X {} diff --git a/compiler/testData/checkerWithErrorTypes/full/NamespaceQualified.jet b/compiler/testData/checkerWithErrorTypes/quick/NamespaceQualified.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/NamespaceQualified.jet rename to compiler/testData/checkerWithErrorTypes/quick/NamespaceQualified.jet index 213e2867d94..194c1047e24 100644 --- a/compiler/testData/checkerWithErrorTypes/full/NamespaceQualified.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/NamespaceQualified.jet @@ -1,3 +1,5 @@ +// +JDK + namespace foobar namespace a { @@ -60,4 +62,4 @@ abstract class Collection : Iterable { } return iteratee.done() } -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/Nullability.jet b/compiler/testData/checkerWithErrorTypes/quick/Nullability.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/Nullability.jet rename to compiler/testData/checkerWithErrorTypes/quick/Nullability.jet index 8479b364cd8..95e8ebb3700 100644 --- a/compiler/testData/checkerWithErrorTypes/full/Nullability.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/Nullability.jet @@ -1,3 +1,5 @@ +// +JDK + fun test() { val a : Int? = 0 if (a != null) { @@ -277,4 +279,4 @@ fun f9(a : Int?) : Int { if (a != null) return a return 1 -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/Objects.jet b/compiler/testData/checkerWithErrorTypes/quick/Objects.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Objects.jet rename to compiler/testData/checkerWithErrorTypes/quick/Objects.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/PrimaryConstructors.jet b/compiler/testData/checkerWithErrorTypes/quick/PrimaryConstructors.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/PrimaryConstructors.jet rename to compiler/testData/checkerWithErrorTypes/quick/PrimaryConstructors.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/ProjectionsInSupertypes.jet b/compiler/testData/checkerWithErrorTypes/quick/ProjectionsInSupertypes.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/ProjectionsInSupertypes.jet rename to compiler/testData/checkerWithErrorTypes/quick/ProjectionsInSupertypes.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/Properties.jet b/compiler/testData/checkerWithErrorTypes/quick/Properties.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Properties.jet rename to compiler/testData/checkerWithErrorTypes/quick/Properties.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/QualifiedExpressions.jet b/compiler/testData/checkerWithErrorTypes/quick/QualifiedExpressions.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/QualifiedExpressions.jet rename to compiler/testData/checkerWithErrorTypes/quick/QualifiedExpressions.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/QualifiedThis.jet b/compiler/testData/checkerWithErrorTypes/quick/QualifiedThis.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/QualifiedThis.jet rename to compiler/testData/checkerWithErrorTypes/quick/QualifiedThis.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/RecursiveTypeInference.jet b/compiler/testData/checkerWithErrorTypes/quick/RecursiveTypeInference.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/RecursiveTypeInference.jet rename to compiler/testData/checkerWithErrorTypes/quick/RecursiveTypeInference.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/Redeclarations.jet b/compiler/testData/checkerWithErrorTypes/quick/Redeclarations.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Redeclarations.jet rename to compiler/testData/checkerWithErrorTypes/quick/Redeclarations.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/ResolveOfJavaGenerics.jet b/compiler/testData/checkerWithErrorTypes/quick/ResolveOfJavaGenerics.jet similarity index 96% rename from compiler/testData/checkerWithErrorTypes/full/ResolveOfJavaGenerics.jet rename to compiler/testData/checkerWithErrorTypes/quick/ResolveOfJavaGenerics.jet index d98dd030994..2353e215293 100644 --- a/compiler/testData/checkerWithErrorTypes/full/ResolveOfJavaGenerics.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ResolveOfJavaGenerics.jet @@ -1,3 +1,5 @@ +// +JDK + // Fixpoint generic in Java: Enum> fun test(a : annotation.RetentionPolicy) { @@ -17,4 +19,4 @@ fun test(a : java.util.ArrayList) { fun test(a : java.lang.Class) { -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/ResolveToJava.jet b/compiler/testData/checkerWithErrorTypes/quick/ResolveToJava.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/ResolveToJava.jet rename to compiler/testData/checkerWithErrorTypes/quick/ResolveToJava.jet index 61483f8ea48..d404b2365ba 100644 --- a/compiler/testData/checkerWithErrorTypes/full/ResolveToJava.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ResolveToJava.jet @@ -1,3 +1,5 @@ +// +JDK + import java.* import util.* import utils.* @@ -49,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/full/Return.jet b/compiler/testData/checkerWithErrorTypes/quick/Return.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Return.jet rename to compiler/testData/checkerWithErrorTypes/quick/Return.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/StringTemplates.jet b/compiler/testData/checkerWithErrorTypes/quick/StringTemplates.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/StringTemplates.jet rename to compiler/testData/checkerWithErrorTypes/quick/StringTemplates.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/SupertypeListChecks.jet b/compiler/testData/checkerWithErrorTypes/quick/SupertypeListChecks.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/SupertypeListChecks.jet rename to compiler/testData/checkerWithErrorTypes/quick/SupertypeListChecks.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/TraitSupertypeList.jet b/compiler/testData/checkerWithErrorTypes/quick/TraitSupertypeList.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/TraitSupertypeList.jet rename to compiler/testData/checkerWithErrorTypes/quick/TraitSupertypeList.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/UnreachableCode.jet b/compiler/testData/checkerWithErrorTypes/quick/UnreachableCode.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/UnreachableCode.jet rename to compiler/testData/checkerWithErrorTypes/quick/UnreachableCode.jet index 60efa628adf..36bfd0e8925 100644 --- a/compiler/testData/checkerWithErrorTypes/full/UnreachableCode.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/UnreachableCode.jet @@ -1,3 +1,5 @@ +// +JDK + fun t1() : Int{ return 0 1 diff --git a/compiler/testData/checkerWithErrorTypes/full/Unresolved.jet b/compiler/testData/checkerWithErrorTypes/quick/Unresolved.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Unresolved.jet rename to compiler/testData/checkerWithErrorTypes/quick/Unresolved.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/ValAndFunOverrideCompatibilityClash.jet b/compiler/testData/checkerWithErrorTypes/quick/ValAndFunOverrideCompatibilityClash.jet similarity index 93% rename from compiler/testData/checkerWithErrorTypes/full/ValAndFunOverrideCompatibilityClash.jet rename to compiler/testData/checkerWithErrorTypes/quick/ValAndFunOverrideCompatibilityClash.jet index f18974bb51f..f493c55a093 100644 --- a/compiler/testData/checkerWithErrorTypes/full/ValAndFunOverrideCompatibilityClash.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/ValAndFunOverrideCompatibilityClash.jet @@ -1,3 +1,5 @@ +// +JDK + class Foo1() : java.util.ArrayList() open class Bar() { diff --git a/compiler/testData/checkerWithErrorTypes/full/VarargTypes.jet b/compiler/testData/checkerWithErrorTypes/quick/VarargTypes.jet similarity index 98% rename from compiler/testData/checkerWithErrorTypes/full/VarargTypes.jet rename to compiler/testData/checkerWithErrorTypes/quick/VarargTypes.jet index 2ce06de117c..d5a3b859b8c 100644 --- a/compiler/testData/checkerWithErrorTypes/full/VarargTypes.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/VarargTypes.jet @@ -1,4 +1,5 @@ // KT-389 Wrong type inference for varargs etc. +// +JDK import java.util.* @@ -23,4 +24,4 @@ fun test() { fool(1, 2, 3) food(1.0, 2.0, 3.0) foof(1.0.flt, 2.0.flt, 3.0.flt) -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/Variance.jet b/compiler/testData/checkerWithErrorTypes/quick/Variance.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/Variance.jet rename to compiler/testData/checkerWithErrorTypes/quick/Variance.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/When.jet b/compiler/testData/checkerWithErrorTypes/quick/When.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/When.jet rename to compiler/testData/checkerWithErrorTypes/quick/When.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/AsErasedError.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedError.jet similarity index 93% rename from compiler/testData/checkerWithErrorTypes/full/cast/AsErasedError.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedError.jet index bff067d20ee..2b6a8a020d3 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/AsErasedError.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedError.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.List; import java.util.Collection; diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/AsErasedFine.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedFine.jet similarity index 91% rename from compiler/testData/checkerWithErrorTypes/full/cast/AsErasedFine.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedFine.jet index 341f370d108..b4c50dc6b11 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/AsErasedFine.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedFine.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.List; import java.util.Collection; diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/AsErasedStar.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedStar.jet similarity index 85% rename from compiler/testData/checkerWithErrorTypes/full/cast/AsErasedStar.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedStar.jet index b9c2faf0d9a..4217aae11df 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/AsErasedStar.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedStar.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.List; fun ff(l: Any) = l as List<*> diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/AsErasedWarning.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedWarning.jet similarity index 89% rename from compiler/testData/checkerWithErrorTypes/full/cast/AsErasedWarning.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedWarning.jet index a55f6b7d58b..eff6dff6487 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/AsErasedWarning.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedWarning.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.List; fun ff(a: Any) = a as List diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/IsErasedAllow.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllow.jet similarity index 92% rename from compiler/testData/checkerWithErrorTypes/full/cast/IsErasedAllow.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllow.jet index 7f32b79eba2..ca46b082bc1 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/IsErasedAllow.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllow.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.Collection; import java.util.List; diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/IsErasedAllowParameterSubtype.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllowParameterSubtype.jet similarity index 93% rename from compiler/testData/checkerWithErrorTypes/full/cast/IsErasedAllowParameterSubtype.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllowParameterSubtype.jet index d1694229dc6..a4d9a515e30 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/IsErasedAllowParameterSubtype.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllowParameterSubtype.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.Collection; import java.util.List; diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/IsErasedDisallowFromAny.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedDisallowFromAny.jet similarity index 90% rename from compiler/testData/checkerWithErrorTypes/full/cast/IsErasedDisallowFromAny.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedDisallowFromAny.jet index eb3b402ccc7..76e1b3e530e 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/IsErasedDisallowFromAny.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedDisallowFromAny.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.List; fun ff(l: Any) = l is List diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/IsErasedStar.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedStar.jet similarity index 85% rename from compiler/testData/checkerWithErrorTypes/full/cast/IsErasedStar.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedStar.jet index 404d8f8f3b0..232d2a2f1c9 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/IsErasedStar.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedStar.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.List; fun ff(l: Any) = l is List<*> diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/IsReified.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsReified.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/cast/IsReified.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/IsReified.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/IsTraits.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsTraits.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/cast/IsTraits.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/IsTraits.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/cast/WhenErasedDisallowFromAny.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/WhenErasedDisallowFromAny.jet similarity index 92% rename from compiler/testData/checkerWithErrorTypes/full/cast/WhenErasedDisallowFromAny.jet rename to compiler/testData/checkerWithErrorTypes/quick/cast/WhenErasedDisallowFromAny.jet index f38a4b14fbe..af0653dd699 100644 --- a/compiler/testData/checkerWithErrorTypes/full/cast/WhenErasedDisallowFromAny.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/WhenErasedDisallowFromAny.jet @@ -1,3 +1,5 @@ +// +JDK + import java.util.List; fun ff(l: Any) = when(l) { diff --git a/compiler/testData/checkerWithErrorTypes/full/infos/Autocasts.jet b/compiler/testData/checkerWithErrorTypes/quick/infos/Autocasts.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/infos/Autocasts.jet rename to compiler/testData/checkerWithErrorTypes/quick/infos/Autocasts.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/infos/PropertiesWithBackingFields.jet b/compiler/testData/checkerWithErrorTypes/quick/infos/PropertiesWithBackingFields.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/infos/PropertiesWithBackingFields.jet rename to compiler/testData/checkerWithErrorTypes/quick/infos/PropertiesWithBackingFields.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/kt600.jet b/compiler/testData/checkerWithErrorTypes/quick/kt600.jet similarity index 96% rename from compiler/testData/checkerWithErrorTypes/full/kt600.jet rename to compiler/testData/checkerWithErrorTypes/quick/kt600.jet index b5734ce9471..6cebda6137c 100644 --- a/compiler/testData/checkerWithErrorTypes/full/kt600.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/kt600.jet @@ -1,8 +1,9 @@ //KT-600 Problem with 'sure' extension function type inference +// +JDK fun T?.sure() : T { if (this != null) return this else throw NullPointerException() } fun test() { val i : Int? = 10 val i2 : Int = i.sure() // inferred type is Int? but Int was excepted -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/AmbiguityOnLazyTypeComputation.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/AmbiguityOnLazyTypeComputation.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/AmbiguityOnLazyTypeComputation.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/AmbiguityOnLazyTypeComputation.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/AssignmentsUnderOperators.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/AssignmentsUnderOperators.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/AssignmentsUnderOperators.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/AssignmentsUnderOperators.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/CoercionToUnit.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/CoercionToUnit.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/CoercionToUnit.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/CoercionToUnit.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/DoubleDefine.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/DoubleDefine.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/regression/DoubleDefine.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/DoubleDefine.jet index 996c4608778..74da10dc846 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/DoubleDefine.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/DoubleDefine.jet @@ -1,3 +1,5 @@ +// +JDK + import java.* import util.* @@ -63,4 +65,4 @@ fun main(args: Array) { catch(e: Throwable) { System.out?.println(e.getMessage()) } -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/ErrorsOnIbjectExpressionsAsParameters.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/ErrorsOnIbjectExpressionsAsParameters.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/ErrorsOnIbjectExpressionsAsParameters.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/ErrorsOnIbjectExpressionsAsParameters.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet11.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet11.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet11.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet11.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet121.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet121.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet121.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet121.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet124.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet124.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet124.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet124.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet169.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet169.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet169.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet169.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet17.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet17.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet17.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet17.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet183-1.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet183-1.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet183-1.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet183-1.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet183.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet183.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet183.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet183.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet53.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet53.jet new file mode 100644 index 00000000000..a138884afc2 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet53.jet @@ -0,0 +1,6 @@ +// +JDK + +import java.util.Collections +import java.util.List + +val ab = Collections.emptyList() : List? diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet67.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet67.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet67.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet67.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet68.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet68.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet68.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet68.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet69.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet69.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet69.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet69.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet72.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet72.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet72.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet72.jet index d3d3272c8e3..5ca74129847 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/Jet72.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet72.jet @@ -1,4 +1,5 @@ // JET-72 Type inference doesn't work when iterating over ArrayList +// +JDK import java.util.ArrayList diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet81.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/Jet81.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet81.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/Jet81.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/OverrideResolution.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/OverrideResolution.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/OverrideResolution.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/OverrideResolution.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/ScopeForSecondaryConstructors.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/ScopeForSecondaryConstructors.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/ScopeForSecondaryConstructors.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/ScopeForSecondaryConstructors.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/SpecififcityByReceiver.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/SpecififcityByReceiver.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/SpecififcityByReceiver.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/SpecififcityByReceiver.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/ThisConstructorInGenericClass.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/ThisConstructorInGenericClass.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/ThisConstructorInGenericClass.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/ThisConstructorInGenericClass.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/WrongTraceInCallResolver.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/WrongTraceInCallResolver.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/WrongTraceInCallResolver.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/WrongTraceInCallResolver.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt251.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt251.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt251.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt251.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt258.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt258.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt258.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt258.jet index 257dfb12378..00b7e9696d4 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt258.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt258.jet @@ -1,4 +1,5 @@ // KT-258 Support equality constraints in type inference +// +JDK import java.util.* diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt287.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt287.jet similarity index 96% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt287.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt287.jet index b0efe2e6460..69d2d526fb0 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt287.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt287.jet @@ -1,4 +1,6 @@ // KT-287 Infer constructor type arguments +// +JDK + import java.util.* fun attributes() : Map = HashMap() // Should be inferred; diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt303.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt303.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt303.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt303.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt313.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt313.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt313.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt313.jet index d22f0dc4f2e..7a112bcb106 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt313.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt313.jet @@ -1,4 +1,5 @@ // KT-313 Bug in substitutions in a function returning its type parameter T +// +JDK fun Iterable.join(separator : String?) : String { return separator.npe() diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt335.336.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt335.336.jet similarity index 98% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt335.336.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt335.336.jet index 46537f0041c..e874d8f005d 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt335.336.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt335.336.jet @@ -1,5 +1,6 @@ // KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference) // KT-335 Type inference fails on Collections.sort +// +JDK import java.util.* import java.lang.Comparable as Comparable diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt385.109.441.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt385.109.441.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt385.109.441.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt385.109.441.jet index 8af621372fd..9dcac990807 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt385.109.441.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt385.109.441.jet @@ -1,6 +1,7 @@ // KT-385 type inference does not work properly` // KT-109 Good code is red: type arguments are not inferred // KT-441 Exception in type inference when multiple overloads accepting an integer literal are accessible +// +JDK import java.util.* @@ -31,4 +32,4 @@ inline fun run(body : fun() : T) : T = body() fun main(args : Array) { println(run { 1 }) -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt402.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt402.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt402.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt402.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt459.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt459.jet similarity index 92% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt459.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt459.jet index e2dd54ef0da..faa62212f38 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt459.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt459.jet @@ -1,8 +1,9 @@ // KT-459 Type argument inference fails when class names are fully qualified +// +JDK fun test() { val attributes : java.util.HashMap = java.util.HashMap() // failure! attributes["href"] = "1" // inference fails, but it shouldn't } -fun java.util.Map.set(key : K, value : V) {}//= this.put(key, value) \ No newline at end of file +fun java.util.Map.set(key : K, value : V) {}//= this.put(key, value) diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt469.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt469.jet similarity index 98% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt469.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt469.jet index 3d01d2efee9..a9ff4c1d291 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt469.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt469.jet @@ -1,3 +1,5 @@ +// +JDK + namespace kt469 //KT-512 plusAssign() : Unit does not work properly diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt549.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt549.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt549.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt549.jet index 9e4725f142e..5fc17be122b 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt549.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt549.jet @@ -1,4 +1,6 @@ //KT-549 type inference failed +// +JDK + namespace demo fun filter(list : Array, filter : fun (T) : Boolean) : java.util.List { diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt58.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt58.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt58.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt58.jet index 7ebe0ee8feb..57562a61f37 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt58.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt58.jet @@ -1,4 +1,5 @@ //KT-58 Allow finally around definite returns +// +JDK namespace kt58 @@ -88,4 +89,4 @@ fun t7() : Int { } fun doSmth(i: Int) { -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt580.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt580.jet similarity index 90% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt580.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt580.jet index d05397ef6e0..a3689acc91d 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt580.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt580.jet @@ -1,4 +1,6 @@ //KT-580 Type inference failed +// +JDK + namespace whats.the.difference import java.util.* @@ -17,4 +19,4 @@ fun main(vals : IntArray) { } fun Array.lastIndex() = size - 1 -val Array.lastIndex : Int get() = size - 1 \ No newline at end of file +val Array.lastIndex : Int get() = size - 1 diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt588.jet b/compiler/testData/checkerWithErrorTypes/quick/regression/kt588.jet similarity index 95% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt588.jet rename to compiler/testData/checkerWithErrorTypes/quick/regression/kt588.jet index 2b4b4d86ff4..410c70c3479 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt588.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regression/kt588.jet @@ -1,4 +1,6 @@ // KT-588 Unresolved static method +// +JDK + class Test() : Thread("Test") { class object { fun init2() { @@ -9,4 +11,4 @@ class Test() : Thread("Test") { init2() // unresolved Test.init2() // ok } -} \ No newline at end of file +} diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet index 7420cb938e5..33500c845c4 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet @@ -1,4 +1,5 @@ //KT-235 Illegal assignment return type +// +JDK namespace kt235 @@ -46,4 +47,4 @@ class MyArray1() { class MyNumber() { fun inc(): MyNumber = MyNumber() -} \ No newline at end of file +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/FullJetPsiCheckerTest.java b/compiler/tests/org/jetbrains/jet/checkers/FullJetPsiCheckerTest.java deleted file mode 100644 index b16946132bf..00000000000 --- a/compiler/tests/org/jetbrains/jet/checkers/FullJetPsiCheckerTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package org.jetbrains.jet.checkers; - -import com.google.common.collect.Lists; -import com.intellij.openapi.util.TextRange; -import junit.framework.Test; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.JetLiteFixture; -import org.jetbrains.jet.JetTestCaseBuilder; -import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; -import org.jetbrains.jet.lang.resolve.AnalyzingUtils; -import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.resolve.ImportingStrategy; -import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade; -import org.jetbrains.jet.lang.resolve.java.JavaDefaultImports; - -import java.util.List; - -/** - * @author abreslav - */ -public class FullJetPsiCheckerTest extends JetLiteFixture { - private final String myDataPath; - private String myName; - - public FullJetPsiCheckerTest(@NonNls String dataPath, String name) { - myDataPath = dataPath; - myName = name; - } - - @Override - public String getName() { - return "test" + myName; - } - - @Override - public void runTest() throws Exception { - String fileName = myName + ".jet"; - String fullPath = myDataPath + "/" + fileName; - - - String expectedText = loadFile(fullPath); - - List diagnosedRanges = Lists.newArrayList(); - String clearText = CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges); - - myFile = createPsiFile(myName, clearText); - - boolean importJdk = !expectedText.contains("-JDK"); - ImportingStrategy importingStrategy = importJdk ? JavaDefaultImports.JAVA_DEFAULT_IMPORTS : ImportingStrategy.NONE; - - BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(AnalyzingUtils.getInstance(importingStrategy), myFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER); - - CheckerTestUtil.diagnosticsDiff(diagnosedRanges, bindingContext.getDiagnostics(), new CheckerTestUtil.DiagnosticDiffCallbacks() { - @Override - public void missingDiagnostic(String type, int expectedStart, int expectedEnd) { - String message = "Missing " + type + DiagnosticUtils.atLocation(myFile, new TextRange(expectedStart, expectedEnd)); - System.err.println(message); - } - - @Override - public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) { - String message = "Unexpected " + type + DiagnosticUtils.atLocation(myFile, new TextRange(actualStart, actualEnd)); - System.err.println(message); - } - }); - - String actualText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString(); - - assertEquals(expectedText, actualText); - -// String myFullDataPath = getTestDataPath() + getDataPath(); -// System.out.println("myFullDataPath = " + myFullDataPath); -// convert(new File(myFullDataPath + "/../../checker/"), new File(myFullDataPath)); - } - -/* - private void convert(File src, File dest) throws IOException { - File[] files = src.listFiles(); - for (File file : files) { - try { - if (file.isDirectory()) { - File destDir = new File(dest, file.getName()); - destDir.mkdir(); - convert(file, destDir); - continue; - } - if (!file.getName().endsWith(".jet")) continue; - String text = loadFile(file.getAbsolutePath()); - Pattern pattern = Pattern.compile(""); - String clearText = pattern.matcher(text).replaceAll(""); - - configureFromFileText(file.getName(), clearText); - - BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache((JetFile) myFile); - String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString(); - - File destFile = new File(dest, file.getName()); - FileWriter fileWriter = new FileWriter(destFile); - fileWriter.write(expectedText); - fileWriter.close(); - } - catch (RuntimeException e) { - e.printStackTrace(); - } - } - } -*/ - - public static Test suite() { - return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/checkerWithErrorTypes/full/", true, new JetTestCaseBuilder.NamedTestFactory() { - @NotNull - @Override - public Test createTest(@NotNull String dataPath, @NotNull String name) { - return new FullJetPsiCheckerTest(dataPath, name); - } - }); - } -} From a52d9a28cce954dac1950be3906982fd2a0ce008 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Fri, 25 Nov 2011 18:31:28 +0400 Subject: [PATCH 05/11] merge regression folders --- .../AmbiguityOnLazyTypeComputation.jet | 0 .../{regression => regressions}/AssignmentsUnderOperators.jet | 0 .../quick/{regression => regressions}/CoercionToUnit.jet | 0 .../quick/{regression => regressions}/DoubleDefine.jet | 0 .../ErrorsOnIbjectExpressionsAsParameters.jet | 0 .../quick/{regression => regressions}/Jet11.jet | 0 .../quick/{regression => regressions}/Jet121.jet | 0 .../quick/{regression => regressions}/Jet124.jet | 0 .../quick/{regression => regressions}/Jet169.jet | 0 .../quick/{regression => regressions}/Jet17.jet | 0 .../quick/{regression => regressions}/Jet183-1.jet | 0 .../quick/{regression => regressions}/Jet183.jet | 0 .../quick/{regression => regressions}/Jet53.jet | 0 .../quick/{regression => regressions}/Jet67.jet | 0 .../quick/{regression => regressions}/Jet68.jet | 0 .../quick/{regression => regressions}/Jet69.jet | 0 .../quick/{regression => regressions}/Jet72.jet | 0 .../quick/{regression => regressions}/Jet81.jet | 0 .../quick/{regression => regressions}/OverrideResolution.jet | 0 .../{regression => regressions}/ScopeForSecondaryConstructors.jet | 0 .../quick/{regression => regressions}/SpecififcityByReceiver.jet | 0 .../{regression => regressions}/ThisConstructorInGenericClass.jet | 0 .../{regression => regressions}/WrongTraceInCallResolver.jet | 0 .../quick/{regression => regressions}/kt251.jet | 0 .../quick/{regression => regressions}/kt258.jet | 0 .../quick/{regression => regressions}/kt287.jet | 0 .../quick/{regression => regressions}/kt303.jet | 0 .../quick/{regression => regressions}/kt313.jet | 0 .../quick/{regression => regressions}/kt335.336.jet | 0 .../quick/{regression => regressions}/kt385.109.441.jet | 0 .../quick/{regression => regressions}/kt402.jet | 0 .../quick/{regression => regressions}/kt459.jet | 0 .../quick/{regression => regressions}/kt469.jet | 0 .../quick/{regression => regressions}/kt549.jet | 0 .../quick/{regression => regressions}/kt58.jet | 0 .../quick/{regression => regressions}/kt580.jet | 0 .../quick/{regression => regressions}/kt588.jet | 0 .../checkerWithErrorTypes/quick/{ => regressions}/kt600.jet | 0 38 files changed, 0 insertions(+), 0 deletions(-) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/AmbiguityOnLazyTypeComputation.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/AssignmentsUnderOperators.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/CoercionToUnit.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/DoubleDefine.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/ErrorsOnIbjectExpressionsAsParameters.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet11.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet121.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet124.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet169.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet17.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet183-1.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet183.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet53.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet67.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet68.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet69.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet72.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/Jet81.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/OverrideResolution.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/ScopeForSecondaryConstructors.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/SpecififcityByReceiver.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/ThisConstructorInGenericClass.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/WrongTraceInCallResolver.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt251.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt258.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt287.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt303.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt313.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt335.336.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt385.109.441.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt402.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt459.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt469.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt549.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt58.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt580.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{regression => regressions}/kt588.jet (100%) rename compiler/testData/checkerWithErrorTypes/quick/{ => regressions}/kt600.jet (100%) diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/AmbiguityOnLazyTypeComputation.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/AmbiguityOnLazyTypeComputation.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/AmbiguityOnLazyTypeComputation.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/AmbiguityOnLazyTypeComputation.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/AssignmentsUnderOperators.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/AssignmentsUnderOperators.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/AssignmentsUnderOperators.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/AssignmentsUnderOperators.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/CoercionToUnit.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/CoercionToUnit.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/CoercionToUnit.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/CoercionToUnit.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/DoubleDefine.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/DoubleDefine.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/DoubleDefine.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/DoubleDefine.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/ErrorsOnIbjectExpressionsAsParameters.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/ErrorsOnIbjectExpressionsAsParameters.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/ErrorsOnIbjectExpressionsAsParameters.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/ErrorsOnIbjectExpressionsAsParameters.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet11.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet11.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet11.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet11.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet121.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet121.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet121.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet121.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet124.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet124.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet124.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet124.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet169.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet169.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet169.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet169.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet17.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet17.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet17.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet17.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet183-1.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet183-1.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet183-1.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet183-1.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet183.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet183.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet183.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet183.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet53.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet53.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet53.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet53.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet67.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet67.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet67.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet67.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet68.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet68.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet68.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet68.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet69.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet69.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet69.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet69.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet72.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet72.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet72.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet72.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/Jet81.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet81.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/Jet81.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet81.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/OverrideResolution.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/OverrideResolution.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/OverrideResolution.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/OverrideResolution.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/ScopeForSecondaryConstructors.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/ScopeForSecondaryConstructors.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/ScopeForSecondaryConstructors.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/ScopeForSecondaryConstructors.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/SpecififcityByReceiver.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/SpecififcityByReceiver.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/SpecififcityByReceiver.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/SpecififcityByReceiver.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/ThisConstructorInGenericClass.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/ThisConstructorInGenericClass.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/ThisConstructorInGenericClass.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/ThisConstructorInGenericClass.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/WrongTraceInCallResolver.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/WrongTraceInCallResolver.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/WrongTraceInCallResolver.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/WrongTraceInCallResolver.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt251.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt251.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt251.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt251.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt258.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt258.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt258.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt258.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt287.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt287.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt287.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt287.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt303.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt303.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt303.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt303.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt313.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt313.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt313.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt313.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt335.336.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt335.336.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt335.336.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt335.336.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt385.109.441.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt385.109.441.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt385.109.441.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt385.109.441.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt402.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt402.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt402.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt402.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt459.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt459.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt459.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt459.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt469.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt469.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt469.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt469.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt549.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt549.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt549.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt549.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt58.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt58.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt58.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt58.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt580.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt580.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt580.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt580.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regression/kt588.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt588.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/regression/kt588.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt588.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/kt600.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt600.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/quick/kt600.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt600.jet From a7eada71ce8e5af7a1bf15322b842b8deaa897eb Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 25 Nov 2011 18:32:03 +0300 Subject: [PATCH 06/11] By Pavel Talanov: KT-618 overloaded assignment operators should not allow for returning types other than Unit of Subtypes or the type where they are defined --- .../ExpressionTypingVisitorForStatements.java | 25 +++++++++++++++-- .../quick/regressions/kt618.jet | 28 +++++++++++++++++++ 2 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 compiler/testData/checkerWithErrorTypes/quick/regressions/kt618.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java index 68704d336ee..7ed8e8e7c12 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorForStatements.java @@ -20,11 +20,12 @@ import org.jetbrains.jet.lexer.JetTokens; import static org.jetbrains.jet.lang.diagnostics.Errors.*; import static org.jetbrains.jet.lang.resolve.BindingContext.INDEXED_LVALUE_SET; +import static org.jetbrains.jet.lang.resolve.BindingContext.VARIABLE_REASSIGNMENT; import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.getExpressionReceiver; /** -* @author abreslav -*/ + * @author abreslav + */ public class ExpressionTypingVisitorForStatements extends BasicExpressionTypingVisitor { private final WritableScope scope; @@ -138,17 +139,35 @@ public class ExpressionTypingVisitorForStatements extends BasicExpressionTypingV } assignmentOperationType = getTypeForBinaryCall(scope, counterpartName, context, expression); if (assignmentOperationType != null) { - context.trace.record(BindingContext.VARIABLE_REASSIGNMENT, expression); + context.trace.record(VARIABLE_REASSIGNMENT, expression); ExpressionTypingUtils.checkWrappingInRef(expression.getLeft(), context); } } else { temporaryBindingTrace.commit(); + checkReassignment(expression, context, assignmentOperationType, left); } checkLValue(context.trace, expression.getLeft()); return checkAssignmentType(assignmentOperationType, expression, contextWithExpectedType); } + private void checkReassignment(@NotNull JetBinaryExpression expression, @NotNull ExpressionTypingContext context, + @NotNull JetType assignmentOperationType, @Nullable JetExpression left) { + if (left == null) return; + JetType leftType = facade.getType(left, context.replaceScope(scope)); + if (leftType == null) return; + boolean isUnit = context.semanticServices.getTypeChecker(). + isSubtypeOf(assignmentOperationType, JetStandardClasses.getUnitType()); + if (isUnit) return; + + if (context.semanticServices.getTypeChecker().isSubtypeOf(assignmentOperationType, leftType)) { + context.trace.record(VARIABLE_REASSIGNMENT, expression); + } + else { + context.trace.report(TYPE_MISMATCH.on(expression, leftType, assignmentOperationType)); + } + } + @Override protected JetType visitAssignment(JetBinaryExpression expression, ExpressionTypingContext contextWithExpectedType) { ExpressionTypingContext context = contextWithExpectedType.replaceExpectedType(TypeUtils.NO_EXPECTED_TYPE).replaceExpectedReturnType(TypeUtils.NO_EXPECTED_TYPE); diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt618.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt618.jet new file mode 100644 index 00000000000..569d286c17b --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt618.jet @@ -0,0 +1,28 @@ +namespace lol + +class B() { + fun plusAssign(other : B) : String { + return "s" + } + fun minusAssign(other : B) : String { + return "s" + } + fun modAssign(other : B) : String { + return "s" + } + fun divAssign(other : B) : String { + return "s" + } + fun timesAssign(other : B) : String { + return "s" + } +} + +fun main(args : Array) { + var c = B() + c += B() + c *= B() + c /= B() + c -= B() + c %= B() +} From 0bd0932282ee53a44c3f303b66cc30faf5060869 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Fri, 25 Nov 2011 21:39:28 +0400 Subject: [PATCH 07/11] remove unintentional variable redeclarations --- compiler/testData/checkerWithErrorTypes/quick/Abstract.jet | 2 +- .../testData/checkerWithErrorTypes/quick/regressions/kt235.jet | 2 +- .../testData/checkerWithErrorTypes/quick/regressions/kt580.jet | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/testData/checkerWithErrorTypes/quick/Abstract.jet b/compiler/testData/checkerWithErrorTypes/quick/Abstract.jet index 1ab361db8d8..a13891668c6 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(a: B3) { +fun foo(c: B3) { val a = B3() val b = B1(2, "s") } diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet index 33500c845c4..c5a96d7c961 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt235.jet @@ -17,7 +17,7 @@ fun main(args: Array) { x = 2 //the same } val array1 = MyArray1() - val x = { (): String => + val i = { (): String => array1[2] = 23 } diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt580.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt580.jet index a3689acc91d..c2d12ec6e93 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt580.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt580.jet @@ -7,7 +7,7 @@ import java.util.* fun iarray(vararg a : String) = a // BUG -fun main(vals : IntArray) { +fun main() { val vals = iarray("789", "678", "567") val diffs = ArrayList for (i in vals.indices) { From a6eeb01b64723fde9b53235904f7c9d2996d93da Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Fri, 25 Nov 2011 22:31:29 +0400 Subject: [PATCH 08/11] try to fix VarArgTest Accoring to spec array of class.getMethods() is not sorted, so we can't just call getMethods()[0] to get desired method. --- .../jetbrains/jet/codegen/CodegenTestCase.java | 18 +++++++++++++++++- .../jet/codegen/NamespaceGenTest.java | 2 +- .../org/jetbrains/jet/codegen/VarArgTest.java | 11 +++++------ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java index 8c584e9cc26..485a97b80d2 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java +++ b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java @@ -7,10 +7,12 @@ import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetNamespace; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.parsing.JetParsingTest; +import org.junit.Assert; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -157,7 +159,21 @@ public abstract class CodegenTestCase extends JetLiteFixture { protected Method generateFunction() { Class aClass = generateNamespaceClass(); try { - return aClass.getMethods()[0]; + Method r = null; + for (Method method : aClass.getMethods()) { + if (method.getDeclaringClass().equals(Object.class)) { + continue; + } + + if (r != null) { + throw new AssertionError("more then one public method in class " + aClass); + } + + r = method; + } + if (r == null) + throw new AssertionError(); + return r; } catch (Error e) { System.out.println(generateToText()); throw e; diff --git a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index 81865f848af..295781b1837 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -487,7 +487,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testTupleLiteral() throws Exception { loadText("fun foo() = (1, \"foo\")"); // System.out.println(generateToText()); - final Method main = generateFunction(); + final Method main = generateFunction("foo"); Tuple2 tuple2 = (Tuple2) main.invoke(null); assertEquals(1, tuple2._1); assertEquals("foo", tuple2._2); diff --git a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java index 62fbe452833..e08b515771c 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java @@ -26,7 +26,7 @@ public class VarArgTest extends CodegenTestCase { public void testIntArrayKotlinNoArgs () throws InvocationTargetException, IllegalAccessException { loadText("fun test() = testf(); fun testf(vararg ts: Int) = ts"); // System.out.println(generateToText()); - final Method main = generateFunction(); + final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((int[])res).length == 0); } @@ -34,8 +34,7 @@ public class VarArgTest extends CodegenTestCase { public void testIntArrayKotlin () throws InvocationTargetException, IllegalAccessException { loadText("fun test() = testf(239, 7); fun testf(vararg ts: Int) = ts"); // System.out.println(generateToText()); - final Method main = generateFunction(); - System.out.println(main.toString()); + final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((int[])res).length == 2); assertTrue(((int[])res)[0] == 239); @@ -45,7 +44,7 @@ public class VarArgTest extends CodegenTestCase { public void testNullableIntArrayKotlin () throws InvocationTargetException, IllegalAccessException { loadText("fun test() = testf(239.byt, 7.byt); fun testf(vararg ts: Byte?) = ts"); // System.out.println(generateToText()); - final Method main = generateFunction(); + final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((Byte[])res).length == 2); assertTrue(((Byte[])res)[0] == (byte)239); @@ -55,7 +54,7 @@ public class VarArgTest extends CodegenTestCase { public void testIntArrayKotlinObj () throws InvocationTargetException, IllegalAccessException { loadText("fun test() = testf(\"239\"); fun testf(vararg ts: String) = ts"); // System.out.println(generateToText()); - final Method main = generateFunction(); + final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((String[])res).length == 1); assertTrue(((String[])res)[0].equals("239")); @@ -64,7 +63,7 @@ public class VarArgTest extends CodegenTestCase { public void testArrayT () throws InvocationTargetException, IllegalAccessException { loadText("fun test() = _array(2, 4); fun _array(vararg elements : T) = elements"); // System.out.println(generateToText()); - final Method main = generateFunction(); + final Method main = generateFunction("test"); Object res = main.invoke(null); assertTrue(((Integer[])res).length == 2); assertTrue(((Integer[])res)[0].equals(2)); From 2cbd072478370959e1d41bbc8f85bf355197b951 Mon Sep 17 00:00:00 2001 From: Alex Tkachman Date: Sat, 26 Nov 2011 09:30:24 +0200 Subject: [PATCH 09/11] npe() runtime intrinsic method. --- .../codegen/intrinsics/IntrinsicMethods.java | 1 + .../jetbrains/jet/codegen/intrinsics/NPE.java | 24 ++++++++++++++ compiler/frontend/src/jet/Library.jet | 4 +-- .../org/jetbrains/jet/runtime/JetNpeTest.java | 32 +++++++++++++++++++ stdlib/src/jet/runtime/Intrinsics.java | 10 ++++++ .../jet/runtime/JetNullPointerException.java | 32 +++++++++++++++++++ 6 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/NPE.java create mode 100644 compiler/tests/org/jetbrains/jet/runtime/JetNpeTest.java create mode 100644 stdlib/src/jet/runtime/JetNullPointerException.java diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java index e86d46bfb8e..2edc35848db 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java @@ -87,6 +87,7 @@ public class IntrinsicMethods { declareOverload(myStdLib.getLibraryScope().getFunctions("identityEquals"), 1, EQUALS); declareOverload(myStdLib.getLibraryScope().getFunctions("plus"), 1, new StringPlus()); declareOverload(myStdLib.getLibraryScope().getFunctions("Array"), 1, new NewArray()); + declareOverload(myStdLib.getLibraryScope().getFunctions("npe"), 0, new NPE()); declareIntrinsicFunction("ByteIterator", "next", 0, ITERATOR_NEXT); declareIntrinsicFunction("ShortIterator", "next", 0, ITERATOR_NEXT); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/NPE.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/NPE.java new file mode 100644 index 00000000000..c0bd922f973 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/NPE.java @@ -0,0 +1,24 @@ +package org.jetbrains.jet.codegen.intrinsics; + +import com.intellij.psi.PsiElement; +import org.jetbrains.jet.codegen.ExpressionCodegen; +import org.jetbrains.jet.codegen.JetTypeMapper; +import org.jetbrains.jet.codegen.StackValue; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.InstructionAdapter; + +import java.util.List; + +/** + * @author alex.tkachman + */ +public class NPE implements IntrinsicMethod { + @Override + public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List arguments, StackValue receiver) { + receiver.put(JetTypeMapper.TYPE_OBJECT, v); + v.invokestatic("jet/runtime/Intrinsics", "npe", "(Ljava/lang/Object;)Ljava/lang/Object;"); + StackValue.onStack(JetTypeMapper.TYPE_OBJECT).put(expectedType, v); + return StackValue.onStack(expectedType); + } +} diff --git a/compiler/frontend/src/jet/Library.jet b/compiler/frontend/src/jet/Library.jet index 279171d8776..f085b8012b2 100644 --- a/compiler/frontend/src/jet/Library.jet +++ b/compiler/frontend/src/jet/Library.jet @@ -42,9 +42,7 @@ fun Any?.equals(other : Any?) : Boolean// = this === other // Returns "null" for null fun Any?.toString() : String// = this === other -// fun array(vararg elements : T) : Array - -// fun array(vararg elements : Int) : IntArray +fun T?.npe() : T fun String?.plus(other: Any?) : String diff --git a/compiler/tests/org/jetbrains/jet/runtime/JetNpeTest.java b/compiler/tests/org/jetbrains/jet/runtime/JetNpeTest.java new file mode 100644 index 00000000000..cf0ff45814a --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/runtime/JetNpeTest.java @@ -0,0 +1,32 @@ +package org.jetbrains.jet.runtime; + +import jet.runtime.Intrinsics; +import junit.framework.TestCase; +import org.jetbrains.jet.codegen.CodegenTestCase; + +import java.lang.reflect.Method; + +public class JetNpeTest extends CodegenTestCase { + public void testStackTrace () { + try { + Intrinsics.npe(null); + fail("No NPE thrown"); + } + catch (NullPointerException e) { + StackTraceElement stackTraceElement = e.getStackTrace()[0]; + assertEquals(stackTraceElement.getMethodName(), "testStackTrace"); + assertEquals(stackTraceElement.getClassName(), "org.jetbrains.jet.runtime.JetNpeTest"); + } + } + + public void testNotNull () throws Exception { + loadText("fun box() = if(10.npe() == 10) \"OK\" else \"fail\""); + blackBox(); + } + + public void testNull () throws Exception { + loadText("fun box() = if(null.npe() == 10) \"OK\" else \"fail\""); + Method box = generateFunction("box"); + assertThrows(box, NullPointerException.class, null); + } +} diff --git a/stdlib/src/jet/runtime/Intrinsics.java b/stdlib/src/jet/runtime/Intrinsics.java index 9243275e611..9f26a0f72b5 100644 --- a/stdlib/src/jet/runtime/Intrinsics.java +++ b/stdlib/src/jet/runtime/Intrinsics.java @@ -10,4 +10,14 @@ public class Intrinsics { public static String stringPlus(String self, Object other) { return ((self == null) ? "null" : self) + ((other == null) ? "null" : other.toString()); } + + public static Object npe(Object self) { + if(self == null) + return throwNpe(); + return self; + } + + private static Object throwNpe() { + throw new JetNullPointerException(); + } } diff --git a/stdlib/src/jet/runtime/JetNullPointerException.java b/stdlib/src/jet/runtime/JetNullPointerException.java new file mode 100644 index 00000000000..ec9c6a0c1d5 --- /dev/null +++ b/stdlib/src/jet/runtime/JetNullPointerException.java @@ -0,0 +1,32 @@ +package jet.runtime; + +import java.util.ArrayList; + +/** +* @author alex.tkachman +*/ +class JetNullPointerException extends NullPointerException { + @Override + public synchronized Throwable fillInStackTrace() { + super.fillInStackTrace(); + StackTraceElement[] stackTrace = getStackTrace(); + ArrayList list = new ArrayList(); + boolean skip = true; + for(StackTraceElement ste : stackTrace) { + if(!skip) { + list.add(ste); + } + else { + if("jet.runtime.Intrinsics".equals(ste.getClassName()) && "npe".equals(ste.getMethodName())) { + skip = false; + } + } + } + setStackTrace(list.toArray(new StackTraceElement[list.size()])); + return this; + } + + public static void main(String[] args) { + Intrinsics.npe(null); + } +} From 554aab83be4878f8cdce5fdb5fd7585077693dae Mon Sep 17 00:00:00 2001 From: Alex Tkachman Date: Sat, 26 Nov 2011 10:01:57 +0200 Subject: [PATCH 10/11] npe() renamed to sure() --- .../jet/codegen/ExpressionCodegen.java | 42 ++++++++----------- .../jet/codegen/intrinsics/Concat.java | 2 +- .../codegen/intrinsics/IntrinsicMethods.java | 3 +- .../intrinsics/{NPE.java => Sure.java} | 4 +- compiler/frontend/src/jet/Library.jet | 2 +- .../quick/regressions/kt600.jet | 4 +- .../org/jetbrains/jet/runtime/JetNpeTest.java | 10 ++--- stdlib/src/jet/runtime/Intrinsics.java | 30 ++++++++++++- .../jet/runtime/JetNullPointerException.java | 32 -------------- 9 files changed, 58 insertions(+), 71 deletions(-) rename compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/{NPE.java => Sure.java} (84%) delete mode 100644 stdlib/src/jet/runtime/JetNullPointerException.java diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 0aa482db4b4..3ab8cc82519 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -35,18 +35,10 @@ import java.util.*; * @author alex.tkachman */ public class ExpressionCodegen extends JetVisitor { - private static final String CLASS_OBJECT = "java/lang/Object"; - private static final String CLASS_STRING = "java/lang/String"; - public static final String CLASS_STRING_BUILDER = "java/lang/StringBuilder"; - private static final String CLASS_COMPARABLE = "java/lang/Comparable"; private static final String CLASS_NO_PATTERN_MATCHED_EXCEPTION = "jet/NoPatternMatchedException"; private static final String CLASS_TYPE_CAST_EXCEPTION = "jet/TypeCastException"; - private static final Type OBJECT_TYPE = Type.getType(Object.class); - private static final Type THROWABLE_TYPE = Type.getType(Throwable.class); - private static final Type STRING_TYPE = Type.getObjectType(CLASS_STRING); - private final Stack