diff --git a/bootstrap.xml b/bootstrap.xml index 1697aacc6b7..695ce5f2e03 100644 --- a/bootstrap.xml +++ b/bootstrap.xml @@ -1,4 +1,21 @@ + + + + @{prop}=${@{prop}} + + + + + + + + + + + + + diff --git a/build.xml b/build.xml index bc0ee63e9f7..6c91c946fa5 100644 --- a/build.xml +++ b/build.xml @@ -20,7 +20,7 @@ - + @@ -36,7 +36,7 @@ - + diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java index ce0eb62f800..a1135e9c65c 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenContext.java @@ -10,6 +10,7 @@ import org.objectweb.asm.commons.InstructionAdapter; import java.util.Collections; import java.util.HashMap; +import java.util.LinkedHashMap; /* * @author max @@ -38,6 +39,8 @@ public abstract class CodegenContext { public final ObjectOrClosureCodegen closure; HashMap typeInfoConstants; + HashMap reverseTypeInfoConstants; + int typeInfoConstantsCount; HashMap accessors; protected StackValue outerExpression; @@ -177,13 +180,16 @@ public abstract class CodegenContext { if(parentContext != STATIC) return parentContext.getTypeInfoConstantIndex(type); - if(typeInfoConstants == null) - typeInfoConstants = new HashMap(); + if(typeInfoConstants == null) { + typeInfoConstants = new LinkedHashMap(); + reverseTypeInfoConstants = new LinkedHashMap(); + } Integer index = typeInfoConstants.get(type); if(index == null) { - index = typeInfoConstants.size(); + index = typeInfoConstantsCount++; typeInfoConstants.put(type, index); + reverseTypeInfoConstants.put(index, type); } return index; } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index e69555a882b..0aa482db4b4 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -2068,14 +2068,14 @@ public class ExpressionCodegen extends JetVisitor { return type; } - private void generateNewArray(JetCallExpression expression, JetType arrayType) { + public void generateNewArray(JetCallExpression expression, JetType arrayType) { List args = expression.getValueArguments(); boolean isArray = state.getStandardLibrary().getArray().equals(arrayType.getConstructor().getDeclarationDescriptor()); if(isArray) { - if (args.size() != 2 && !arrayType.getArguments().get(0).getType().isNullable()) { - throw new CompilationException("array constructor of non-nullable type requires two arguments"); - } +// if (args.size() != 2 && !arrayType.getArguments().get(0).getType().isNullable()) { +// throw new CompilationException("array constructor of non-nullable type requires two arguments"); +// } } else { if (args.size() != 1) { @@ -2445,18 +2445,28 @@ If finally block is present, its last expression is the value of try expression. return StackValue.onStack(Type.BOOLEAN_TYPE); } + public boolean hasTypeInfoForInstanceOf(JetType type) { + DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor(); + if(declarationDescriptor instanceof TypeParameterDescriptor) + return true; + + ClassDescriptor classDescriptor = (ClassDescriptor) declarationDescriptor.getOriginal(); + if(classDescriptor.equals(state.getStandardLibrary().getArray())) { + return hasTypeInfoForInstanceOf(type.getArguments().get(0).getType()); + } + + for(TypeParameterDescriptor proj : classDescriptor.getTypeConstructor().getParameters()) { + if(proj.isReified()) { + return true; + } + } + + return false; + } + private void generateInstanceOf(StackValue expressionToGen, JetType jetType, boolean leaveExpressionOnStack) { DeclarationDescriptor descriptor = jetType.getConstructor().getDeclarationDescriptor(); - boolean javaClass = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor) instanceof PsiClass; - if (!javaClass && (jetType.getArguments().size() > 0 || !(descriptor instanceof ClassDescriptor))) { - generateTypeInfo(jetType); - expressionToGen.put(OBJECT_TYPE, v); - if (leaveExpressionOnStack) { - v.dupX1(); - } - v.invokevirtual("jet/typeinfo/TypeInfo", "isInstance", "(Ljava/lang/Object;)Z"); - } - else { + if (!hasTypeInfoForInstanceOf(jetType)) { expressionToGen.put(OBJECT_TYPE, v); if (leaveExpressionOnStack) { v.dup(); @@ -2479,6 +2489,14 @@ If finally block is present, its last expression is the value of try expression. v.instanceOf(type); } } + else { + generateTypeInfo(jetType); + expressionToGen.put(OBJECT_TYPE, v); + if (leaveExpressionOnStack) { + v.dupX1(); + } + v.invokevirtual("jet/typeinfo/TypeInfo", "isInstance", "(Ljava/lang/Object;)Z"); + } } public void generateTypeInfo(JetType jetType) { @@ -2656,30 +2674,6 @@ If finally block is present, its last expression is the value of try expression. conditionValue = generatePatternMatch(pattern, patternCondition.isNegated(), StackValue.local(subjectLocal, subjectType), nextEntry); } - else if (condition instanceof JetWhenConditionCall) { - final JetExpression call = ((JetWhenConditionCall) condition).getCallSuffixExpression(); - if (call instanceof JetCallExpression) { - v.load(subjectLocal, subjectType); - final DeclarationDescriptor declarationDescriptor = resolveCalleeDescriptor((JetCallExpression) call); - if (!(declarationDescriptor instanceof FunctionDescriptor)) { - throw new UnsupportedOperationException("expected function descriptor in when condition with call, found " + declarationDescriptor); - } - conditionValue = invokeFunction((JetCallExpression) call, declarationDescriptor, StackValue.onStack(subjectType)); - } - else if (call instanceof JetSimpleNameExpression) { - final DeclarationDescriptor descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call); - if (descriptor instanceof PropertyDescriptor) { - v.load(subjectLocal, subjectType); - conditionValue = intermediateValueForProperty((PropertyDescriptor) descriptor, false, null); - } - else { - throw new UnsupportedOperationException("unknown simple name resolve result: " + descriptor); - } - } - else { - throw new UnsupportedOperationException("unsupported kind of call suffix"); - } - } else { throw new UnsupportedOperationException("unsupported kind of when condition"); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java index 908c8d29867..837c1503717 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java @@ -14,9 +14,7 @@ import org.objectweb.asm.MethodVisitor; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; -import java.util.Collections; import java.util.List; -import java.util.Map; import static org.objectweb.asm.Opcodes.*; @@ -114,11 +112,12 @@ public class NamespaceCodegen { private void generateTypeInfoFields(JetNamespace namespace, CodegenContext context) { if(context.typeInfoConstants != null) { String jvmClassName = getJVMClassName(namespace.getName()); - for(Map.Entry e : (context.typeInfoConstants != null ? context.typeInfoConstants : Collections.emptyMap()).entrySet()) { - String fieldName = "$typeInfoCache$" + e.getValue(); + for(int index = 0; index != context.typeInfoConstantsCount; index++) { + JetType type = context.reverseTypeInfoConstants.get(index); + String fieldName = "$typeInfoCache$" + index; v.newField(null, ACC_PRIVATE | ACC_STATIC | ACC_SYNTHETIC, fieldName, "Ljet/typeinfo/TypeInfo;", null, null); - MethodVisitor mmv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, "$getCachedTypeInfo$" + e.getValue(), "()Ljet/typeinfo/TypeInfo;", null, null); + MethodVisitor mmv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC | ACC_SYNTHETIC, "$getCachedTypeInfo$" + index, "()Ljet/typeinfo/TypeInfo;", null, null); InstructionAdapter v = new InstructionAdapter(mmv); v.visitFieldInsn(GETSTATIC, jvmClassName, fieldName, "Ljet/typeinfo/TypeInfo;"); v.visitInsn(DUP); @@ -126,7 +125,7 @@ public class NamespaceCodegen { v.visitJumpInsn(IFNONNULL, end); v.pop(); - generateTypeInfo(context, v, e.getKey(), state.getTypeMapper(), e.getKey()); + generateTypeInfo(context, v, type, state.getTypeMapper(), type); v.dup(); v.visitFieldInsn(PUTSTATIC, jvmClassName, fieldName, "Ljet/typeinfo/TypeInfo;"); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java index 8c199a571a3..fc1292cf899 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/Increment.java @@ -5,6 +5,7 @@ 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.jetbrains.jet.lang.psi.JetParenthesizedExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; @@ -23,7 +24,10 @@ public class Increment implements IntrinsicMethod { @Override public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List arguments, StackValue receiver) { - final JetExpression operand = arguments.get(0); + JetExpression operand = arguments.get(0); + while(operand instanceof JetParenthesizedExpression) { + operand = ((JetParenthesizedExpression)operand).getExpression(); + } if (operand instanceof JetReferenceExpression) { final int index = codegen.indexOfLocal((JetReferenceExpression) operand); if (index >= 0 && JetTypeMapper.isIntPrimitive(expectedType)) { @@ -33,6 +37,7 @@ public class Increment implements IntrinsicMethod { } StackValue value = codegen.genQualified(receiver, operand); value. dupReceiver(v); + value. dupReceiver(v); value.put(expectedType, v); if (expectedType == Type.LONG_TYPE) { v.lconst(myDelta); @@ -44,10 +49,11 @@ public class Increment implements IntrinsicMethod { v.dconst(myDelta); } else { - v.aconst(myDelta); + v.iconst(myDelta); } v.add(expectedType); value.store(v); - return value; + value.put(expectedType, v); + return StackValue.onStack(expectedType); } } 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 a75db2d5a37..e86d46bfb8e 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/IntrinsicMethods.java @@ -15,6 +15,7 @@ import org.jetbrains.jet.lang.types.JetStandardLibrary; import org.jetbrains.jet.lang.types.TypeProjection; import org.jetbrains.jet.plugin.JetFileType; import org.objectweb.asm.Opcodes; +import sun.tools.tree.NewArrayExpression; import java.util.*; @@ -85,6 +86,7 @@ public class IntrinsicMethods { declareOverload(myStdLib.getLibraryScope().getFunctions("equals"), 1, EQUALS); declareOverload(myStdLib.getLibraryScope().getFunctions("identityEquals"), 1, EQUALS); declareOverload(myStdLib.getLibraryScope().getFunctions("plus"), 1, new StringPlus()); + declareOverload(myStdLib.getLibraryScope().getFunctions("Array"), 1, new NewArray()); declareIntrinsicFunction("ByteIterator", "next", 0, ITERATOR_NEXT); declareIntrinsicFunction("ShortIterator", "next", 0, ITERATOR_NEXT); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/NewArray.java b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/NewArray.java new file mode 100644 index 00000000000..318dfcfdf7f --- /dev/null +++ b/compiler/backend/src/org/jetbrains/jet/codegen/intrinsics/NewArray.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.JetCallExpression; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.objectweb.asm.Type; +import org.objectweb.asm.commons.InstructionAdapter; + +import java.util.List; + +/** + * @author alex.tkachman + */ +public class NewArray implements IntrinsicMethod { + @Override + public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List arguments, StackValue receiver) { + codegen.generateNewArray((JetCallExpression) element, codegen.getBindingContext().get(BindingContext.EXPRESSION_TYPE, (JetExpression) element)); + return StackValue.onStack(expectedType); + } +} diff --git a/compiler/frontend/src/jet/Library.jet b/compiler/frontend/src/jet/Library.jet index 24a7f4e962f..279171d8776 100644 --- a/compiler/frontend/src/jet/Library.jet +++ b/compiler/frontend/src/jet/Library.jet @@ -105,7 +105,9 @@ trait Iterable { fun iterator() : Iterator } -class Array(val size : Int, init : fun(Int) : T = null ) { +fun Array(val size : Int) : Array + +class Array(val size : Int, init : fun(Int) : T) { fun get(index : Int) : T fun set(index : Int, value : T) : Unit diff --git a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java index 3f7fe8350e5..0f694b7e8e5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetNodeTypes.java @@ -141,7 +141,6 @@ public interface JetNodeTypes { JetNodeType WHEN_CONDITION_IN_RANGE = new JetNodeType("WHEN_CONDITION_IN_RANGE", JetWhenConditionInRange.class); JetNodeType WHEN_CONDITION_IS_PATTERN = new JetNodeType("WHEN_CONDITION_IS_PATTERN", JetWhenConditionIsPattern.class); - JetNodeType WHEN_CONDITION_CALL = new JetNodeType("WHEN_CONDITION_CALL", JetWhenConditionCall.class); JetNodeType NAMESPACE_NAME = new JetNodeType("NAMESPACE_NAME", JetContainerNode.class); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java index bb1624eda0d..f5bc5122eda 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetControlFlowProcessor.java @@ -62,10 +62,6 @@ public class JetControlFlowProcessor { private class CFPVisitor extends JetVisitorVoid { private final boolean inCondition; private final JetVisitorVoid conditionVisitor = new JetVisitorVoid() { - @Override - public void visitWhenConditionCall(JetWhenConditionCall condition) { - value(condition.getCallSuffixExpression(), CFPVisitor.this.inCondition); // TODO : inCondition? - } @Override public void visitWhenConditionInRange(JetWhenConditionInRange condition) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/CallableDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/CallableDescriptor.java index 4e78d2c81f5..752d0da55d3 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/CallableDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/CallableDescriptor.java @@ -21,7 +21,9 @@ public interface CallableDescriptor extends DeclarationDescriptor { @NotNull List getTypeParameters(); - @NotNull + /** + * Method may return null for not yet fully initialized object or if error occurred. + */ JetType getReturnType(); @NotNull diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java index ef3ab5aefa0..490b9f889b1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorImpl.java @@ -120,7 +120,6 @@ public class FunctionDescriptorImpl extends DeclarationDescriptorImpl implements } @Override - @NotNull public JetType getReturnType() { return unsubstitutedReturnType; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java index 69555990589..361eb70fbb4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyDescriptor.java @@ -113,7 +113,6 @@ public class PropertyDescriptor extends VariableDescriptorImpl implements Callab return expectedThisObject; } - @NotNull @Override public JetType getReturnType() { return getOutType(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.java index 4181da25779..095254c7f3d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/PropertyGetterDescriptor.java @@ -34,7 +34,6 @@ public class PropertyGetterDescriptor extends PropertyAccessorDescriptor { return Collections.emptyList(); } - @NotNull @Override public JetType getReturnType() { return returnType; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableDescriptorImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableDescriptorImpl.java index 6daefbce285..9ff1027e6c6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableDescriptorImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/VariableDescriptorImpl.java @@ -84,7 +84,6 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorImpl i return ReceiverDescriptor.NO_RECEIVER; } - @NotNull @Override public JetType getReturnType() { return getOutType(); 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..59941479937 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java @@ -288,7 +288,10 @@ public interface Errors { ParameterizedDiagnosticFactory2 TYPE_MISMATCH_IN_TUPLE_PATTERN = ParameterizedDiagnosticFactory2.create(ERROR, "Type mismatch: subject is of type {0} but the pattern is of type Tuple{1}"); // TODO: message ParameterizedDiagnosticFactory2 TYPE_MISMATCH_IN_BINDING_PATTERN = ParameterizedDiagnosticFactory2.create(ERROR, "{0} must be a supertype of {1}. Use 'is' to match against {0}"); ParameterizedDiagnosticFactory2 INCOMPATIBLE_TYPES = ParameterizedDiagnosticFactory2.create(ERROR, "Incompatible types: {0} and {1}"); - + + ParameterizedDiagnosticFactory1 CANNOT_CHECK_FOR_ERASED = ParameterizedDiagnosticFactory1.create(ERROR, "Cannot check for instance of erased type: {0}"); + ParameterizedDiagnosticFactory2 UNCHECKED_CAST = ParameterizedDiagnosticFactory2.create(WARNING, "Unchecked cast: {0} to {1}"); + ParameterizedDiagnosticFactory3> INCONSISTENT_TYPE_PARAMETER_VALUES = new ParameterizedDiagnosticFactory3>(ERROR, "Type parameter {0} of {1} has inconsistent values: {2}") { @Override protected String makeMessageForA(@NotNull TypeParameterDescriptor typeParameterDescriptor) { @@ -370,7 +373,7 @@ public interface Errors { ParameterizedDiagnosticFactory2 ABSTRACT_MEMBER_NOT_IMPLEMENTED = new ParameterizedDiagnosticFactory2(ERROR, "Class ''{0}'' must be declared abstract or implement abstract member {1}") { @Override protected String makeMessageForA(@NotNull JetClassOrObject jetClassOrObject) { - return jetClassOrObject.getName(); + return JetPsiUtil.safeName(jetClassOrObject.getName()); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java index d5b8b5a8760..aa9843843da 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java @@ -419,7 +419,10 @@ public class JetExpressionParsing extends AbstractJetParsing { } else return false; } - else return false; + else { + return false; + } + return true; } @@ -764,7 +767,6 @@ public class JetExpressionParsing extends AbstractJetParsing { /* * whenCondition * : expression - * : ("." | "?." postfixExpression typeArguments? valueArguments? * : ("in" | "!in") expression * : ("is" | "!is") isRHS * ; @@ -793,21 +795,10 @@ public class JetExpressionParsing extends AbstractJetParsing { parsePattern(); } condition.done(WHEN_CONDITION_IS_PATTERN); - } else if (at(DOT) || at(SAFE_ACCESS)) { - advance(); // DOT or SAFE_ACCESS - PsiBuilder.Marker mark = mark(); - parsePostfixExpression(); - if (parseCallSuffix()) { - mark.done(CALL_EXPRESSION); - } - else { - mark.drop(); - } - condition.done(WHEN_CONDITION_CALL); } else { PsiBuilder.Marker expressionPattern = mark(); if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW)) { - error("Expecting an element, is-condition or in-condition"); + error("Expecting an expression, is-condition or in-condition"); } else { parseExpression(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitor.java index 7b62fcac518..d75649d31e8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitor.java @@ -356,10 +356,6 @@ public class JetVisitor extends PsiElementVisitor { return visitExpression(expression, data); } - public R visitWhenConditionCall(JetWhenConditionCall condition, D data) { - return visitJetElement(condition, data); - } - public R visitWhenConditionIsPattern(JetWhenConditionIsPattern condition, D data) { return visitJetElement(condition, data); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitorVoid.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitorVoid.java index 0f649207239..f3b7fde8385 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitorVoid.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetVisitorVoid.java @@ -354,10 +354,6 @@ public class JetVisitorVoid extends PsiElementVisitor { visitExpression(expression); } - public void visitWhenConditionCall(JetWhenConditionCall condition) { - visitJetElement(condition); - } - public void visitWhenConditionIsPattern(JetWhenConditionIsPattern condition) { visitJetElement(condition); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetWhenConditionCall.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetWhenConditionCall.java deleted file mode 100644 index c74e0ea6acb..00000000000 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetWhenConditionCall.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.jetbrains.jet.lang.psi; - -import com.intellij.lang.ASTNode; -import com.intellij.psi.tree.TokenSet; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.jetbrains.jet.lexer.JetTokens; - -/** - * @author abreslav - */ -public class JetWhenConditionCall extends JetWhenCondition { - public JetWhenConditionCall(@NotNull ASTNode node) { - super(node); - } - - public boolean isSafeCall() { - return getNode().findChildByType(JetTokens.SAFE_ACCESS) != null; - } - - @NotNull - public ASTNode getOperationTokenNode() { - return getNode().findChildByType(TokenSet.create(JetTokens.SAFE_ACCESS, JetTokens.DOT)); - } - - @Nullable @IfNotParsed - public JetExpression getCallSuffixExpression() { - return findChildByClass(JetExpression.class); - } - - @Override - public void accept(@NotNull JetVisitorVoid visitor) { - visitor.visitWhenConditionCall(this); - } - - @Override - public R accept(@NotNull JetVisitor visitor, D data) { - return visitor.visitWhenConditionCall(this, data); - } -} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index f9bedad327d..68effdfba5e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -39,6 +39,8 @@ import static org.jetbrains.jet.lang.types.TypeUtils.NO_EXPECTED_TYPE; * @author abreslav */ public class CallResolver { + private static final JetType DONT_CARE = ErrorUtils.createErrorTypeWithCustomDebugName("DONT_CARE"); + private final JetSemanticServices semanticServices; private final OverloadingConflictResolver overloadingConflictResolver; private final DataFlowInfo dataFlowInfo; @@ -412,7 +414,7 @@ public class CallResolver { constraintSystem.registerTypeVariable(typeParameterDescriptor, Variance.INVARIANT); // TODO } - TypeSubstitutor substituteUnknown = ConstraintSystemImpl.makeConstantSubstitutor(candidate.getTypeParameters(), ErrorUtils.createErrorType("Unknown")); + TypeSubstitutor substituteDontCare = ConstraintSystemImpl.makeConstantSubstitutor(candidate.getTypeParameters(), DONT_CARE); for (Map.Entry entry : candidateCall.getValueArguments().entrySet()) { ResolvedValueArgument valueArgument = entry.getValue(); @@ -428,7 +430,7 @@ public class CallResolver { // We'll type check the arguments later, with the inferred types expected TemporaryBindingTrace traceForUnknown = TemporaryBindingTrace.create(temporaryTrace); ExpressionTypingServices temporaryServices = new ExpressionTypingServices(semanticServices, traceForUnknown); - JetType type = temporaryServices.getType(scope, expression, substituteUnknown.substitute(valueParameterDescriptor.getOutType(), Variance.INVARIANT)); + JetType type = temporaryServices.getType(scope, expression, substituteDontCare.substitute(valueParameterDescriptor.getOutType(), Variance.INVARIANT)); if (type != null) { constraintSystem.addSubtypingConstraint(type, effectiveExpectedType); } @@ -439,10 +441,10 @@ public class CallResolver { } // Error is already reported if something is missing - ReceiverDescriptor receiverParameter = candidateCall.getReceiverArgument(); - ReceiverDescriptor candidateReceiver = candidate.getReceiverParameter(); - if (receiverParameter.exists() && candidateReceiver.exists()) { - constraintSystem.addSubtypingConstraint(receiverParameter.getType(), candidateReceiver.getType()); + ReceiverDescriptor receiverArgument = candidateCall.getReceiverArgument(); + ReceiverDescriptor receiverParameter = candidate.getReceiverParameter(); + if (receiverArgument.exists() && receiverParameter.exists()) { + constraintSystem.addSubtypingConstraint(receiverArgument.getType(), receiverParameter.getType()); } if (expectedType != NO_EXPECTED_TYPE) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java index 5cfbbc1301f..1c77b65f443 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -171,11 +171,20 @@ public class ErrorUtils { } private static JetType createErrorType(String debugMessage, JetScope memberScope) { - return new ErrorTypeImpl(new TypeConstructorImpl(ERROR_CLASS, Collections.emptyList(), false, "[ERROR : " + debugMessage + "]", Collections.emptyList(), Collections.singleton(JetStandardClasses.getAnyType())), memberScope); + return createErrorTypeWithCustomDebugName(memberScope, "[ERROR : " + debugMessage + "]"); + } + + @NotNull + public static JetType createErrorTypeWithCustomDebugName(String debugName) { + return createErrorTypeWithCustomDebugName(ERROR_SCOPE, debugName); + } + + private static JetType createErrorTypeWithCustomDebugName(JetScope memberScope, String debugName) { + return new ErrorTypeImpl(new TypeConstructorImpl(ERROR_CLASS, Collections.emptyList(), false, debugName, Collections.emptyList(), Collections.singleton(JetStandardClasses.getAnyType())), memberScope); } public static JetType createWrongVarianceErrorType(TypeProjection value) { - return createErrorType(value + " is not allowed here]", value.getType().getMemberScope()); + return createErrorType(value + " is not allowed here", value.getType().getMemberScope()); } public static ClassifierDescriptor getErrorClass() { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java index 62923713125..c095764a3ab 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java @@ -284,7 +284,7 @@ public class JetStandardLibrary { } @NotNull - public ClassDescriptor getArray() { + public ClassDescriptor getArray() { initStdClasses(); return arrayClass; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java index 6304adf84db..82e4416c056 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -110,54 +110,65 @@ public class TypeUtils { } @Nullable - public static JetType intersect(JetTypeChecker typeChecker, Set types) { + public static JetType intersect(@NotNull JetTypeChecker typeChecker, @NotNull Set types) { assert !types.isEmpty(); if (types.size() == 1) { return types.iterator().next(); } - StringBuilder debugName = new StringBuilder(); - boolean nullable = false; - Set resultingTypes = Sets.newHashSet(); + // Intersection of T1..Tn is an intersection of their non-null versions, + // made nullable is they all were nullable + boolean allNullable = true; + boolean nothingTypePresent = false; + List nullabilityStripped = Lists.newArrayList(); + for (JetType type : types) { + nothingTypePresent |= JetStandardClasses.isNothingOrNullableNothing(type); + allNullable &= type.isNullable(); + nullabilityStripped.add(makeNotNullable(type)); + } + + if (nothingTypePresent) { + return allNullable ? JetStandardClasses.getNullableNothingType() : JetStandardClasses.getNothingType(); + } + // Now we remove types that have subtypes in the list + List resultingTypes = Lists.newArrayList(); outer: - for (Iterator iterator = types.iterator(); iterator.hasNext();) { - JetType type = iterator.next(); - + for (JetType type : nullabilityStripped) { if (!canHaveSubtypes(typeChecker, type)) { - for (JetType other : types) { + for (JetType other : nullabilityStripped) { // It makes sense to check for subtyping of other <: type, despite that // type is not supposed to be open, for there're enums if (!type.equals(other) && !typeChecker.isSubtypeOf(type, other) && !typeChecker.isSubtypeOf(other, type)) { return null; } } - return type; + return makeNullableAsSpecified(type, allNullable); } else { - for (JetType other : types) { + for (JetType other : nullabilityStripped) { if (!type.equals(other) && typeChecker.isSubtypeOf(other, type)) { continue outer; } + } } - nullable |= type.isNullable(); - resultingTypes.add(type); - debugName.append(type.toString()); - if (iterator.hasNext()) { - debugName.append(" & "); - } } + + if (resultingTypes.size() == 1) { + return makeNullableAsSpecified(resultingTypes.get(0), allNullable); + } + List noAnnotations = Collections.emptyList(); TypeConstructor constructor = new TypeConstructorImpl( null, noAnnotations, false, - debugName.toString(), + makeDebugNameForIntersectionType(resultingTypes).toString(), Collections.emptyList(), resultingTypes); @@ -171,11 +182,25 @@ public class TypeUtils { return new JetTypeImpl( noAnnotations, constructor, - nullable, + allNullable, Collections.emptyList(), new ChainedScope(null, scopes)); // TODO : check intersectibility, don't use a chanied scope } + private static StringBuilder makeDebugNameForIntersectionType(Iterable resultingTypes) { + StringBuilder debugName = new StringBuilder("{"); + for (Iterator iterator = resultingTypes.iterator(); iterator.hasNext(); ) { + JetType type = iterator.next(); + + debugName.append(type.toString()); + if (iterator.hasNext()) { + debugName.append(" & "); + } + } + debugName.append("}"); + return debugName; + } + public static boolean canHaveSubtypes(JetTypeChecker typeChecker, JetType type) { if (type.isNullable()) { return true; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 0446105d479..720155d0206 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -1,6 +1,7 @@ package org.jetbrains.jet.lang.types.expressions; import com.google.common.collect.Lists; +import com.google.common.collect.Multimap; import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.tree.IElementType; @@ -8,6 +9,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.*; import org.jetbrains.jet.lang.resolve.calls.CallMaker; @@ -245,10 +247,63 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { else { if (typeChecker.isSubtypeOf(actualType, targetType)) { context.trace.report(USELESS_CAST.on(expression, expression.getOperationSign())); + } else { + if (isCastErased(actualType, targetType)) { + context.trace.report(Errors.UNCHECKED_CAST.on(expression, actualType, targetType)); + } } } } + /** + * Check if assignment from ActualType to TargetType is erased. + * It is an error in "is" statement and warning in "as". + */ + public static boolean isCastErased(JetType actualType, JetType targetType) { + + if (!(targetType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) { + // TODO: what if it is TypeParameterDescriptor? + return false; + } + + JetType targetTypeClerared = TypeUtils.makeUnsubstitutedType( + (ClassDescriptor) targetType.getConstructor().getDeclarationDescriptor(), null); + + Multimap clearTypeSubstitutionMap = + TypeUtils.buildDeepSubstitutionMultimap(targetTypeClerared); + + Set clearSubstituted = new HashSet(); + + for (int i = 0; i < actualType.getConstructor().getParameters().size(); ++i) { + TypeParameterDescriptor subjectTypeParameterDescriptor = actualType.getConstructor().getParameters().get(i); + + Collection subst = clearTypeSubstitutionMap.get(subjectTypeParameterDescriptor.getTypeConstructor()); + for (TypeProjection proj : subst) { + clearSubstituted.add(proj.getType()); + } + } + + for (int i = 0; i < targetType.getConstructor().getParameters().size(); ++i) { + TypeParameterDescriptor typeParameter = targetType.getConstructor().getParameters().get(i); + TypeProjection typeProjection = targetType.getArguments().get(i); + + if (typeParameter.isReified()) { + continue; + } + + // "is List<*>" + if (typeProjection.equals(TypeUtils.makeStarProjection(typeParameter))) { + continue; + } + + // if parameter is mapped to nothing then it is erased + if (!clearSubstituted.contains(typeParameter.getDefaultType())) { + return true; + } + } + return false; + } + @Override public JetType visitTupleExpression(JetTupleExpression expression, ExpressionTypingContext context) { List entries = expression.getEntries(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.java index 943343f4d70..f5c277970bb 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/PatternMatchingTypingVisitor.java @@ -6,6 +6,7 @@ import com.intellij.openapi.util.Ref; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.VariableDescriptor; +import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowValue; @@ -17,8 +18,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver; import org.jetbrains.jet.lang.types.*; -import java.util.List; -import java.util.Set; +import java.util.*; import static org.jetbrains.jet.lang.diagnostics.Errors.*; import static org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils.ensureBooleanResultWithCustomSubject; @@ -113,19 +113,6 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { final DataFlowInfo[] newDataFlowInfo = new DataFlowInfo[]{context.dataFlowInfo}; condition.accept(new JetVisitorVoid() { - @Override - public void visitWhenConditionCall(JetWhenConditionCall condition) { - JetExpression callSuffixExpression = condition.getCallSuffixExpression(); -// JetScope compositeScope = new ScopeWithReceiver(context.scope, subjectType, semanticServices.getTypeChecker()); - if (callSuffixExpression != null) { -// JetType selectorReturnType = getType(compositeScope, callSuffixExpression, false, context); - assert subjectExpression != null; - JetType selectorReturnType = facade.getSelectorReturnType(new ExpressionReceiver(subjectExpression, subjectType), condition.getOperationTokenNode(), callSuffixExpression, context);//getType(compositeScope, callSuffixExpression, false, context); - ensureBooleanResultWithCustomSubject(callSuffixExpression, selectorReturnType, "This expression", context); -// context.getServices().checkNullSafety(subjectType, condition.getOperationTokenNode(), getCalleeFunctionDescriptor(callSuffixExpression, context), condition); - } - } - @Override public void visitWhenConditionInRange(JetWhenConditionInRange condition) { JetExpression rangeExpression = condition.getRangeExpression(); @@ -245,6 +232,9 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { } } + /* + * (a: SubjectType) is Type + */ private void checkTypeCompatibility(@Nullable JetType type, @NotNull JetType subjectType, @NotNull JetElement reportErrorOn) { // TODO : Take auto casts into account? if (type == null) { @@ -253,6 +243,11 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor { if (TypeUtils.intersect(context.semanticServices.getTypeChecker(), Sets.newHashSet(type, subjectType)) == null) { // context.trace.getErrorHandler().genericError(reportErrorOn.getNode(), "Incompatible types: " + type + " and " + subjectType); context.trace.report(INCOMPATIBLE_TYPES.on(reportErrorOn, type, subjectType)); + return; + } + + if (BasicExpressionTypingVisitor.isCastErased(subjectType, type)) { + context.trace.report(Errors.CANNOT_CHECK_FOR_ERASED.on(reportErrorOn, type)); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java index e693c3dddf1..c5aff27be5c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/inference/ConstraintSystemImpl.java @@ -9,6 +9,7 @@ import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.types.*; import java.util.Collection; +import java.util.Collections; import java.util.Map; import java.util.Set; @@ -46,8 +47,19 @@ public class ConstraintSystemImpl implements ConstraintSystem { } public static abstract class TypeValue { - private final Set upperBounds = Sets.newHashSet(); - private final Set lowerBounds = Sets.newHashSet(); + private final Set mutableUpperBounds = Sets.newHashSet(); + private final Set upperBounds = Collections.unmodifiableSet(mutableUpperBounds); + + private final Set mutableLowerBounds = Sets.newHashSet(); + private final Set lowerBounds = Collections.unmodifiableSet(mutableLowerBounds); + + public void addUpperBound(@NotNull TypeValue bound) { + mutableUpperBounds.add(bound); + } + + public void addLowerBound(@NotNull TypeValue bound) { + mutableLowerBounds.add(bound); + } @NotNull public Set getUpperBounds() { @@ -86,8 +98,8 @@ public class ConstraintSystemImpl implements ConstraintSystem { throw new LoopInTypeVariableConstraintsException(); } if (value == null) { - JetTypeChecker typeChecker = JetTypeChecker.INSTANCE; beingComputed = true; + JetTypeChecker typeChecker = JetTypeChecker.INSTANCE; try { if (positionVariance == Variance.IN_VARIANCE) { // maximal solution @@ -320,8 +332,8 @@ public class ConstraintSystemImpl implements ConstraintSystem { private void addSubtypingConstraintOnTypeValues(TypeValue typeValueForLower, TypeValue typeValueForUpper) { println(typeValueForLower + " :< " + typeValueForUpper); if (typeValueForLower != typeValueForUpper) { - typeValueForLower.getUpperBounds().add(typeValueForUpper); - typeValueForUpper.getLowerBounds().add(typeValueForLower); + typeValueForLower.addUpperBound(typeValueForUpper); + typeValueForUpper.addLowerBound(typeValueForLower); } } @@ -358,13 +370,20 @@ public class ConstraintSystemImpl implements ConstraintSystem { // effective bounds for each node Set visited = Sets.newHashSet(); - for (KnownType knownType : knownTypes.values()) { - transitiveClosure(knownType, visited); - } for (UnknownType unknownType : unknownTypes.values()) { transitiveClosure(unknownType, visited); } + for (UnknownType unknownType : unknownTypes.values()) { + println("Constraints for " + unknownType.getTypeParameterDescriptor()); + printTypeValue(unknownType); + } + + for (KnownType knownType : knownTypes.values()) { + println("Constraints for " + knownType.getType()); + printTypeValue(knownType); + } + // Find inconsistencies Solution solution = new Solution(); @@ -382,6 +401,15 @@ public class ConstraintSystemImpl implements ConstraintSystem { return solution; } + private void printTypeValue(TypeValue typeValue) { + for (TypeValue bound : typeValue.getUpperBounds()) { + println(" :< " + bound); + } + for (TypeValue bound : typeValue.getLowerBounds()) { + println(" :> " + bound); + } + } + private void check(TypeValue typeValue, Solution solution) { try { KnownType resultingValue = typeValue.getValue(); @@ -416,7 +444,7 @@ public class ConstraintSystemImpl implements ConstraintSystem { } } solution.registerError("[TODO] Loop in constraints"); - e.printStackTrace(); +// e.printStackTrace(); } } @@ -426,6 +454,9 @@ public class ConstraintSystemImpl implements ConstraintSystem { } for (TypeValue upperBound : Sets.newHashSet(current.getUpperBounds())) { + if (upperBound instanceof KnownType) { + continue; + } transitiveClosure(upperBound, visited); Set upperBounds = upperBound.getUpperBounds(); for (TypeValue transitiveBound : upperBounds) { diff --git a/compiler/frontend/src/org/jetbrains/jet/resolve/DescriptorRenderer.java b/compiler/frontend/src/org/jetbrains/jet/resolve/DescriptorRenderer.java index a378e31d39b..991c3ced6a9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/resolve/DescriptorRenderer.java +++ b/compiler/frontend/src/org/jetbrains/jet/resolve/DescriptorRenderer.java @@ -73,7 +73,11 @@ public class DescriptorRenderer implements Renderer { } public String renderType(JetType type) { - return escape(type.toString()); + if (type == null) { + return escape("[NULL]"); + } else { + return escape(type.toString()); + } } protected String escape(String s) { @@ -222,7 +226,6 @@ public class DescriptorRenderer implements Renderer { renderName(descriptor, builder); renderValueParameters(descriptor, builder); - // TODO: getReturnType may be uninitialized and throw IllegalStateException // stepan.koltsov@ 2011-11-21 builder.append(" : ").append(escape(renderType(descriptor.getReturnType()))); return super.visitFunctionDescriptor(descriptor, builder); } 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/quick/UnusedVariables.jet b/compiler/testData/checkerWithErrorTypes/quick/UnusedVariables.jet index c52c8e8e61d..63fbca9007e 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/UnusedVariables.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/UnusedVariables.jet @@ -50,7 +50,7 @@ class MyTest() { i = 456; } - fun testWhile(a : Any?, b : Any?) { + fun testWhile() { var a : Any? = true var b : Any? = 34 while (a is Any) { @@ -139,4 +139,4 @@ fun testBackingFieldsNotMarked() { } } -fun doSmth(i : Int) {} \ No newline at end of file +fun doSmth(i : Int) {} 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 73% rename from compiler/testData/checkerWithErrorTypes/full/When.jet rename to compiler/testData/checkerWithErrorTypes/quick/When.jet index 7f53fb38c9d..bff65aac380 100644 --- a/compiler/testData/checkerWithErrorTypes/full/When.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/When.jet @@ -13,16 +13,19 @@ fun foo() : Int { 1 + a => 1 in 1..a => 1 !in 1..a => 1 - .a => 1 - .equals(1).a => 1 - ?.equals(1) => 1 + // Commented for KT-621 .a => 1 + // Commented for KT-621 .equals(1).a => 1 + // Commented for KT-621 ?.equals(1) => 1 else => 1 } - return when (x?:null) { - .foo() => 1 - .equals(1) => 1 - ?.equals(1).equals(2) => 1 - } + + // Commented for KT-621 + // return when (x?:null) { + // .foo() => 1 + // .equals(1) => 1 + // ?.equals(1).equals(2) => 1 + // } + return 0 } val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo() diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedError.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedError.jet new file mode 100644 index 00000000000..2b6a8a020d3 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedError.jet @@ -0,0 +1,6 @@ +// +JDK + +import java.util.List; +import java.util.Collection; + +fun ff(c: Collection) = c as List diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedFine.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedFine.jet new file mode 100644 index 00000000000..b4c50dc6b11 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedFine.jet @@ -0,0 +1,6 @@ +// +JDK + +import java.util.List; +import java.util.Collection; + +fun ff(c: Collection) = c as List diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedStar.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedStar.jet new file mode 100644 index 00000000000..4217aae11df --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedStar.jet @@ -0,0 +1,6 @@ +// +JDK + +import java.util.List; + +fun ff(l: Any) = l as List<*> + diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedWarning.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedWarning.jet new file mode 100644 index 00000000000..eff6dff6487 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/AsErasedWarning.jet @@ -0,0 +1,5 @@ +// +JDK + +import java.util.List; + +fun ff(a: Any) = a as List diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllow.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllow.jet new file mode 100644 index 00000000000..ca46b082bc1 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllow.jet @@ -0,0 +1,7 @@ +// +JDK + +import java.util.Collection; +import java.util.List; + +fun ff(l: Collection) = l is List + diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllowParameterSubtype.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllowParameterSubtype.jet new file mode 100644 index 00000000000..a4d9a515e30 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedAllowParameterSubtype.jet @@ -0,0 +1,11 @@ +// +JDK + +import java.util.Collection; +import java.util.List; + +open class A + +class B : A + +fun ff(l: Collection) = l is List + diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedDisallowFromAny.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedDisallowFromAny.jet new file mode 100644 index 00000000000..76e1b3e530e --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedDisallowFromAny.jet @@ -0,0 +1,5 @@ +// +JDK + +import java.util.List; + +fun ff(l: Any) = l is List diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedStar.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedStar.jet new file mode 100644 index 00000000000..232d2a2f1c9 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsErasedStar.jet @@ -0,0 +1,5 @@ +// +JDK + +import java.util.List; + +fun ff(l: Any) = l is List<*> diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/IsReified.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsReified.jet new file mode 100644 index 00000000000..247196d6e84 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsReified.jet @@ -0,0 +1,3 @@ +class MyList + +fun ff(a: Any) = a is MyList diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/IsTraits.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/IsTraits.jet new file mode 100644 index 00000000000..99656c2ab24 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/IsTraits.jet @@ -0,0 +1,4 @@ +trait Aaa +trait Bbb + +fun f(a: Aaa) = a is Bbb diff --git a/compiler/testData/checkerWithErrorTypes/quick/cast/WhenErasedDisallowFromAny.jet b/compiler/testData/checkerWithErrorTypes/quick/cast/WhenErasedDisallowFromAny.jet new file mode 100644 index 00000000000..af0653dd699 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/cast/WhenErasedDisallowFromAny.jet @@ -0,0 +1,8 @@ +// +JDK + +import java.util.List; + +fun ff(l: Any) = when(l) { + is List => 1 + else 2 +} 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/regression/AmbiguityOnLazyTypeComputation.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/AmbiguityOnLazyTypeComputation.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/AmbiguityOnLazyTypeComputation.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/AmbiguityOnLazyTypeComputation.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/AssignmentsUnderOperators.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/AssignmentsUnderOperators.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/AssignmentsUnderOperators.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/AssignmentsUnderOperators.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/CoercionToUnit.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/CoercionToUnit.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/CoercionToUnit.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/CoercionToUnit.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/DoubleDefine.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/DoubleDefine.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/regression/DoubleDefine.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/DoubleDefine.jet index 996c4608778..74da10dc846 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/DoubleDefine.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/ErrorsOnIbjectExpressionsAsParameters.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/ErrorsOnIbjectExpressionsAsParameters.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/ErrorsOnIbjectExpressionsAsParameters.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet11.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet11.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet11.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet11.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet121.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet121.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet121.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet121.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet124.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet124.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet124.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet124.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet169.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet169.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet169.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet169.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet17.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet17.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet17.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet17.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet183-1.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet183-1.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet183-1.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet183-1.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet183.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet183.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet183.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet183.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet53.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet53.jet new file mode 100644 index 00000000000..a138884afc2 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/Jet67.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet67.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet67.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet68.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet68.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet68.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet68.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet69.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet69.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet69.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet69.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/Jet72.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/Jet72.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet72.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet72.jet index d3d3272c8e3..5ca74129847 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/Jet72.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/Jet81.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/Jet81.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/Jet81.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/OverrideResolution.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/OverrideResolution.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/OverrideResolution.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/OverrideResolution.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/ScopeForSecondaryConstructors.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/ScopeForSecondaryConstructors.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/ScopeForSecondaryConstructors.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/ScopeForSecondaryConstructors.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/SpecififcityByReceiver.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/SpecififcityByReceiver.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/SpecififcityByReceiver.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/SpecififcityByReceiver.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/ThisConstructorInGenericClass.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/ThisConstructorInGenericClass.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/ThisConstructorInGenericClass.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/ThisConstructorInGenericClass.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/WrongTraceInCallResolver.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/WrongTraceInCallResolver.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/WrongTraceInCallResolver.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/WrongTraceInCallResolver.jet diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt127.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt127.jet index 7bcb076f08c..19ad92b2d52 100644 --- a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt127.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt127.jet @@ -8,8 +8,11 @@ fun Any?.equals1(other : Any?) : Boolean = true fun main(args: Array) { val command : Foo? = null - when (command) { - .equals(null) => 1; // must be resolved - ?.equals(null) => 1 // same here - } + + // Commented for KT-621 + // when (command) { + // .equals(null) => 1; // must be resolved + // ?.equals(null) => 1 // same here + // } + command.equals(null) } 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/testData/checkerWithErrorTypes/full/regression/kt251.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt251.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt251.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt251.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt258.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt258.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt258.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt258.jet index 257dfb12378..00b7e9696d4 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt258.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/kt287.jet similarity index 96% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt287.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt287.jet index b0efe2e6460..69d2d526fb0 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt287.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/kt303.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt303.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt303.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt313.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt313.jet similarity index 97% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt313.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt313.jet index d22f0dc4f2e..7a112bcb106 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt313.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/kt335.336.jet similarity index 98% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt335.336.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt335.336.jet index 46537f0041c..e874d8f005d 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt335.336.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/kt385.109.441.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt385.109.441.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt385.109.441.jet index 8af621372fd..9dcac990807 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt385.109.441.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/kt402.jet similarity index 100% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt402.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt402.jet diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt459.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt459.jet similarity index 92% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt459.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt459.jet index e2dd54ef0da..faa62212f38 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt459.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/regressions/kt469.jet similarity index 98% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt469.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt469.jet index 3d01d2efee9..a9ff4c1d291 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt469.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt469.jet @@ -1,3 +1,5 @@ +// +JDK + namespace kt469 //KT-512 plusAssign() : Unit does not work properly diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt549.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt549.jet new file mode 100644 index 00000000000..5fc17be122b --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt549.jet @@ -0,0 +1,18 @@ +//KT-549 type inference failed +// +JDK + +namespace demo + + fun filter(list : Array, filter : fun (T) : Boolean) : java.util.List { + val answer = java.util.ArrayList(); + for (l in list) { + if (filter(l)) answer.add(l) + } + return answer; + } + +fun main(args : Array) { + for (a in filter(args, {it.length > 1})) { + System.out?.println("Hello, ${a}!") + } +} diff --git a/compiler/testData/checkerWithErrorTypes/quick/regressions/kt571.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt571.jet new file mode 100644 index 00000000000..2333eb78644 --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt571.jet @@ -0,0 +1,3 @@ +//KT-571 Type inference failed +fun let(t : T, body : fun(T) : R) = body(t) +private fun double(d : Int) : Int = let(d * 2) {it / 10 + it * 2 % 10} diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt58.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt58.jet similarity index 99% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt58.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt58.jet index 7ebe0ee8feb..57562a61f37 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt58.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/quick/regressions/kt580.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt580.jet new file mode 100644 index 00000000000..a3689acc91d --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt580.jet @@ -0,0 +1,22 @@ +//KT-580 Type inference failed +// +JDK + +namespace whats.the.difference + +import java.util.* + +fun iarray(vararg a : String) = a // BUG + +fun main(vals : IntArray) { + val vals = iarray("789", "678", "567") + val diffs = ArrayList + for (i in vals.indices) { + for (j in i..vals.lastIndex()) // Type inference failed + diffs.add(vals[i].length - vals[j].length) + for (j in i..vals.lastIndex) // Type inference failed + diffs.add(vals[i].length - vals[j].length) + } +} + +fun Array.lastIndex() = size - 1 +val Array.lastIndex : Int get() = size - 1 diff --git a/compiler/testData/checkerWithErrorTypes/full/regression/kt588.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt588.jet similarity index 95% rename from compiler/testData/checkerWithErrorTypes/full/regression/kt588.jet rename to compiler/testData/checkerWithErrorTypes/quick/regressions/kt588.jet index 2b4b4d86ff4..410c70c3479 100644 --- a/compiler/testData/checkerWithErrorTypes/full/regression/kt588.jet +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/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/kt600.jet b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt600.jet new file mode 100644 index 00000000000..6cebda6137c --- /dev/null +++ b/compiler/testData/checkerWithErrorTypes/quick/regressions/kt600.jet @@ -0,0 +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 +} diff --git a/compiler/testData/codegen/patternMatching/callProperty.jet b/compiler/testData/codegen/patternMatching/callProperty.jet index b52ac44de96..65fc9b7997d 100644 --- a/compiler/testData/codegen/patternMatching/callProperty.jet +++ b/compiler/testData/codegen/patternMatching/callProperty.jet @@ -2,8 +2,11 @@ class C(val p: Boolean) { } fun box(): String { val c = C(true) - return when(c) { - .p => "OK" - else => "fail" - } + + // Commented for KT-621 + // return when(c) { + // .p => "OK" + // else => "fail" + // } + return if (c.p) "OK" else "fail" } diff --git a/compiler/testData/codegen/patternMatching/is.jet b/compiler/testData/codegen/patternMatching/is.jet index a5b5f33195f..9fac50c586b 100644 --- a/compiler/testData/codegen/patternMatching/is.jet +++ b/compiler/testData/codegen/patternMatching/is.jet @@ -1,6 +1,6 @@ fun typeName(a: Any?) : String { return when(a) { - is java.util.ArrayList => "array list" + is java.util.ArrayList<*> => "array list" else => "no idea" } } @@ -8,4 +8,4 @@ fun typeName(a: Any?) : String { fun box() : String { if(typeName(java.util.ArrayList ()) != "array list") return "array list failed" return "OK" -} \ No newline at end of file +} diff --git a/compiler/testData/codegen/regressions/kt247.jet b/compiler/testData/codegen/regressions/kt247.jet index 49637518d25..af13811dee9 100644 --- a/compiler/testData/codegen/regressions/kt247.jet +++ b/compiler/testData/codegen/regressions/kt247.jet @@ -19,7 +19,7 @@ fun t3() { fun t4() { val e: E? = E() - System.out?.println(e?.foo() == e) //verify error + System.out?.println(e?.bar() == e) //verify error System.out?.println(e?.foo()) //verify error } @@ -35,4 +35,5 @@ class C(val x: Int) class D(val s: String) class E() { fun foo() = 1 + fun bar() = this } diff --git a/compiler/testData/codegen/regressions/kt528.kt b/compiler/testData/codegen/regressions/kt528.kt index 456f55d04be..8cfe1707aee 100644 --- a/compiler/testData/codegen/regressions/kt528.kt +++ b/compiler/testData/codegen/regressions/kt528.kt @@ -25,14 +25,25 @@ class Luhny() { fun charIn(it : Char) { buffer.addLast(it) - when (it) { - .isDigit() => digits.addLast(it.int - '0'.int) - ' ', '-' => {} - else => { - printAll() - digits.clear() - } + + // Commented for KT-621 + // when (it) { + // .isDigit() => digits.addLast(it.int - '0'.int) + // ' ', '-' => {} + // else => { + // printAll() + // digits.clear() + // } + // } + + if (it.isDigit()) { + digits.addLast(it.int - '0'.int) + } else if (it == ' ' || it == '-') { + } else { + printAll() + digits.clear() } + if (digits.size() > 16) printOneDigit() check() diff --git a/compiler/testData/codegen/regressions/kt529.kt b/compiler/testData/codegen/regressions/kt529.kt index 66487f37509..84a6d3edc52 100644 --- a/compiler/testData/codegen/regressions/kt529.kt +++ b/compiler/testData/codegen/regressions/kt529.kt @@ -23,11 +23,21 @@ class Luhny() { fun process(it : Char) { buffer.addLast(it) - when (it) { - .isDigit() => digits.addLast(it.int - '0'.int) - ' ', '-' => {} - else => printAll() + + // Commented for KT-621 + // when (it) { + // .isDigit() => digits.addLast(it.int - '0'.int) + // ' ', '-' => {} + // else => printAll() + // } + + if (it.isDigit()) { + digits.addLast(it.int - '0'.int) + } else if (it == ' ' || it == '-') { + } else { + printAll() } + if (digits.size() > 16) printOneDigit() check() diff --git a/compiler/testData/codegen/regressions/kt533.kt b/compiler/testData/codegen/regressions/kt533.kt index 05e55878b81..7e7ef961ffd 100644 --- a/compiler/testData/codegen/regressions/kt533.kt +++ b/compiler/testData/codegen/regressions/kt533.kt @@ -24,14 +24,25 @@ class Luhny() { fun charIn(it : Char) { buffer.push(it) - when (it) { - .isDigit() => digits.push(it.int - '0'.int) - ' ', '-' => {} - else => { - printAll() - digits.clear() - } + + // Commented for KT-621 + // when (it) { + // .isDigit() => digits.push(it.int - '0'.int) + // ' ', '-' => {} + // else => { + // printAll() + // digits.clear() + // } + // } + + if (it.isDigit()) { + digits.push(it.int - '0'.int) + } else if (it == ' ' || it == '-') { + } else { + printAll() + digits.clear() } + if (digits.size() > 16) printOneDigit() check() diff --git a/compiler/testData/codegen/regressions/kt602.jet b/compiler/testData/codegen/regressions/kt602.jet new file mode 100644 index 00000000000..aae930a7328 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt602.jet @@ -0,0 +1 @@ +fun box() = if(Array(10) is Array) "OK" else "fail" diff --git a/compiler/testData/codegen/regressions/kt613.jet b/compiler/testData/codegen/regressions/kt613.jet new file mode 100644 index 00000000000..463b77aa909 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt613.jet @@ -0,0 +1,15 @@ +namespace name + +class Test() { + var i = 5 + val ten = 10.lng + + fun Long.t() = this.int + i++ + ++i + + fun tt() = ten.t() +} + +fun box() : String { + var m = Test() + return if((m.i)++ == 5 && ++(m.i) == 7 && m.tt() == 26) "OK" else "fail" +} \ No newline at end of file diff --git a/compiler/testData/psi/CallsInWhen.jet b/compiler/testData/psi/CallsInWhen.jet index ad63479bd65..2675ba89523 100644 --- a/compiler/testData/psi/CallsInWhen.jet +++ b/compiler/testData/psi/CallsInWhen.jet @@ -1,13 +1,13 @@ fun foo() { when (a) { - .foo => a - .foo() => a - .foo => a - .foo(a) => a - .foo(a, d) => a - .{bar} => a - .{!bar} => a - .{() => !bar} => a + a.foo => a + a.foo() => a + a.foo => a + a.foo(a) => a + a.foo(a, d) => a + a.{bar} => a + a.{!bar} => a + a.{() => !bar} => a else => a } } diff --git a/compiler/testData/psi/CallsInWhen.txt b/compiler/testData/psi/CallsInWhen.txt index dff80072a3d..c3992ac542b 100644 --- a/compiler/testData/psi/CallsInWhen.txt +++ b/compiler/testData/psi/CallsInWhen.txt @@ -22,10 +22,14 @@ JetFile: CallsInWhen.jet PsiElement(LBRACE)('{') PsiWhiteSpace('\n ') WHEN_ENTRY - WHEN_CONDITION_CALL - PsiElement(DOT)('.') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') PsiElement(DOUBLE_ARROW)('=>') PsiWhiteSpace(' ') @@ -33,14 +37,18 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace('\n ') WHEN_ENTRY - WHEN_CONDITION_CALL - PsiElement(DOT)('.') - CALL_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(DOUBLE_ARROW)('=>') PsiWhiteSpace(' ') @@ -48,19 +56,53 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace('\n ') WHEN_ENTRY - WHEN_CONDITION_CALL - PsiElement(DOT)('.') - CALL_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace('\n ') + WHEN_ENTRY + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(DOUBLE_ARROW)('=>') PsiWhiteSpace(' ') @@ -68,56 +110,34 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace('\n ') WHEN_ENTRY - WHEN_CONDITION_CALL - PsiElement(DOT)('.') - CALL_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(GT)('>') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - VALUE_ARGUMENT - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace('\n ') - WHEN_ENTRY - WHEN_CONDITION_CALL - PsiElement(DOT)('.') - CALL_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - TYPE_ARGUMENT_LIST - PsiElement(LT)('<') - TYPE_PROJECTION - TYPE_REFERENCE - USER_TYPE + PsiElement(IDENTIFIER)('a') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + VALUE_ARGUMENT REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(GT)('>') - VALUE_ARGUMENT_LIST - PsiElement(LPAR)('(') - VALUE_ARGUMENT - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - VALUE_ARGUMENT - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('d') - PsiElement(RPAR)(')') + PsiElement(IDENTIFIER)('d') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') PsiElement(DOUBLE_ARROW)('=>') PsiWhiteSpace(' ') @@ -125,15 +145,19 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace('\n ') WHEN_ENTRY - WHEN_CONDITION_CALL - PsiElement(DOT)('.') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(RBRACE)('}') + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(RBRACE)('}') PsiWhiteSpace(' ') PsiElement(DOUBLE_ARROW)('=>') PsiWhiteSpace(' ') @@ -141,18 +165,22 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace('\n ') WHEN_ENTRY - WHEN_CONDITION_CALL - PsiElement(DOT)('.') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - BLOCK - PREFIX_EXPRESSION - OPERATION_REFERENCE - PsiElement(EXCL)('!') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(RBRACE)('}') + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + PREFIX_EXPRESSION + OPERATION_REFERENCE + PsiElement(EXCL)('!') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(RBRACE)('}') PsiWhiteSpace(' ') PsiElement(DOUBLE_ARROW)('=>') PsiWhiteSpace(' ') @@ -160,24 +188,28 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace('\n ') WHEN_ENTRY - WHEN_CONDITION_CALL - PsiElement(DOT)('.') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') - PsiWhiteSpace(' ') - BLOCK - PREFIX_EXPRESSION - OPERATION_REFERENCE - PsiElement(EXCL)('!') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('bar') - PsiElement(RBRACE)('}') + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(DOT)('.') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(DOUBLE_ARROW)('=>') + PsiWhiteSpace(' ') + BLOCK + PREFIX_EXPRESSION + OPERATION_REFERENCE + PsiElement(EXCL)('!') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('bar') + PsiElement(RBRACE)('}') PsiWhiteSpace(' ') PsiElement(DOUBLE_ARROW)('=>') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/When_ERR.txt b/compiler/testData/psi/When_ERR.txt index dba08d47c7f..64b931828e9 100644 --- a/compiler/testData/psi/When_ERR.txt +++ b/compiler/testData/psi/When_ERR.txt @@ -82,7 +82,7 @@ JetFile: When_ERR.jet WHEN_ENTRY WHEN_CONDITION_IS_PATTERN EXPRESSION_PATTERN - PsiErrorElement:Expecting an element, is-condition or in-condition + PsiErrorElement:Expecting an expression, is-condition or in-condition PsiElement(DOUBLE_ARROW)('=>') PsiWhiteSpace(' ') @@ -164,7 +164,7 @@ JetFile: When_ERR.jet WHEN_ENTRY WHEN_CONDITION_IS_PATTERN EXPRESSION_PATTERN - PsiErrorElement:Expecting an element, is-condition or in-condition + PsiErrorElement:Expecting an expression, is-condition or in-condition PsiElement(DOUBLE_ARROW)('=>') PsiErrorElement:Expecting an element 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); - } - }); - } -} diff --git a/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java index 80063a36516..f5e8faf941a 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ArrayGenTest.java @@ -9,7 +9,7 @@ public class ArrayGenTest extends CodegenTestCase { public void testKt326 () throws Exception { blackBoxFile("regressions/kt326.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testCreateMultiInt () throws Exception { @@ -39,7 +39,7 @@ public class ArrayGenTest extends CodegenTestCase { public void testCreateMultiGenerics () throws Exception { loadText("class L() { val a = Array(5) } fun foo() = L.a"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); Object invoke = foo.invoke(null); System.out.println(invoke.getClass()); @@ -48,7 +48,7 @@ public class ArrayGenTest extends CodegenTestCase { public void testIntGenerics () throws Exception { loadText("class L(var a : T) {} fun foo() = L(5).a"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); Object invoke = foo.invoke(null); System.out.println(invoke.getClass()); @@ -57,147 +57,147 @@ public class ArrayGenTest extends CodegenTestCase { public void testIterator () throws Exception { loadText("fun box() { val x = Array(5, { it } ).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIterator () throws Exception { loadText("fun box() { val x = ByteArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.nextByte()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIteratorByte () throws Exception { loadText("fun box() { for(x in ByteArray(5)) { java.lang.System.out?.println(x) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIteratorShort () throws Exception { loadText("fun box() { for(x in ShortArray(5)) { java.lang.System.out?.println(x) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIteratorInt () throws Exception { loadText("fun box() { for(x in IntArray(5)) { java.lang.System.out?.println(x) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIteratorLong () throws Exception { loadText("fun box() { for(x in LongArray(5)) { java.lang.System.out?.println(x) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIteratorFloat () throws Exception { loadText("fun box() { for(x in FloatArray(5)) { java.lang.System.out?.println(x) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIteratorDouble () throws Exception { loadText("fun box() { for(x in DoubleArray(5)) { java.lang.System.out?.println(x) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIteratorChar () throws Exception { loadText("fun box() { for(x in CharArray(5)) { java.lang.System.out?.println(x) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testPrimitiveIteratorBoolean () throws Exception { loadText("fun box() { for(x in BooleanArray(5)) { java.lang.System.out?.println(x) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testLongIterator () throws Exception { loadText("fun box() { val x = LongArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.nextLong()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testCharIterator () throws Exception { loadText("fun box() { val x = CharArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testByteIterator () throws Exception { loadText("fun box() { val x = ByteArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testShortIterator () throws Exception { loadText("fun box() { val x = ShortArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testIntIterator () throws Exception { loadText("fun box() { val x = IntArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testLongIterator2 () throws Exception { loadText("fun box() { val x = LongArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testFloatIterator () throws Exception { loadText("fun box() { val x = FloatArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testDoubleIterator () throws Exception { loadText("fun box() { val x = ShortArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testBooleanIterator () throws Exception { loadText("fun box() { val x = BooleanArray(5).iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testArrayIndices () throws Exception { loadText("fun box() { val x = Array(5, {it}).indices.iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } public void testCharIndices () throws Exception { loadText("fun box() { val x = CharArray(5).indices.iterator(); while(x.hasNext) { java.lang.System.out?.println(x.next()) } }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); foo.invoke(null); } @@ -208,7 +208,7 @@ public class ArrayGenTest extends CodegenTestCase { public void testArrayPlusAssign () throws Exception { loadText("fun box() : Int { val s = IntArray(1); s [0] = 5; s[0] += 7; return s[0] }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertTrue((Integer)foo.invoke(null) == 12); } @@ -218,7 +218,7 @@ public class ArrayGenTest extends CodegenTestCase { "fun box() : String { val s = ArrayList(1); s.add(\"\"); s [1, -1] = \"5\"; s[2, -2] += \"7\"; return s[2,-2] }\n" + "fun ArrayList.get(index1: Int, index2 : Int) = this[index1+index2]\n" + "fun ArrayList.set(index1: Int, index2 : Int, elem: String) { this[index1+index2] = elem }\n"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction("box"); assertTrue(foo.invoke(null).equals("57")); } @@ -228,7 +228,7 @@ public class ArrayGenTest extends CodegenTestCase { "fun box() : String? { val s = Array(1,{ \"\" }); s [1, -1] = \"5\"; s[2, -2] += \"7\"; return s[-3,3] }\n" + "fun Array.get(index1: Int, index2 : Int) = this[index1+index2]\n" + "fun Array.set(index1: Int, index2 : Int, elem: String) { this[index1+index2] = elem\n }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction("box"); assertTrue(foo.invoke(null).equals("57")); } @@ -238,7 +238,7 @@ public class ArrayGenTest extends CodegenTestCase { "fun box() : String { val s = ArrayList(1); s.add(\"\"); s [1, -1] = \"5\"; return s[2, -2] }\n" + "fun ArrayList.get(index1: Int, index2 : Int) = this[index1+index2]\n" + "fun ArrayList.set(index1: Int, index2 : Int, elem: String) { this[index1+index2] = elem }\n"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction("box"); assertTrue(foo.invoke(null).equals("5")); } @@ -248,7 +248,7 @@ public class ArrayGenTest extends CodegenTestCase { "fun box() : String? { val s = Array(1,{ \"\" }); s [1, -1] = \"5\"; return s[-2, 2] }\n" + "fun Array.get(index1: Int, index2 : Int) = this[index1+index2]\n" + "fun Array.set(index1: Int, index2 : Int, elem: String) { this[index1+index2] = elem\n }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction("box"); assertTrue(foo.invoke(null).equals("5")); } @@ -257,7 +257,7 @@ public class ArrayGenTest extends CodegenTestCase { loadText( "fun box() : Int? { val s = java.util.HashMap(); s[\"239\"] = 239; return s[\"239\"] }\n" + "fun java.util.HashMap.set(index: String, elem: Int?) { this.put(index, elem) }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction("box"); assertTrue((Integer)foo.invoke(null) == 239); } @@ -267,7 +267,7 @@ public class ArrayGenTest extends CodegenTestCase { "fun box() : Int { var l = IntArray(1); l[0.lng] = 4; l[0.lng] += 6; return l[0.lng];}\n" + "fun IntArray.set(index: Long, elem: Int) { this[index.int] = elem }\n" + "fun IntArray.get(index: Long) = this[index.int]"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction("box"); assertTrue((Integer)foo.invoke(null) == 10); } @@ -276,9 +276,14 @@ public class ArrayGenTest extends CodegenTestCase { blackBoxFile("regressions/kt503.jet"); } + public void testKt602() { + blackBoxFile("regressions/kt602.jet"); +// System.out.println(generateToText()); + } + public void testKt594() throws Exception { loadFile("regressions/kt594.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); blackBox(); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index 6b44f7b8d94..1f300ca6406 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -49,7 +49,7 @@ public class ClassGenTest extends CodegenTestCase { public void testNewInstanceExplicitConstructor() throws Exception { loadFile("classes/newInstanceDefaultConstructor.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method method = generateFunction("test"); final Integer returnValue = (Integer) method.invoke(null); assertEquals(610, returnValue.intValue()); @@ -149,7 +149,7 @@ public class ClassGenTest extends CodegenTestCase { public void testEnumClass() throws Exception { loadText("enum class Direction { NORTH; SOUTH; EAST; WEST }"); final Class direction = loadAllClasses(generateClassesInFile()).get("Direction"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Field north = direction.getField("NORTH"); assertEquals(direction, north.getType()); assertInstanceOf(north.get(null), direction); @@ -170,36 +170,36 @@ public class ClassGenTest extends CodegenTestCase { public void testKt48 () throws Exception { blackBoxFile("regressions/kt48.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testKt309 () throws Exception { loadText("fun box() = null"); final Method method = generateFunction("box"); assertEquals(method.getReturnType().getName(), "java.lang.Object"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testKt343 () throws Exception { blackBoxFile("regressions/kt343.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testKt344 () throws Exception { loadFile("regressions/kt344.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); blackBox(); } public void testKt508 () throws Exception { loadFile("regressions/kt508.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); blackBox(); } public void testKt504 () throws Exception { loadFile("regressions/kt504.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); blackBox(); } @@ -209,7 +209,7 @@ public class ClassGenTest extends CodegenTestCase { public void testKt496 () throws Exception { blackBoxFile("regressions/kt496.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testKt500 () throws Exception { diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java index 07b094c344d..9533317fbb2 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClosuresGenTest.java @@ -6,7 +6,7 @@ package org.jetbrains.jet.codegen; public class ClosuresGenTest extends CodegenTestCase { public void testSimplestClosure() throws Exception { blackBoxFile("classes/simplestClosure.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testSimplestClosureAndBoxing() throws Exception { @@ -27,7 +27,7 @@ public class ClosuresGenTest extends CodegenTestCase { public void testEnclosingLocalVariable() throws Exception { blackBoxFile("classes/enclosingLocalVariable.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testDoubleEnclosedLocalVariable() throws Exception { diff --git a/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java b/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java index 11914b419ac..0c1d8f4aa41 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java @@ -17,7 +17,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testIf() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(15, main.invoke(null, true)); assertEquals(20, main.invoke(null, false)); @@ -26,7 +26,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testSingleBranchIf() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(15, main.invoke(null, true)); assertEquals(20, main.invoke(null, false)); @@ -47,7 +47,7 @@ public class ControlStructuresTest extends CodegenTestCase { private void factorialTest(final String name) throws IllegalAccessException, InvocationTargetException { loadFile(name); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(6, main.invoke(null, 3)); assertEquals(120, main.invoke(null, 5)); @@ -55,7 +55,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testContinue() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(3, main.invoke(null, 4)); assertEquals(7, main.invoke(null, 5)); @@ -63,7 +63,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testIfNoElse() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(5, main.invoke(null, 5, true)); assertEquals(10, main.invoke(null, 5, false)); @@ -78,7 +78,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testFor() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); List args = Arrays.asList("IntelliJ", " ", "IDEA"); assertEquals("IntelliJ IDEA", main.invoke(null, args)); @@ -86,7 +86,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testIfBlock() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); List args = Arrays.asList("IntelliJ", " ", "IDEA"); assertEquals("TTT", main.invoke(null, args)); @@ -96,7 +96,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testForInArray() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); String[] args = new String[] { "IntelliJ", " ", "IDEA" }; assertEquals("IntelliJ IDEA", main.invoke(null, new Object[] { args })); @@ -126,7 +126,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testTryCatch() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals("no message", main.invoke(null, "0")); assertEquals("For input string: \"a\"", main.invoke(null, "a")); @@ -134,7 +134,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testTryFinally() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); StringBuilder sb = new StringBuilder(); main.invoke(null, sb, "9"); @@ -187,8 +187,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testCompareToNonnullableEq() throws Exception { loadText("fun foo(a: String?, b: String): Boolean = a == b || b == a"); - String text = generateToText(); - System.out.println(text); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(false, main.invoke(null, null, "lala")); assertEquals(true, main.invoke(null, "papa", "papa")); @@ -197,7 +196,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testCompareToNonnullableNotEq() throws Exception { loadText("fun foo(a: String?, b: String): Boolean = a != b"); String text = generateToText(); - System.out.println(text); +// System.out.println(text); assertTrue(text.contains("IXOR")); final Method main = generateFunction(); assertEquals(true, main.invoke(null, null, "lala")); @@ -210,7 +209,7 @@ public class ControlStructuresTest extends CodegenTestCase { public void testKt416() throws Exception { blackBoxFile("regressions/kt416.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testKt513() throws Exception { diff --git a/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java index ceacbc22fe6..8ab99d48757 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/FunctionGenTest.java @@ -9,17 +9,17 @@ import java.lang.reflect.Method; public class FunctionGenTest extends CodegenTestCase { public void testDefaultArgs() throws Exception { blackBoxFile("functions/defaultargs.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testNoThisNoClosure() throws Exception { blackBoxFile("functions/nothisnoclosure.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testAnyToString () throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any) = x.toString()"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("something", foo.invoke(null, "something")); assertEquals("null", foo.invoke(null, new Object[]{null})); @@ -28,7 +28,7 @@ public class FunctionGenTest extends CodegenTestCase { public void testNullableAnyToString () throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any?) = x.toString()"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("something", foo.invoke(null, "something")); assertEquals("null", foo.invoke(null, new Object[]{null})); @@ -63,7 +63,7 @@ public class FunctionGenTest extends CodegenTestCase { public void testAnyEqualsNullable () throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any?) = x.equals(\"lala\")"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertTrue((Boolean) foo.invoke(null, "lala")); assertFalse((Boolean) foo.invoke(null, "mama")); @@ -71,7 +71,7 @@ public class FunctionGenTest extends CodegenTestCase { public void testAnyEquals () throws InvocationTargetException, IllegalAccessException { loadText("fun foo(x: Any) = x.equals(\"lala\")"); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertTrue((Boolean) foo.invoke(null, "lala")); assertFalse((Boolean) foo.invoke(null, "mama")); diff --git a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index 9c88cfaec3e..81865f848af 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -17,8 +17,7 @@ import java.util.Arrays; public class NamespaceGenTest extends CodegenTestCase { public void testPSVM() throws Exception { loadFile("PSVM.jet"); - final String text = generateToText(); - System.out.println(text); +// System.out.println(generateToText()); final Method main = generateFunction(); Object[] args = new Object[] { new String[0] }; @@ -27,8 +26,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testReturnOne() throws Exception { loadText("fun f() : Int { return 42; }"); - final String text = generateToText(); - System.out.println(text); +// System.out.println(generateToText()); final Method main = generateFunction(); final Object returnValue = main.invoke(null, new Object[0]); @@ -37,8 +35,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testReturnA() throws Exception { loadText("fun foo(a : Int) = a"); - final String text = generateToText(); - System.out.println(text); +// System.out.println(generateToText()); final Method main = generateFunction(); final Object returnValue = main.invoke(null, 50); @@ -47,8 +44,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testLocalProperty() throws Exception { loadFile("localProperty.jet"); - final String text = generateToText(); - System.out.println(text); +// System.out.println(generateToText()); final Method main = generateFunction(); final Object returnValue = main.invoke(null, 76); @@ -57,7 +53,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testCurrentTime() throws Exception { loadText("fun f() : Long { return System.currentTimeMillis(); }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); final long returnValue = (Long) main.invoke(null); assertIsCurrentTime(returnValue); @@ -65,7 +61,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testIdentityHashCode() throws Exception { loadText("fun f(o: Any) : Int { return System.identityHashCode(o); }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); Object o = new Object(); final int returnValue = (Integer) main.invoke(null, o); @@ -82,7 +78,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testHelloWorld() throws Exception { loadFile("helloWorld.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); generateFunction(); // assert that it can be verified } @@ -90,7 +86,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testAssign() throws Exception { loadFile("assign.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(2, main.invoke(null)); } @@ -116,7 +112,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testBoxVariable() throws Exception { loadText("fun foo(): Int? { var x = 239; return x; }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(239, main.invoke(null)); } @@ -173,14 +169,14 @@ public class NamespaceGenTest extends CodegenTestCase { public void testBottles2() throws Exception { loadFile("bottles2.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); main.invoke(null); // ensure no exception } public void testJavaConstructor() throws Exception { loadText("fun foo(): StringBuilder = StringBuilder()"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); final Object result = main.invoke(null); assertTrue(result instanceof StringBuilder); @@ -195,7 +191,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testJavaEquals() throws Exception { loadText("fun foo(s1: String, s2: String) = s1 == s2"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(Boolean.TRUE, main.invoke(null, new String("jet"), new String("jet"))); assertEquals(Boolean.FALSE, main.invoke(null, new String("jet"), new String("ceylon"))); @@ -211,7 +207,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testJavaEqualsNull() throws Exception { loadText("fun foo(s1: String?, s2: String?) = s1 == s2"); final Method main = generateFunction(); - System.out.println(generateToText()); +// System.out.println(generateToText()); assertEquals(Boolean.TRUE, main.invoke(null, null, null)); assertEquals(Boolean.FALSE, main.invoke(null, "jet", null)); assertEquals(Boolean.FALSE, main.invoke(null, null, "jet")); @@ -220,7 +216,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testEqualsNullLiteral() throws Exception { loadText("fun foo(s: String?) = s == null"); final Method main = generateFunction(); - System.out.println(generateToText()); +// System.out.println(generateToText()); assertEquals(Boolean.TRUE, main.invoke(null, new Object[] { null })); assertEquals(Boolean.FALSE, main.invoke(null, "jet")); } @@ -245,7 +241,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFunctionCall() throws Exception { loadFile("functionCall.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction("f"); assertEquals("foo", main.invoke(null)); } @@ -267,14 +263,14 @@ public class NamespaceGenTest extends CodegenTestCase { public void testStringPlusEq() throws Exception { loadText("fun foo(s: String) : String { var result = s; result += s; return result; } "); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals("JarJar", main.invoke(null, "Jar")); } public void testStringCompare() throws Exception { loadText("fun foo(s1: String, s2: String) = s1 < s2"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(Boolean.TRUE, main.invoke(null, "Ceylon", "Java")); assertEquals(Boolean.FALSE, main.invoke(null, "Jet", "Java")); @@ -302,7 +298,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFieldRead() throws Exception { loadText("import java.awt.*; fun foo(c: GridBagConstraints) = c.gridx"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 239; @@ -319,7 +315,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFieldIncrement() throws Exception { loadText("import java.awt.*; fun foo(c: GridBagConstraints) { c.gridx++; return; }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 609; @@ -329,7 +325,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFieldAugAssign() throws Exception { loadText("import java.awt.*; fun foo(c: GridBagConstraints) { c.gridx *= 2; return; }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); GridBagConstraints c = new GridBagConstraints(); c.gridx = 305; @@ -358,7 +354,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArrayAugAssign() throws Exception { loadText("fun foo(c: Array) { c[0] *= 2 }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); Integer[] data = new Integer[] { 5 }; main.invoke(null, new Object[] { data }); @@ -367,7 +363,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArrayAugAssignLong() throws Exception { loadText("fun foo(c: LongArray) { c[0] *= 2.lng }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); long[] data = new long[] { 5 }; main.invoke(null, new Object[] { data }); @@ -376,7 +372,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArrayNew() throws Exception { loadText("fun foo() = Array(4, { it })"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); Integer[] result = (Integer[]) main.invoke(null); assertEquals(4, result.length); @@ -388,14 +384,14 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArrayNewNullable() throws Exception { loadText("fun foo() = Array(4)"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); Integer[] result = (Integer[]) main.invoke(null); assertEquals(4, result.length); } public void testFloatArrayNew() throws Exception { loadText("fun foo() = FloatArray(4)"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); float[] result = (float[]) main.invoke(null); assertEquals(4, result.length); @@ -403,7 +399,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testFloatArrayArrayNew() throws Exception { loadText("fun foo() = Array(4, { FloatArray(5-it) })"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); float[][] result = (float[][]) main.invoke(null); assertEquals(4, result.length); @@ -412,7 +408,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testArraySize() throws Exception { loadText("fun foo(a: Array) = a.size"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); Object[] args = new Object[] { new Integer[4] }; int result = (Integer) main.invoke(null, args); @@ -422,7 +418,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testIntArraySize() throws Exception { loadText("fun foo(a: IntArray) = a.size"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); Object[] args = new Object[] { new int[4] }; int result = (Integer) main.invoke(null, args); @@ -490,7 +486,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testTupleLiteral() throws Exception { loadText("fun foo() = (1, \"foo\")"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); Tuple2 tuple2 = (Tuple2) main.invoke(null); assertEquals(1, tuple2._1); @@ -499,7 +495,7 @@ public class NamespaceGenTest extends CodegenTestCase { public void testParametrizedTupleLiteral() throws Exception { loadText("fun E.foo(extra: java.util.List) = (1, \"foo\", this, extra)"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); Tuple4 tuple4 = (Tuple4) main.invoke(null, "aaa", TypeInfo.STRING_TYPE_INFO, TypeInfo.INT_TYPE_INFO, Arrays.asList(10)); assertEquals(1, tuple4._1); @@ -515,7 +511,7 @@ public class NamespaceGenTest extends CodegenTestCase { assertNull(main.invoke(null, "IntelliJ")); } catch (Throwable t) { - System.out.println(generateToText()); +// System.out.println(generateToText()); t.printStackTrace(); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/ObjectGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ObjectGenTest.java index 53b76ccf788..05c5a66ca93 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ObjectGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ObjectGenTest.java @@ -11,7 +11,7 @@ public class ObjectGenTest extends CodegenTestCase { public void testObjectLiteral() throws Exception { blackBoxFile("objects/objectLiteral.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testMethodOnObject() throws Exception { diff --git a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java index 667415f53f3..a3fd95c3ab3 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java @@ -37,7 +37,7 @@ public class PatternMatchingTest extends CodegenTestCase { public void testInrange() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("array list", foo.invoke(null, 239)); assertEquals("digit", foo.invoke(null, 0)); @@ -49,13 +49,13 @@ public class PatternMatchingTest extends CodegenTestCase { public void testIs() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); blackBox(); } public void testRange() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("array list", foo.invoke(null, 239)); assertEquals("digit", foo.invoke(null, 0)); @@ -67,7 +67,7 @@ public class PatternMatchingTest extends CodegenTestCase { public void testRangeChar() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertEquals("digit", foo.invoke(null, '0')); assertEquals("something", foo.invoke(null, 'A')); @@ -99,18 +99,19 @@ public class PatternMatchingTest extends CodegenTestCase { assertEquals("something", foo.invoke(null, new Tuple2(null, "not", "tuple"))); } - public void testCall() throws Exception { - loadText("fun foo(s: String) = when(s) { .startsWith(\"J\") => \"JetBrains\"; else => \"something\" }"); - Method foo = generateFunction(); - try { - assertEquals("JetBrains", foo.invoke(null, "Java")); - assertEquals("something", foo.invoke(null, "C#")); - } - catch (Throwable t) { - System.out.println(generateToText()); - t.printStackTrace(); - } - } + // Commented for KT-621 +// public void testCall() throws Exception { +// loadText("fun foo(s: String) = when(s) { .startsWith(\"J\") => \"JetBrains\"; else => \"something\" }"); +// Method foo = generateFunction(); +// try { +// assertEquals("JetBrains", foo.invoke(null, "Java")); +// assertEquals("something", foo.invoke(null, "C#")); +// } +// catch (Throwable t) { +// System.out.println(generateToText()); +// t.printStackTrace(); +// } +// } public void testCallProperty() throws Exception { blackBoxFile("patternMatching/callProperty.jet"); diff --git a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java index 0a7b11175ea..e98e1b17a8b 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PrimitiveTypesTest.java @@ -10,7 +10,7 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testPlus() throws Exception { loadText("fun f(a: Int, b: Int): Int { return a + b }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); final int returnValue = (Integer) main.invoke(null, 37, 5); @@ -20,7 +20,7 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testGt() throws Exception { loadText("fun foo(f: Int): Boolean { if (f > 0) return true; return false; }"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(true, main.invoke(null, 1)); assertEquals(false, main.invoke(null, 0)); @@ -57,7 +57,7 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testLong() throws Exception { loadText("fun foo(a: Long, b: Long): Long = a + b"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); long arg = (long) Integer.MAX_VALUE; long expected = 2 * (long) Integer.MAX_VALUE; @@ -66,7 +66,7 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testLongCmp() throws Exception { loadText("fun foo(a: Long, b: Long): Long = if (a == b) 0xffffffff else 0xfffffffe"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(0xffffffffL, main.invoke(null, 1, 1)); assertEquals(0xfffffffeL, main.invoke(null, 1, 0)); @@ -132,7 +132,7 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testDoubleToInt() throws Exception { loadText("fun foo(a: Double): Int = a.int"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(1, main.invoke(null, 1.0)); } @@ -216,7 +216,7 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testBitInv() throws Exception { loadText("fun foo(a: Int): Int = a.inv()"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(0xffff0000, main.invoke(null, 0x0000ffff)); } @@ -249,14 +249,14 @@ public class PrimitiveTypesTest extends CodegenTestCase { public void testDecrementAsStatement() throws Exception { loadFile("bottles.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); main.invoke(null); // ensure no exception } private void binOpTest(final String text, final Object arg1, final Object arg2, final Object expected) throws Exception { loadText(text); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); assertEquals(expected, main.invoke(null, arg1, arg2)); } diff --git a/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java index 096bd9e1c03..943064ca3bb 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PropertyGenTest.java @@ -64,7 +64,7 @@ public class PropertyGenTest extends CodegenTestCase { public void testFieldPropertyAccess() throws Exception { loadFile("properties/fieldPropertyAccess.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method method = generateFunction(); assertEquals(1, method.invoke(null)); assertEquals(2, method.invoke(null)); @@ -136,6 +136,10 @@ public class PropertyGenTest extends CodegenTestCase { blackBoxFile("regressions/kt257.jet"); } + public void testKt613 () throws Exception { + blackBoxFile("regressions/kt613.jet"); + } + public void testKt160() throws Exception { loadText("internal val s = java.lang.Double.toString(1.0)"); final Method method = generateFunction("getS"); diff --git a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java index fdfbbecfa5b..7337274caac 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/StdlibTest.java @@ -71,7 +71,7 @@ public class StdlibTest extends CodegenTestCase { public void testInputStreamIterator () { blackBoxFile("inputStreamIterator.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testKt533 () { diff --git a/compiler/tests/org/jetbrains/jet/codegen/SuperGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/SuperGenTest.java index 86bbd2b935e..0b276174692 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/SuperGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/SuperGenTest.java @@ -3,21 +3,21 @@ package org.jetbrains.jet.codegen; public class SuperGenTest extends CodegenTestCase { public void testBasicProperty () { blackBoxFile("/super/basicproperty.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testTraitProperty () { blackBoxFile("/super/traitproperty.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testBasicMethod () { blackBoxFile("/super/basicmethod.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testEnclosedMethod () { blackBoxFile("/super/enclosed.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/TraitsTest.java b/compiler/tests/org/jetbrains/jet/codegen/TraitsTest.java index b805c7d2147..4fd7093c08e 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TraitsTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TraitsTest.java @@ -8,12 +8,12 @@ public class TraitsTest extends CodegenTestCase { public void testSimple () throws Exception { blackBoxFile("traits/simple.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testWithRequired () throws Exception { blackBoxFile("traits/withRequired.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testMultiple () throws Exception { diff --git a/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java b/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java index 2abfd9db28e..1ce4e56d3c8 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TypeInfoTest.java @@ -65,7 +65,7 @@ public class TypeInfoTest extends CodegenTestCase { if (true) return; loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); assertFalse((Boolean) foo.invoke(null)); } @@ -116,7 +116,7 @@ public class TypeInfoTest extends CodegenTestCase { public void testClassObjectInTypeInfo() throws Exception { loadFile(); - System.out.println(generateToText()); +// System.out.println(generateToText()); Method foo = generateFunction(); JetObject jetObject = (JetObject) foo.invoke(null); TypeInfo typeInfo = jetObject.getTypeInfo(); @@ -135,12 +135,12 @@ public class TypeInfoTest extends CodegenTestCase { public void testKt259() throws Exception { blackBoxFile("regressions/kt259.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } public void testInner() throws Exception { blackBoxFile("typeInfo/inner.jet"); - System.out.println(generateToText()); +// System.out.println(generateToText()); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java index a71dacad1af..62fbe452833 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/VarArgTest.java @@ -9,7 +9,7 @@ import java.lang.reflect.Method; public class VarArgTest extends CodegenTestCase { public void testStringArray () throws InvocationTargetException, IllegalAccessException { loadText("fun test(vararg ts: String) = ts"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); String[] args = {"mama", "papa"}; assertTrue(args == main.invoke(null, new Object[]{ args } )); @@ -17,7 +17,7 @@ public class VarArgTest extends CodegenTestCase { public void testIntArray () throws InvocationTargetException, IllegalAccessException { loadText("fun test(vararg ts: Int) = ts"); - System.out.println(generateToText()); +// System.out.println(generateToText()); final Method main = generateFunction(); int[] args = {3, 4}; assertTrue(args == main.invoke(null, new Object[]{ args })); @@ -25,7 +25,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()); +// System.out.println(generateToText()); final Method main = generateFunction(); Object res = main.invoke(null); assertTrue(((int[])res).length == 0); @@ -33,8 +33,9 @@ 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()); +// System.out.println(generateToText()); final Method main = generateFunction(); + System.out.println(main.toString()); Object res = main.invoke(null); assertTrue(((int[])res).length == 2); assertTrue(((int[])res)[0] == 239); @@ -43,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()); +// System.out.println(generateToText()); final Method main = generateFunction(); Object res = main.invoke(null); assertTrue(((Byte[])res).length == 2); @@ -53,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()); +// System.out.println(generateToText()); final Method main = generateFunction(); Object res = main.invoke(null); assertTrue(((String[])res).length == 1); @@ -62,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()); +// System.out.println(generateToText()); final Method main = generateFunction(); Object res = main.invoke(null); assertTrue(((Integer[])res).length == 2); diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index bc2d5e09fa3..81687edd8c8 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -162,6 +162,22 @@ public class JetTypeCheckerTest extends JetLiteFixture { assertIntersection("Int?", "Int?", "Int?"); assertIntersection("Int", "Int?", "Int"); assertIntersection("Int", "Int", "Int?"); + + assertIntersection("Int", "Any", "Int"); + assertIntersection("Int", "Int", "Any"); + + assertIntersection("Int", "Any", "Int?"); + assertIntersection("Int", "Int?", "Any"); + assertIntersection("Int", "Any?", "Int"); + assertIntersection("Int", "Int", "Any?"); + + assertIntersection("Nothing", "Nothing", "Nothing"); + assertIntersection("Nothing?", "Nothing?", "Nothing?"); + assertIntersection("Nothing", "Nothing", "Nothing?"); + assertIntersection("Nothing", "Nothing?", "Nothing"); + + assertIntersection("Nothing?", "String?", "Nothing?"); + assertIntersection("Nothing?", "Nothing?", "String?"); } public void testBasicSubtyping() throws Exception { diff --git a/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceSafeCallWithDotCall.java b/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceSafeCallWithDotCall.java index d38fad55bcd..c6a18316996 100644 --- a/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceSafeCallWithDotCall.java +++ b/idea/src/org/jetbrains/jet/plugin/quickfix/ReplaceSafeCallWithDotCall.java @@ -40,13 +40,6 @@ public class ReplaceSafeCallWithDotCall extends JetIntentionAction { CodeEditUtil.replaceChild(newElement.getNode(), newElement.getSelectorExpression().getNode(), safeQualifiedExpression.getSelectorExpression().getNode()); CodeEditUtil.replaceChild(newElement.getNode(), newElement.getReceiverExpression().getNode(), safeQualifiedExpression.getReceiverExpression().getNode()); - element.replace(newElement); - } - else if (element instanceof JetWhenConditionCall) { - JetWhenConditionCall newElement = (JetWhenConditionCall) element; - JetDotQualifiedExpression callExpression = (JetDotQualifiedExpression) JetPsiFactory.createExpression(project, "x.foo"); - CodeEditUtil.replaceChild(newElement.getNode(), newElement.getOperationTokenNode(), callExpression.getOperationTokenNode()); - element.replace(newElement); } } diff --git a/idea/testData/checker/When.jet b/idea/testData/checker/When.jet index a7bd2a87103..c9e799dd41d 100644 --- a/idea/testData/checker/When.jet +++ b/idea/testData/checker/When.jet @@ -13,15 +13,18 @@ fun foo() : Int { 1 + a => 1 in 1..a => 1 !in 1..a => 1 - .a => 1 - .equals(1).a => 1 - ?.equals(1) => 1 + // Commented for KT-621 .a => 1 + // Commented for KT-621 .equals(1).a => 1 + // Commented for KT-621 ?.equals(1) => 1 else => 1 } - return when (x?:null) { - .foo() => 1 - ?.equals(1).equals(2) => 1 - } + + // Commented for KT-621 + // return when (x?:null) { + // .foo() => 1 + // ?.equals(1).equals(2) => 1 + // } + return 0 } val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo() diff --git a/idea/testData/quickfix/expressions/beforeUnnecessarySafeCall2.kt b/idea/testData/quickfix/expressions/beforeUnnecessarySafeCall2.kt deleted file mode 100644 index cee0f9535b3..00000000000 --- a/idea/testData/quickfix/expressions/beforeUnnecessarySafeCall2.kt +++ /dev/null @@ -1,7 +0,0 @@ -// "Replace with dot call" "true" -fun foo(a: Any) { - when (a) { - ?.equals(0) => true - else => false - } -} \ No newline at end of file