diff --git a/.idea/modules.xml b/.idea/modules.xml index 9c559c5bba1..13927ade54d 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -11,8 +11,8 @@ + - diff --git a/build.xml b/build.xml index c799c56523e..8f7b193af88 100644 --- a/build.xml +++ b/build.xml @@ -42,11 +42,11 @@ - + - - + + diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java b/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java index ffffaffb1ec..f93b818b852 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java @@ -3,13 +3,11 @@ package org.jetbrains.jet.codegen; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; -import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; +import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.types.JetType; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.commons.InstructionAdapter; -import org.objectweb.asm.commons.Method; import java.util.List; @@ -87,7 +85,8 @@ public class CallableMethod implements Callable { else { if(getInvokeOpcode() != Opcodes.INVOKESTATIC) desc = desc.replace("(", "(L" + getOwner() + ";"); - v.visitMethodInsn(Opcodes.INVOKESTATIC, getInvokeOpcode() == Opcodes.INVOKEINTERFACE ? getOwner() + "$$TImpl" : getOwner(), getSignature().getAsmMethod().getName() + "$default", desc); + v.visitMethodInsn(Opcodes.INVOKESTATIC, getInvokeOpcode() == Opcodes.INVOKEINTERFACE ? getOwner() + JvmAbi.TRAIT_IMPL_SUFFIX + : getOwner(), getSignature().getAsmMethod().getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, desc); } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java index 83d535a52a1..a277a4b5444 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java @@ -48,8 +48,6 @@ public abstract class ClassBodyCodegen { generateSyntheticParts(accessors); generateStaticInitializer(); - - v.done(); } protected abstract void generateDeclaration(); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClassCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassCodegen.java index be784975f03..50996384f19 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClassCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClassCodegen.java @@ -26,6 +26,12 @@ public class ClassCodegen { } final CodegenContext contextForInners = context.intoClass(descriptor, OwnerKind.IMPLEMENTATION, state.getTypeMapper()); + + if (!classBuilder.generateCode()) { + // Outer class implementation must happen prior inner classes so we get proper scoping tree in JetLightClass's delegate + generateImplementation(context, aClass, OwnerKind.IMPLEMENTATION, contextForInners.accessors, classBuilder); + } + for (JetDeclaration declaration : aClass.getDeclarations()) { if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) { generate(contextForInners, (JetClass) declaration); @@ -35,7 +41,11 @@ public class ClassCodegen { } } - generateImplementation(context, aClass, OwnerKind.IMPLEMENTATION, contextForInners.accessors, classBuilder); + if (classBuilder.generateCode()) { + generateImplementation(context, aClass, OwnerKind.IMPLEMENTATION, contextForInners.accessors, classBuilder); + } + + classBuilder.done(); } private void generateImplementation(CodegenContext context, JetClassOrObject aClass, OwnerKind kind, HashMap accessors, ClassBuilder classBuilder) { @@ -46,6 +56,7 @@ public class ClassCodegen { if(aClass instanceof JetClass && ((JetClass)aClass).isTrait()) { ClassBuilder traitBuilder = state.forTraitImplementation(descriptor); new TraitImplBodyCodegen(aClass, context.intoClass(descriptor, OwnerKind.TRAIT_IMPL, state.getTypeMapper()), traitBuilder, state).generate(null); + traitBuilder.done(); } } } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 8dafa6b2690..59cf9453497 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -2410,13 +2410,19 @@ If finally block is present, its last expression is the value of try expression. return generateTuplePatternMatch((JetTuplePattern) pattern, negated, expressionToMatch, nextEntry); } else if (pattern instanceof JetExpressionPattern) { - final Type subjectType = expressionToMatch.type; - expressionToMatch.dupReceiver(v); - expressionToMatch.put(subjectType, v); - JetExpression condExpression = ((JetExpressionPattern) pattern).getExpression(); - Type condType = isNumberPrimitive(subjectType) ? expressionType(condExpression) : TYPE_OBJECT; - gen(condExpression, condType); - return generateEqualsForExpressionsOnStack(JetTokens.EQEQ, subjectType, condType, false, false); + if(expressionToMatch != null) { + final Type subjectType = expressionToMatch.type; + expressionToMatch.dupReceiver(v); + expressionToMatch.put(subjectType, v); + JetExpression condExpression = ((JetExpressionPattern) pattern).getExpression(); + Type condType = isNumberPrimitive(subjectType) ? expressionType(condExpression) : TYPE_OBJECT; + gen(condExpression, condType); + return generateEqualsForExpressionsOnStack(JetTokens.EQEQ, subjectType, condType, false, false); + } + else { + JetExpression condExpression = ((JetExpressionPattern) pattern).getExpression(); + return gen(condExpression); + } } else if (pattern instanceof JetWildcardPattern) { return StackValue.constant(!negated, Type.BOOLEAN_TYPE); @@ -2665,9 +2671,11 @@ If finally block is present, its last expression is the value of try expression. JetExpression expr = expression.getSubjectExpression(); final Type subjectType = expressionType(expr); final Type resultType = expressionType(expression); - final int subjectLocal = myFrameMap.enterTemp(subjectType.getSize()); - gen(expr, subjectType); - v.store(subjectLocal, subjectType); + final int subjectLocal = expr != null ? myFrameMap.enterTemp(subjectType.getSize()) : -1; + if(subjectLocal != -1) { + gen(expr, subjectType); + v.store(subjectLocal, subjectType); + } Label end = new Label(); boolean hasElse = false; @@ -2736,7 +2744,7 @@ If finally block is present, its last expression is the value of try expression. JetWhenConditionIsPattern patternCondition = (JetWhenConditionIsPattern) condition; JetPattern pattern = patternCondition.getPattern(); conditionValue = generatePatternMatch(pattern, patternCondition.isNegated(), - StackValue.local(subjectLocal, subjectType), nextEntry); + subjectLocal == -1 ? null : StackValue.local(subjectLocal, subjectType), nextEntry); } else { throw new UnsupportedOperationException("unsupported kind of when condition"); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index c8c9f3dee79..97345407289 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -6,7 +6,8 @@ import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorUtils; -import org.jetbrains.jet.lang.resolve.java.StdlibNames; +import org.jetbrains.jet.lang.resolve.java.JvmAbi; +import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.Label; @@ -68,6 +69,10 @@ public class FunctionCodegen { { flags |= ACC_VARARGS; } + + if (functionDescriptor.getModality() == Modality.FINAL) { + flags |= ACC_FINAL; + } OwnerKind kind = context.getContextKind(); @@ -88,48 +93,48 @@ public class FunctionCodegen { if(kind != OwnerKind.TRAIT_IMPL) { AnnotationVisitor av = mv.visitAnnotation(JetTypeMapper.JET_METHOD_TYPE.getDescriptor(), true); if(functionDescriptor.getReturnType().isNullable()) { - av.visit(StdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD, true); + av.visit(JvmStdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD, true); } if (jvmSignature.getKotlinReturnType() != null) { - av.visit(StdlibNames.JET_METHOD_RETURN_TYPE_FIELD, jvmSignature.getKotlinReturnType()); + av.visit(JvmStdlibNames.JET_METHOD_RETURN_TYPE_FIELD, jvmSignature.getKotlinReturnType()); } if (jvmSignature.getKotlinTypeParameter() != null) { - av.visit(StdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD, jvmSignature.getKotlinTypeParameter()); + av.visit(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD, jvmSignature.getKotlinTypeParameter()); } av.visitEnd(); } if(kind == OwnerKind.TRAIT_IMPL) { - AnnotationVisitor av = mv.visitParameterAnnotation(start++, StdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true); - av.visit(StdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "this$self"); + AnnotationVisitor av = mv.visitParameterAnnotation(start++, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true); + av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "this$self"); av.visitEnd(); } if(receiverParameter.exists()) { - AnnotationVisitor av = mv.visitParameterAnnotation(start++, StdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true); - av.visit(StdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "this$receiver"); + AnnotationVisitor av = mv.visitParameterAnnotation(start++, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true); + av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, "this$receiver"); if(receiverParameter.getType().isNullable()) { - av.visit(StdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true); + av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true); } - av.visit(StdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD, true); + av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD, true); av.visitEnd(); } for (final TypeParameterDescriptor typeParameterDescriptor : typeParameters) { - AnnotationVisitor av = mv.visitParameterAnnotation(start++, StdlibNames.JET_TYPE_PARAMETER.getDescriptor(), true); - av.visit(StdlibNames.JET_TYPE_PARAMETER_NAME_FIELD, typeParameterDescriptor.getName()); + AnnotationVisitor av = mv.visitParameterAnnotation(start++, JvmStdlibNames.JET_TYPE_PARAMETER.getDescriptor(), true); + av.visit(JvmStdlibNames.JET_TYPE_PARAMETER_NAME_FIELD, typeParameterDescriptor.getName()); av.visitEnd(); } for(int i = 0; i != paramDescrs.size(); ++i) { - AnnotationVisitor av = mv.visitParameterAnnotation(i + start, StdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true); + AnnotationVisitor av = mv.visitParameterAnnotation(i + start, JvmStdlibNames.JET_VALUE_PARAMETER.getDescriptor(), true); ValueParameterDescriptor parameterDescriptor = paramDescrs.get(i); - av.visit(StdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, parameterDescriptor.getName()); + av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD, parameterDescriptor.getName()); if(parameterDescriptor.hasDefaultValue()) { - av.visit(StdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, true); + av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD, true); } if(parameterDescriptor.getOutType().isNullable()) { - av.visit(StdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true); + av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD, true); } if (jvmSignature.getKotlinParameterTypes() != null && jvmSignature.getKotlinParameterTypes().get(i) != null) { - av.visit(StdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD, jvmSignature.getKotlinParameterTypes().get(i)); + av.visit(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD, jvmSignature.getKotlinParameterTypes().get(i + start)); } av.visitEnd(); } @@ -300,7 +305,7 @@ public class FunctionCodegen { boolean isConstructor = "".equals(jvmSignature.getName()); if(!isStatic && !isConstructor) descriptor = descriptor.replace("(","(L" + ownerInternalName + ";"); - final MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC), isConstructor ? "" : jvmSignature.getName() + "$default", descriptor, null, null); + final MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC), isConstructor ? "" : jvmSignature.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, descriptor, null, null); InstructionAdapter iv = new InstructionAdapter(mv); if (v.generateCode()) { mv.visitCode(); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index 852b12ac22e..7acd5cba2b5 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -6,8 +6,8 @@ import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.OverridingUtil; -import org.jetbrains.jet.lang.resolve.java.StdlibNames; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; +import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeProjection; import org.jetbrains.jet.lexer.JetTokens; @@ -47,19 +47,41 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { boolean isAbstract = false; boolean isInterface = false; + boolean isFinal = false; + boolean isStatic = false; + if(myClass instanceof JetClass) { - if(((JetClass) myClass).hasModifier(JetTokens.ABSTRACT_KEYWORD)) + JetClass jetClass = (JetClass) myClass; + if (jetClass.hasModifier(JetTokens.ABSTRACT_KEYWORD)) isAbstract = true; - if(((JetClass) myClass).isTrait()) { + if (jetClass.isTrait()) { isAbstract = true; isInterface = true; } + if (!jetClass.hasModifier(JetTokens.OPEN_KEYWORD) && !isAbstract) { + isFinal = true; + } + } + else if (myClass.getParent() instanceof JetClassObject) { + isStatic = true; } + int access = 0; + access |= Opcodes.ACC_PUBLIC; + if (isAbstract) { + access |= Opcodes.ACC_ABSTRACT; + } + if (isInterface) { + access |= Opcodes.ACC_INTERFACE; // ACC_SUPER + } + if (isFinal) { + access |= Opcodes.ACC_FINAL; + } + if (isStatic) { + access |= Opcodes.ACC_STATIC; + } v.defineClass(myClass, Opcodes.V1_6, - Opcodes.ACC_PUBLIC | (isAbstract ? Opcodes.ACC_ABSTRACT : 0) | (isInterface - ? Opcodes.ACC_INTERFACE - : 0/*Opcodes.ACC_SUPER*/), + access, signature.getName(), signature.getJavaGenericSignature(), signature.getSuperclassName(), @@ -67,17 +89,27 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { ); v.visitSource(myClass.getContainingFile().getName(), null); - if(descriptor.getContainingDeclaration() instanceof ClassDescriptor) { - v.visitOuterClass(typeMapper.mapType(((ClassDescriptor) descriptor.getContainingDeclaration()).getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(), null, null); + ClassDescriptor container = getContainingClassDescriptor(descriptor); + if(container != null) { + v.visitOuterClass(typeMapper.mapType(container.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName(), null, null); } if(myClass instanceof JetClass && signature.getKotlinGenericSignature() != null) { - AnnotationVisitor annotationVisitor = v.newAnnotation(myClass, StdlibNames.JET_CLASS.getDescriptor(), true); - annotationVisitor.visit(StdlibNames.JET_CLASS_SIGNATURE, signature.getKotlinGenericSignature()); + AnnotationVisitor annotationVisitor = v.newAnnotation(myClass, JvmStdlibNames.JET_CLASS.getDescriptor(), true); + annotationVisitor.visit(JvmStdlibNames.JET_CLASS_SIGNATURE, signature.getKotlinGenericSignature()); annotationVisitor.visitEnd(); } } + private static ClassDescriptor getContainingClassDescriptor(ClassDescriptor decl) { + DeclarationDescriptor container = decl.getContainingDeclaration(); + while (container != null && !(container instanceof NamespaceDescriptor)) { + if (container instanceof ClassDescriptor) return (ClassDescriptor) container; + container = container.getContainingDeclaration(); + } + return null; + } + private JvmClassSignature signature() { List superInterfaces; @@ -106,7 +138,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { { // superinterfaces - superInterfacesLinkedHashSet.add(StdlibNames.JET_OBJECT.getInternalName()); + superInterfacesLinkedHashSet.add(JvmStdlibNames.JET_OBJECT.getInternalName()); for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) { JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference()); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java index ef2cef70364..b7130e122f2 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java @@ -1,5 +1,6 @@ package org.jetbrains.jet.codegen; +import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import jet.JetObject; import jet.typeinfo.TypeInfo; @@ -12,6 +13,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver; import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor; +import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lexer.JetTokens; @@ -180,7 +182,29 @@ public class JetTypeMapper { } private HashMap> naming = new HashMap>(); - + + private String getStableNameForObject(JetObjectDeclaration object, DeclarationDescriptor descriptor) { + String local = getLocalNameForObject(object); + if (local == null) return null; + + DeclarationDescriptor containingClass = getContainingClass(descriptor); + if (containingClass != null) { + return getFQName(containingClass) + "$" + local; + } + else { + return getFQName(getContainingNamespace(descriptor)) + "/" + local; + } + } + + public static String getLocalNameForObject(JetObjectDeclaration object) { + PsiElement parent = object.getParent(); + if (parent instanceof JetClassObject) { + return "ClassObject$"; + } + + return null; + } + public String getFQName(DeclarationDescriptor descriptor) { descriptor = descriptor.getOriginal(); @@ -200,7 +224,17 @@ public class JetTypeMapper { name = map.get(descriptor); if(name == null) { - name = getFQName(container) + "$" + (map.size()+1); + PsiElement declaration = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, descriptor); + if (declaration instanceof JetObjectDeclaration) { + String stable = getStableNameForObject((JetObjectDeclaration) declaration, descriptor); + if (stable != null) { + name = stable; + } + } + + if (name == null) { + name = getFQName(container) + "$" + (map.size()+1); + } map.put(descriptor, name); } return name; @@ -222,7 +256,19 @@ public class JetTypeMapper { return name; } - + + private static ClassDescriptor getContainingClass(DeclarationDescriptor descriptor) { + DeclarationDescriptor parent = descriptor.getContainingDeclaration(); + if (parent == null || parent instanceof ClassDescriptor) return (ClassDescriptor) parent; + return getContainingClass(parent); + } + + private static NamespaceDescriptor getContainingNamespace(DeclarationDescriptor descriptor) { + DeclarationDescriptor parent = descriptor.getContainingDeclaration(); + if (parent == null || parent instanceof NamespaceDescriptor) return (NamespaceDescriptor) parent; + return getContainingNamespace(parent); + } + @NotNull public Type mapType(final JetType jetType) { return mapType(jetType, (BothSignatureWriter) null); } @@ -280,7 +326,7 @@ public class JetTypeMapper { if (descriptor instanceof ClassDescriptor) { String name = getFQName(descriptor); - Type asmType = Type.getObjectType(name + (kind == OwnerKind.TRAIT_IMPL ? "$$TImpl" : "")); + Type asmType = Type.getObjectType(name + (kind == OwnerKind.TRAIT_IMPL ? JvmAbi.TRAIT_IMPL_SUFFIX : "")); if (signatureVisitor != null) { signatureVisitor.writeClassBegin(asmType.getInternalName(), jetType.isNullable()); @@ -738,6 +784,8 @@ public class JetTypeMapper { } private void initKnownTypeNames() { + knowTypeNames.put(JetStandardClasses.getAnyType(), "ANY_TYPE_INFO"); + knowTypeNames.put(JetStandardClasses.getNullableAnyType(), "NULLABLE_ANY_TYPE_INFO"); knowTypeNames.put(standardLibrary.getIntType(), "INT_TYPE_INFO"); knowTypeNames.put(standardLibrary.getNullableIntType(), "NULLABLE_INT_TYPE_INFO"); knowTypeNames.put(standardLibrary.getLongType(), "LONG_TYPE_INFO"); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java index f9167601b55..e797dadb554 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java @@ -6,6 +6,7 @@ import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.calls.ResolvedCall; +import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lexer.JetTokens; @@ -754,7 +755,7 @@ public abstract class StackValue { @Override public void put(Type type, InstructionAdapter v) { if(isSuper && isInterface) { - v.visitMethodInsn(Opcodes.INVOKESTATIC, owner + "$$TImpl", getter.getName(), getter.getDescriptor().replace("(","(L" + owner + ";")); + v.visitMethodInsn(Opcodes.INVOKESTATIC, owner + JvmAbi.TRAIT_IMPL_SUFFIX, getter.getName(), getter.getDescriptor().replace("(","(L" + owner + ";")); } else { if (getter == null) { @@ -770,7 +771,7 @@ public abstract class StackValue { @Override public void store(InstructionAdapter v) { if(isSuper && isInterface) { - v.visitMethodInsn(Opcodes.INVOKESTATIC, owner + "$$TImpl", setter.getName(), setter.getDescriptor().replace("(","(L" + owner + ";")); + v.visitMethodInsn(Opcodes.INVOKESTATIC, owner + JvmAbi.TRAIT_IMPL_SUFFIX, setter.getName(), setter.getDescriptor().replace("(","(L" + owner + ";")); } else { if (setter == null) { diff --git a/compiler/backend/src/org/jetbrains/jet/compiler/CompileEnvironment.java b/compiler/backend/src/org/jetbrains/jet/compiler/CompileEnvironment.java index 58b709b60b9..ae74afa756c 100644 --- a/compiler/backend/src/org/jetbrains/jet/compiler/CompileEnvironment.java +++ b/compiler/backend/src/org/jetbrains/jet/compiler/CompileEnvironment.java @@ -7,6 +7,9 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.Function; import com.intellij.util.Processor; +import jet.ExtensionFunction0; +import jet.ExtensionFunction10; +import jet.Function1; import jet.modules.IModuleBuilder; import jet.modules.IModuleSetBuilder; import org.jetbrains.annotations.Nullable; @@ -18,6 +21,7 @@ import org.jetbrains.jet.lang.psi.JetPsiUtil; import org.jetbrains.jet.plugin.JetMainDetector; import java.io.*; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; @@ -123,6 +127,11 @@ public class CompileEnvironment { if (rtJar.exists()) { return rtJar; } + + File classesJar = new File(new File(javaHome).getParentFile().getAbsolutePath(), "Classes/classes.jar"); + if (classesJar.exists()) { + return classesJar; + } return null; } @@ -193,17 +202,19 @@ public class CompileEnvironment { final IModuleSetBuilder moduleSetBuilder = (IModuleSetBuilder) moduleSetBuilderClass.newInstance(); Class namespaceClass = loader.loadClass("namespace"); - final Method[] methods = namespaceClass.getMethods(); + final Field[] fields = namespaceClass.getDeclaredFields(); boolean modulesDefined = false; - for (Method method : methods) { - if (method.getName().equals("defineModules")) { - method.invoke(null, moduleSetBuilder); + for (Field field : fields) { + if (field.getName().equals("modules")) { + field.setAccessible(true); + ExtensionFunction0 defineMudules = (ExtensionFunction0) field.get(null); + defineMudules.invoke(moduleSetBuilder); modulesDefined = true; break; } } if (!modulesDefined) { - throw new CompileEnvironmentException("Module script " + moduleFile + " must define a defineModules() method"); + throw new CompileEnvironmentException("Module script " + moduleFile + " must define a modules() property"); } return moduleSetBuilder; } catch (Exception e) { diff --git a/compiler/backend/src/org/jetbrains/jet/compiler/CompileSession.java b/compiler/backend/src/org/jetbrains/jet/compiler/CompileSession.java index f35ee3b07fe..9b4a3391cd2 100644 --- a/compiler/backend/src/org/jetbrains/jet/compiler/CompileSession.java +++ b/compiler/backend/src/org/jetbrains/jet/compiler/CompileSession.java @@ -37,6 +37,9 @@ public class CompileSession { } public void addSources(String path) { + if(path == null) + return; + VirtualFile vFile = myEnvironment.getLocalFileSystem().findFileByPath(path); if (vFile == null) { myErrors.add("File/directory not found: " + path); @@ -68,15 +71,15 @@ public class CompileSession { public void addSources(VirtualFile vFile) { if (vFile.isDirectory()) { for (VirtualFile virtualFile : vFile.getChildren()) { - if (virtualFile.getFileType() == JetFileType.INSTANCE) { - addSources(virtualFile); - } + addSources(virtualFile); } } else { - PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(vFile); - if (psiFile instanceof JetFile) { - mySourceFileNamespaces.add(((JetFile) psiFile).getRootNamespace()); + if (vFile.getFileType() == JetFileType.INSTANCE) { + PsiFile psiFile = PsiManager.getInstance(myEnvironment.getProject()).findFile(vFile); + if (psiFile instanceof JetFile) { + mySourceFileNamespaces.add(((JetFile) psiFile).getRootNamespace()); + } } } } @@ -121,8 +124,9 @@ public class CompileSession { else { final File runtimeJarPath = CompileEnvironment.getRuntimeJarPath(); if (runtimeJarPath != null && runtimeJarPath.exists()) { - // todo - throw new UnsupportedOperationException("Loading of stdlib sources from jar"); + VirtualFile runtimeJar = myEnvironment.getLocalFileSystem().findFileByPath(runtimeJarPath.getAbsolutePath()); + VirtualFile jarRoot = myEnvironment.getJarFileSystem().findFileByPath(runtimeJar.getPath() + "!/stdlib/ktSrc"); + addSources(jarRoot); } else { return false; diff --git a/compiler/backend/src/org/jetbrains/jet/compiler/TipsManager.java b/compiler/backend/src/org/jetbrains/jet/compiler/TipsManager.java new file mode 100644 index 00000000000..b105ef2a633 --- /dev/null +++ b/compiler/backend/src/org/jetbrains/jet/compiler/TipsManager.java @@ -0,0 +1,134 @@ +package org.jetbrains.jet.compiler; + +import com.google.common.base.Predicate; +import com.google.common.collect.Collections2; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; +import com.intellij.psi.PsiElement; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.CallableDescriptor; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; +import org.jetbrains.jet.lang.psi.JetExpression; +import org.jetbrains.jet.lang.psi.JetQualifiedExpression; +import org.jetbrains.jet.lang.psi.JetSimpleNameExpression; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintResolutionListener; +import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem; +import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl; +import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemSolution; +import org.jetbrains.jet.lang.resolve.scopes.JetScope; +import org.jetbrains.jet.lang.resolve.scopes.JetScopeUtils; +import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver; +import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; +import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.NamespaceType; +import org.jetbrains.jet.lang.types.Variance; + +import java.util.Collection; +import java.util.Collections; +import java.util.Set; + +import static org.jetbrains.jet.lang.resolve.calls.inference.ConstraintType.RECEIVER; + +/** + * @author Nikolay Krasko + */ +public final class TipsManager { + + private TipsManager() { + } + + @NotNull + public static Collection getReferenceVariants(JetSimpleNameExpression expression, BindingContext context) { + PsiElement parent = expression.getParent(); + if (parent instanceof JetQualifiedExpression) { + JetQualifiedExpression qualifiedExpression = (JetQualifiedExpression) parent; + JetExpression receiverExpression = qualifiedExpression.getReceiverExpression(); + + final JetType expressionType = context.get(BindingContext.EXPRESSION_TYPE, receiverExpression); + final JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, receiverExpression); + + if (expressionType != null && resolutionScope != null) { + return includeExternalCallableExtensions( + expressionType.getMemberScope().getAllDescriptors(), + resolutionScope, new ExpressionReceiver(receiverExpression, expressionType)); + } + } + else { + JetScope resolutionScope = context.get(BindingContext.RESOLUTION_SCOPE, expression); + if (resolutionScope != null) { + return excludeNotCallableExtensions(resolutionScope.getAllDescriptors(), resolutionScope); + } + } + + return Collections.emptyList(); + } + + private static Collection excludeNotCallableExtensions( + @NotNull Collection descriptors, @NotNull final JetScope scope + ) { + final Set descriptorsSet = Sets.newHashSet(descriptors); + + descriptorsSet.removeAll( + Collections2.filter(JetScopeUtils.getAllExtensions(scope), new Predicate() { + @Override + public boolean apply(CallableDescriptor callableDescriptor) { + return !checkReceiverResolution(scope.getImplicitReceiver(), callableDescriptor); + } + })); + + return Lists.newArrayList(descriptorsSet); + } + + private static Collection includeExternalCallableExtensions( + @NotNull Collection descriptors, + @NotNull final JetScope externalScope, + @NotNull final ReceiverDescriptor receiverDescriptor + ) { + // It's impossible to add extension function for namespace + if (receiverDescriptor.getType() instanceof NamespaceType) { + return descriptors; + } + + Set descriptorsSet = Sets.newHashSet(descriptors); + + descriptorsSet.addAll( + Collections2.filter(JetScopeUtils.getAllExtensions(externalScope), + new Predicate() { + @Override + public boolean apply(CallableDescriptor callableDescriptor) { + return checkReceiverResolution(receiverDescriptor, callableDescriptor); + } + })); + + return descriptorsSet; + } + + /* + * Checks if receiver declaration could be resolved to call expected receiver. + */ + private static boolean checkReceiverResolution ( + @NotNull ReceiverDescriptor expectedReceiver, + @NotNull CallableDescriptor receiverArgument + ) { + ConstraintSystem constraintSystem = new ConstraintSystemImpl(ConstraintResolutionListener.DO_NOTHING); + for (TypeParameterDescriptor typeParameterDescriptor : receiverArgument.getTypeParameters()) { + constraintSystem.registerTypeVariable(typeParameterDescriptor, Variance.INVARIANT); + } + + ReceiverDescriptor receiverParameter = receiverArgument.getReceiverParameter(); + if (expectedReceiver.exists() && receiverParameter.exists()) { + constraintSystem.addSubtypingConstraint( + RECEIVER.assertSubtyping(expectedReceiver.getType(), receiverParameter.getType())); + } + else if (expectedReceiver.exists() || receiverParameter.exists()) { + // Only one of receivers exist + return false; + } + + ConstraintSystemSolution solution = constraintSystem.solve(); + return solution.getStatus().isSuccessful(); + } + +} diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java index a66ada741f5..1753b072141 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaClassMembersScope.java @@ -104,7 +104,10 @@ public class JavaClassMembersScope implements JetScope { for (PsiClass innerClass : psiClass.getAllInnerClasses()) { if (name.equals(innerClass.getName())) { if (innerClass.hasModifierProperty(PsiModifier.STATIC) != staticMembers) return null; - return semanticServices.getDescriptorResolver().resolveClass(innerClass); + ClassDescriptor classDescriptor = semanticServices.getDescriptorResolver().resolveClass(innerClass); + if (classDescriptor != null) { + return classDescriptor; + } } } return null; diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java index 6948e7ac5fe..46dd32c5894 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaDescriptorResolver.java @@ -9,7 +9,6 @@ import com.intellij.psi.*; import com.intellij.psi.search.DelegatingGlobalSearchScope; import com.intellij.psi.search.GlobalSearchScope; import jet.typeinfo.TypeInfoVariance; -import org.eclipse.jdt.internal.core.JavaModelManager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; @@ -107,9 +106,14 @@ public class JavaDescriptorResolver { this.semanticServices = semanticServices; } - @NotNull + @Nullable public ClassDescriptor resolveClass(@NotNull PsiClass psiClass) { String qualifiedName = psiClass.getQualifiedName(); + + if (qualifiedName.endsWith(JvmAbi.TRAIT_IMPL_SUFFIX)) { + // TODO: only if -$$TImpl class is created by Kotlin + return null; + } // First, let's check that this is a real Java class, not a Java's view on a Kotlin class: ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(qualifiedName); @@ -128,6 +132,12 @@ public class JavaDescriptorResolver { @Nullable public ClassDescriptor resolveClass(@NotNull String qualifiedName) { + + if (qualifiedName.endsWith(JvmAbi.TRAIT_IMPL_SUFFIX)) { + // TODO: only if -$$TImpl class is created by Kotlin + return null; + } + // First, let's check that this is a real Java class, not a Java's view on a Kotlin class: ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(qualifiedName); if (kotlinClassDescriptor != null) { @@ -234,8 +244,8 @@ public class JavaDescriptorResolver { private List resolveClassTypeParameters(PsiClass psiClass, JavaClassDescriptor classDescriptor) { for (PsiAnnotation annotation : psiClass.getModifierList().getAnnotations()) { - if (annotation.getQualifiedName().equals(StdlibNames.JET_CLASS.getFqName())) { - PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_CLASS_SIGNATURE); + if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_CLASS.getFqName())) { + PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_CLASS_SIGNATURE); if (attributeValue != null) { String typeParametersString = (String) attributeValue.getValue(); if (typeParametersString != null) { @@ -608,18 +618,19 @@ public class JavaDescriptorResolver { String typeFromAnnotation = null; boolean receiver = false; + boolean hasDefaultValue = false; // TODO: must be very slow, make it lazy? String name = parameter.getName() != null ? parameter.getName() : "p" + i; for (PsiAnnotation annotation : parameter.getModifierList().getAnnotations()) { - if (annotation.getQualifiedName().equals(StdlibNames.JET_VALUE_PARAMETER.getFqName())) { - PsiLiteralExpression nameExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_VALUE_PARAMETER_NAME_FIELD); + if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_VALUE_PARAMETER.getFqName())) { + PsiLiteralExpression nameExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_NAME_FIELD); if (nameExpression != null) { name = (String) nameExpression.getValue(); } - PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD); + PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_NULLABLE_FIELD); if (nullableExpression != null) { nullable = (Boolean) nullableExpression.getValue(); } else { @@ -628,25 +639,30 @@ public class JavaDescriptorResolver { changeNullable = true; } - PsiLiteralExpression signatureExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD); + PsiLiteralExpression signatureExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_TYPE_FIELD); if (signatureExpression != null) { typeFromAnnotation = (String) signatureExpression.getValue(); } - PsiLiteralExpression receiverExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD); + PsiLiteralExpression receiverExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_RECEIVER_FIELD); if (receiverExpression != null) { - receiver = true; + receiver = (Boolean) receiverExpression.getValue(); + } + + PsiLiteralExpression hasDefaultValueExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_VALUE_PARAMETER_HAS_DEFAULT_VALUE_FIELD); + if (hasDefaultValueExpression != null) { + hasDefaultValue = (Boolean) hasDefaultValueExpression.getValue(); } - } else if (annotation.getQualifiedName().equals(StdlibNames.JET_TYPE_PARAMETER.getFqName())) { + } else if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_TYPE_PARAMETER.getFqName())) { return JvmMethodParameterMeaning.typeInfo(new Object()); } } JetType outType; - if (typeFromAnnotation != null) { + if (typeFromAnnotation != null && typeFromAnnotation.length() > 0) { outType = semanticServices.getTypeTransformer().transformToType(typeFromAnnotation); } else { outType = semanticServices.getTypeTransformer().transformToType(psiType); @@ -661,7 +677,7 @@ public class JavaDescriptorResolver { name, null, // TODO : review changeNullable ? TypeUtils.makeNullableAsSpecified(outType, nullable) : outType, - false, + hasDefaultValue, varargElementType )); } @@ -748,6 +764,9 @@ public class JavaDescriptorResolver { return functionDescriptor; } DeclarationDescriptor classDescriptor = method.hasModifierProperty(PsiModifier.STATIC) ? resolveNamespace(method.getContainingClass()) : resolveClass(method.getContainingClass()); + if (classDescriptor == null) { + return null; + } PsiParameter[] parameters = method.getParameterList().getParameters(); FunctionDescriptorImpl functionDescriptorImpl = new FunctionDescriptorImpl( owner, @@ -776,8 +795,8 @@ public class JavaDescriptorResolver { private List resolveMethodTypeParameters(PsiMethod method, FunctionDescriptorImpl functionDescriptorImpl) { for (PsiAnnotation annotation : method.getModifierList().getAnnotations()) { - if (annotation.getQualifiedName().equals(StdlibNames.JET_METHOD.getFqName())) { - PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD); + if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_METHOD.getFqName())) { + PsiLiteralExpression attributeValue = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_METHOD_TYPE_PARAMETERS_FIELD); if (attributeValue != null) { String typeParametersString = (String) attributeValue.getValue(); if (typeParametersString != null) { @@ -822,8 +841,8 @@ public class JavaDescriptorResolver { String returnTypeFromAnnotation = null; for (PsiAnnotation annotation : method.getModifierList().getAnnotations()) { - if (annotation.getQualifiedName().equals(StdlibNames.JET_METHOD.getFqName())) { - PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD); + if (annotation.getQualifiedName().equals(JvmStdlibNames.JET_METHOD.getFqName())) { + PsiLiteralExpression nullableExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_METHOD_NULLABLE_RETURN_TYPE_FIELD); if (nullableExpression != null) { nullable = (Boolean) nullableExpression.getValue(); } else { @@ -832,14 +851,14 @@ public class JavaDescriptorResolver { changeNullable = true; } - PsiLiteralExpression returnTypeExpression = (PsiLiteralExpression) annotation.findAttributeValue(StdlibNames.JET_METHOD_RETURN_TYPE_FIELD); + PsiLiteralExpression returnTypeExpression = (PsiLiteralExpression) annotation.findAttributeValue(JvmStdlibNames.JET_METHOD_RETURN_TYPE_FIELD); if (returnTypeExpression != null) { returnTypeFromAnnotation = (String) returnTypeExpression.getValue(); } } } JetType transformedType; - if (returnTypeFromAnnotation != null) { + if (returnTypeFromAnnotation != null && returnTypeFromAnnotation.length() > 0) { transformedType = semanticServices.getTypeTransformer().transformToType(returnTypeFromAnnotation); } else { transformedType = semanticServices.getTypeTransformer().transformToType(returnType); diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java index 098b8ec6bdf..45613dcb978 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaPackageScope.java @@ -94,7 +94,10 @@ public class JavaPackageScope extends JetScopeImpl { } if (psiClass.hasModifierProperty(PsiModifier.PUBLIC)) { - allDescriptors.add(descriptorResolver.resolveClass(psiClass)); + ClassDescriptor classDescriptor = descriptorResolver.resolveClass(psiClass); + if (classDescriptor != null) { + allDescriptors.add(classDescriptor); + } } } } diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.java index 4aed6ee493d..fde7a02232c 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JavaTypeTransformer.java @@ -94,6 +94,9 @@ public class JavaTypeTransformer { } ClassDescriptor descriptor = resolver.resolveClass(psiClass); + if (descriptor == null) { + return ErrorUtils.createErrorType("Unresolve java class: " + classType.getPresentableText()); + } List arguments = Lists.newArrayList(); if (classType.isRaw()) { diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader.java index 64bf4d30633..ec5b1b2a7ee 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JetTypeJetSignatureReader.java @@ -1,17 +1,18 @@ package org.jetbrains.jet.lang.resolve.java; -import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.rt.signature.JetSignatureVisitor; import org.jetbrains.jet.lang.types.ErrorUtils; import org.jetbrains.jet.lang.types.JetStandardClasses; import org.jetbrains.jet.lang.types.JetStandardLibrary; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetTypeImpl; import org.jetbrains.jet.lang.types.TypeProjection; +import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.Variance; +import org.jetbrains.jet.rt.signature.JetSignatureExceptionsAdapter; +import org.jetbrains.jet.rt.signature.JetSignatureVisitor; import java.util.ArrayList; import java.util.Collections; @@ -119,6 +120,23 @@ public abstract class JetTypeJetSignatureReader extends JetSignatureExceptionsAd }; } + @Override + public JetSignatureVisitor visitArrayType(final boolean nullable) { + return new JetTypeJetSignatureReader(javaDescriptorResolver, jetStandardLibrary) { + @Override + protected void done(@NotNull JetType jetType) { + JetType arrayType = TypeUtils.makeNullableAsSpecified(jetStandardLibrary.getArrayType(jetType), nullable); + JetTypeJetSignatureReader.this.done(arrayType); + } + }; + } + + @Override + public void visitTypeVariable(String name, boolean nullable) { + // TODO: need a way to get type TypeParameterDescriptor by name + throw new IllegalStateException(); + } + @Override public void visitEnd() { JetType jetType = new JetTypeImpl( diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java new file mode 100644 index 00000000000..0cb5f676a08 --- /dev/null +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmAbi.java @@ -0,0 +1,9 @@ +package org.jetbrains.jet.lang.resolve.java; + +/** + * @author Stepan Koltsov + */ +public class JvmAbi { + public static final String TRAIT_IMPL_SUFFIX = "$$TImpl"; + public static final String DEFAULT_PARAMS_IMPL_SUFFIX = "$default"; +} diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/StdlibNames.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmStdlibNames.java similarity index 95% rename from compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/StdlibNames.java rename to compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmStdlibNames.java index 285ffe54b3c..f94405a8214 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/StdlibNames.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/JvmStdlibNames.java @@ -5,7 +5,7 @@ import org.objectweb.asm.Type; /** * @author Stepan Koltsov */ -public class StdlibNames { +public class JvmStdlibNames { public static final JvmClassName JET_VALUE_PARAMETER = new JvmClassName("jet.typeinfo.JetValueParameter"); @@ -36,6 +36,6 @@ public class StdlibNames { public static final JvmClassName JET_OBJECT = new JvmClassName("jet.JetObject"); - private StdlibNames() { + private JvmStdlibNames() { } } diff --git a/compiler/frontend/src/jet/Library.jet b/compiler/frontend/src/jet/Library.jet index c54b0d2c49e..e6a78e088a5 100644 --- a/compiler/frontend/src/jet/Library.jet +++ b/compiler/frontend/src/jet/Library.jet @@ -1,6 +1,6 @@ -namespace jet +package jet -namespace typeinfo { +package typeinfo { class TypeInfo { fun isSubtypeOf(other : TypeInfo<*>) : Boolean fun isInstance(obj : Any?) : Boolean @@ -10,7 +10,7 @@ namespace typeinfo { fun typeinfo(expression : T) : TypeInfo } -namespace io { +package io { fun print(message : Any?) fun print(message : Int) fun print(message : Long) @@ -34,7 +34,7 @@ namespace io { fun readLine() : String? } -fun Any.synchronized(block : fun() : R) : R +fun Any.synchronized(block : () -> R) : R fun Any?.identityEquals(other : Any?) : Boolean // = this === other @@ -139,7 +139,7 @@ trait CharIterable : Iterable { fun Array(val size : Int) : Array -class Array(val size : Int, init : fun(Int) : T) { +class Array(val size : Int, init : (Int) -> T) { fun get(index : Int) : T fun set(index : Int, value : T) : Unit diff --git a/compiler/frontend/src/org/jetbrains/jet/JetCoreEnvironment.java b/compiler/frontend/src/org/jetbrains/jet/JetCoreEnvironment.java index 65218c54fcf..1b2e2c12e66 100644 --- a/compiler/frontend/src/org/jetbrains/jet/JetCoreEnvironment.java +++ b/compiler/frontend/src/org/jetbrains/jet/JetCoreEnvironment.java @@ -2,6 +2,7 @@ package org.jetbrains.jet; import com.intellij.core.JavaCoreEnvironment; import com.intellij.lang.java.JavaParserDefinition; +import com.intellij.mock.MockApplication; import com.intellij.openapi.Disposable; import org.jetbrains.jet.lang.parsing.JetParserDefinition; import org.jetbrains.jet.plugin.JetFileType; @@ -19,4 +20,8 @@ public class JetCoreEnvironment extends JavaCoreEnvironment { registerParserDefinition(new JavaParserDefinition()); registerParserDefinition(new JetParserDefinition()); } + + public MockApplication getApplication() { + return myApplication; + } } 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 8844d181e69..0c55185fe81 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java @@ -18,7 +18,7 @@ import static org.jetbrains.jet.lexer.JetTokens.*; */ public class JetExpressionParsing extends AbstractJetParsing { private static final TokenSet WHEN_CONDITION_RECOVERY_SET = TokenSet.create(RBRACE, IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS, ELSE_KEYWORD); - private static final TokenSet WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW = TokenSet.create(RBRACE, IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS, ELSE_KEYWORD, DOUBLE_ARROW, DOT); + private static final TokenSet WHEN_CONDITION_RECOVERY_SET_WITH_ARROW = TokenSet.create(RBRACE, IN_KEYWORD, NOT_IN, IS_KEYWORD, NOT_IS, ELSE_KEYWORD, ARROW, DOT); private static final ImmutableMap KEYWORD_TEXTS = tokenSetToMap(KEYWORDS); @@ -38,8 +38,8 @@ public class JetExpressionParsing extends AbstractJetParsing { CONTINUE_KEYWORD, OBJECT_KEYWORD, IF_KEYWORD, TRY_KEYWORD, ELSE_KEYWORD, WHILE_KEYWORD, DO_KEYWORD, WHEN_KEYWORD, RBRACKET, RBRACE, RPAR, PLUSPLUS, MINUSMINUS, MUL, PLUS, MINUS, EXCL, DIV, PERC, LTEQ, // TODO GTEQ, foo=x - EQEQEQ, ARROW, DOUBLE_ARROW, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, SAFE_ACCESS, ELVIS, - SEMICOLON, RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ, NOT_IN, NOT_IS, HASH, + EQEQEQ, ARROW, ARROW, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, SAFE_ACCESS, ELVIS, + SEMICOLON, RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ, NOT_IN, NOT_IS, //HASH, COLON ); @@ -49,6 +49,7 @@ public class JetExpressionParsing extends AbstractJetParsing { // Atomic LPAR, // parenthesized + HASH, // Tuple // literal constant TRUE_KEYWORD, FALSE_KEYWORD, @@ -100,13 +101,14 @@ public class JetExpressionParsing extends AbstractJetParsing { ); /*package*/ static final TokenSet EXPRESSION_FOLLOW = TokenSet.create( - SEMICOLON, DOUBLE_ARROW, COMMA, RBRACE, RPAR, RBRACKET + SEMICOLON, ARROW, COMMA, RBRACE, RPAR, RBRACKET ); @SuppressWarnings({"UnusedDeclaration"}) private enum Precedence { POSTFIX(PLUSPLUS, MINUSMINUS, - HASH, DOT, SAFE_ACCESS, QUEST), // typeArguments? valueArguments : typeArguments : arrayAccess +// HASH, + DOT, SAFE_ACCESS, QUEST), // typeArguments? valueArguments : typeArguments : arrayAccess PREFIX(MINUS, PLUS, MINUSMINUS, PLUSPLUS, EXCL, LABEL_IDENTIFIER, AT, ATAT) { // attributes @@ -150,7 +152,7 @@ public class JetExpressionParsing extends AbstractJetParsing { EQUALITY(EQEQ, EXCLEQ, EQEQEQ, EXCLEQEQEQ), CONJUNCTION(ANDAND), DISJUNCTION(OROR), - ARROW(JetTokens.ARROW), +// ARROW(JetTokens.ARROW), ASSIGNMENT(EQ, PLUSEQ, MINUSEQ, MULTEQ, DIVEQ, PERCEQ), ; @@ -374,13 +376,13 @@ public class JetExpressionParsing extends AbstractJetParsing { expression.done(PREDICATE_EXPRESSION); } - else if (at(HASH)) { - advance(); // HASH - - expect(IDENTIFIER, "Expecting property or function name"); - - expression.done(HASH_QUALIFIED_EXPRESSION); - } +// else if (at(HASH)) { +// advance(); // HASH +// +// expect(IDENTIFIER, "Expecting property or function name"); +// +// expression.done(HASH_QUALIFIED_EXPRESSION); +// } else if (atSet(Precedence.POSTFIX.getOperations())) { parseOperationReference(); expression.done(POSTFIX_EXPRESSION); @@ -502,7 +504,10 @@ public class JetExpressionParsing extends AbstractJetParsing { // System.out.println("atom at " + myBuilder.getTokenText()); if (at(LPAR)) { - parseParenthesizedExpressionOrTuple(); + parseParenthesizedExpression(); + } + else if (at(HASH)) { + parseTupleExpression(); } else if (at(NAMESPACE_KEYWORD)) { parseOneTokenExpression(ROOT_NAMESPACE); @@ -756,13 +761,13 @@ public class JetExpressionParsing extends AbstractJetParsing { if (at(ELSE_KEYWORD)) { advance(); // ELSE_KEYWORD - if (!at(DOUBLE_ARROW)) { - errorUntil("Expecting '=>'", TokenSet.create(DOUBLE_ARROW, + if (!at(ARROW)) { + errorUntil("Expecting '=>'", TokenSet.create(ARROW, RBRACE, EOL_OR_SEMICOLON)); } - if (at(DOUBLE_ARROW)) { - advance(); // DOUBLE_ARROW + if (at(ARROW)) { + advance(); // ARROW if (atSet(WHEN_CONDITION_RECOVERY_SET)) { error("Expecting an element"); @@ -790,7 +795,7 @@ public class JetExpressionParsing extends AbstractJetParsing { if (!at(COMMA)) break; advance(); // COMMA } - expect(DOUBLE_ARROW, "Expecting '=>' or 'when'", WHEN_CONDITION_RECOVERY_SET); + expect(ARROW, "Expecting '->' or 'when'", WHEN_CONDITION_RECOVERY_SET); if (atSet(WHEN_CONDITION_RECOVERY_SET)) { error("Expecting an element"); } else { @@ -815,7 +820,7 @@ public class JetExpressionParsing extends AbstractJetParsing { mark.done(OPERATION_REFERENCE); - if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW)) { + if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_ARROW)) { error("Expecting an element"); } else { parseExpression(); @@ -824,7 +829,7 @@ public class JetExpressionParsing extends AbstractJetParsing { } else if (at(IS_KEYWORD) || at(NOT_IS)) { advance(); // IS_KEYWORD or NOT_IS - if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW)) { + if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_ARROW)) { error("Expecting a type or a decomposer pattern"); } else { parsePattern(); @@ -832,7 +837,7 @@ public class JetExpressionParsing extends AbstractJetParsing { condition.done(WHEN_CONDITION_IS_PATTERN); } else { PsiBuilder.Marker expressionPattern = mark(); - if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_DOUBLE_ARROW)) { + if (atSet(WHEN_CONDITION_RECOVERY_SET_WITH_ARROW)) { error("Expecting an expression, is-condition or in-condition"); } else { parseExpression(); @@ -863,9 +868,8 @@ public class JetExpressionParsing extends AbstractJetParsing { if (at(NAMESPACE_KEYWORD) || at(IDENTIFIER) || at(FUN_KEYWORD) || at(THIS_KEYWORD)) { PsiBuilder.Marker rollbackMarker = mark(); parseBinaryExpression(Precedence.ELVIS); - if (at(AT)) { + if (at(HASH)) { rollbackMarker.drop(); - advance(); // AT PsiBuilder.Marker list = mark(); parseTuplePattern(DECOMPOSER_ARGUMENT); list.done(DECOMPOSER_ARGUMENT_LIST); @@ -877,9 +881,9 @@ public class JetExpressionParsing extends AbstractJetParsing { rollbackMarker = mark(); myJetParsing.parseTypeRef(); - if (at(AT)) { - errorAndAdvance("'@' is allowed only after a decomposer element, not after a type"); - } +// if (at(AT)) { +// errorAndAdvance("'@' is allowed only after a decomposer element, not after a type"); +// } if (myBuilder.getCurrentOffset() < expressionEndOffset) { rollbackMarker.rollbackTo(); parseBinaryExpression(Precedence.ELVIS); @@ -889,7 +893,7 @@ public class JetExpressionParsing extends AbstractJetParsing { pattern.done(TYPE_PATTERN); } } - } else if (at(LPAR)) { + } else if (at(HASH)) { parseTuplePattern(TUPLE_PATTERN_ENTRY); pattern.done(TUPLE_PATTERN); } @@ -905,20 +909,21 @@ public class JetExpressionParsing extends AbstractJetParsing { } else if (parseLiteralConstant()) { pattern.done(EXPRESSION_PATTERN); } else { - errorUntil("Pattern expected", TokenSet.create(RBRACE, DOUBLE_ARROW)); + errorUntil("Pattern expected", TokenSet.create(RBRACE, ARROW)); pattern.drop(); } } /* * tuplePattern - * : "(" ((SimpleName "=")? pattern){","}? ")" + * : "#" "(" ((SimpleName "=")? pattern){","}? ")" * ; */ private void parseTuplePattern(JetNodeType entryType) { myBuilder.disableNewlines(); - expect(LPAR, "Expecting '('", getDecomposerExpressionFollow()); + expect(HASH, "Expecting a tuple pattern of the form '#(...)'", getDecomposerExpressionFollow()); + expect(LPAR, "Expecting a tuple pattern of the form '#(...)'", getDecomposerExpressionFollow()); if (!at(RPAR)) { while (true) { @@ -1059,8 +1064,8 @@ public class JetExpressionParsing extends AbstractJetParsing { /* * functionLiteral // one can use "it" as a parameter name * : "{" expressions "}" - * : "{" (modifiers SimpleName){","} "=>" statements "}" - * : "{" (type ".")? "(" (modifiers SimpleName (":" type)?){","} ")" (":" type)? "=>" expressions "}" + * : "{" (modifiers SimpleName){","} "->" statements "}" + * : "{" (type ".")? "(" (modifiers SimpleName (":" type)?){","} ")" (":" type)? "->" expressions "}" * ; */ private void parseFunctionLiteral() { @@ -1077,83 +1082,112 @@ public class JetExpressionParsing extends AbstractJetParsing { myBuilder.enableNewlines(); advance(); // LBRACE - int doubleArrowPos = matchTokenStreamPredicate(new FirstBefore(new At(DOUBLE_ARROW), new At(RBRACE)) { - @Override - public boolean isTopLevel(int openAngleBrackets, int openBrackets, int openBraces, int openParentheses) { - return openBraces == 0; + boolean paramsFound = false; + + if (at(ARROW)) { + // { -> ...} + advance(); // ARROW + mark().done(VALUE_PARAMETER_LIST); + paramsFound = true; + } + else if (at(LPAR)) { + // Look for ARROW after matching RPAR + // {(a, b) -> ...} + + { + PsiBuilder.Marker rollbackMarker = mark(); + + parseFunctionLiteralParametersAndType(); + + paramsFound = rollbackOrDropAt(rollbackMarker, ARROW); } - }); - boolean doubleArrowPresent = doubleArrowPos >= 0; - if (doubleArrowPresent) { - boolean dontExpectParameters = false; - - int lastDot = matchTokenStreamPredicate(new LastBefore(new At(DOT), new AtOffset(doubleArrowPos))); - if (lastDot >= 0) { // There is a receiver type - createTruncatedBuilder(lastDot).parseTypeRef(); - - expect(DOT, "Expecting '.'"); - - if (!at(LPAR)) { - int firstLParPos = matchTokenStreamPredicate(new FirstBefore(new At(LPAR), new AtOffset(doubleArrowPos))); - - if (firstLParPos >= 0) { - errorUntilOffset("Expecting '('", firstLParPos); - } else { - errorUntilOffset("To specify a receiver type, use the full notation: {ReceiverType.(parameters) [: ReturnType] => ...}", - doubleArrowPos); - dontExpectParameters = true; + if (!paramsFound) { + // If not found, try a typeRef DOT and then LPAR .. RPAR ARROW + // {((A) -> B).(x) -> ... } + PsiBuilder.Marker rollbackMarker = mark(); + int lastDot = matchTokenStreamPredicate(new LastBefore(new At(DOT), new AtSet(ARROW, RPAR))); + if (lastDot >= 0) { + createTruncatedBuilder(lastDot).parseTypeRef(); + if (at(DOT)) { + advance(); // DOT + parseFunctionLiteralParametersAndType(); } } + paramsFound = rollbackOrDropAt(rollbackMarker, ARROW); } - - if (at(LPAR)) { - parseFunctionLiteralParameterList(); - - if (at(COLON)) { - advance(); // COLON - if (at(DOUBLE_ARROW)) { - error("Expecting a type"); - } - else { - myJetParsing.parseTypeRef(); - } - } - } - else if (!dontExpectParameters) { - PsiBuilder.Marker parameterList = mark(); - - while (!eof()) { - PsiBuilder.Marker parameter = mark(); - - int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtOffset(doubleArrowPos))); - createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, false); - - expect(IDENTIFIER, "Expecting parameter name", TokenSet.create(DOUBLE_ARROW)); - - parameter.done(VALUE_PARAMETER); - - if (at(COLON)) { - errorUntilOffset("To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType => ...}", doubleArrowPos); - } - else if (at(DOUBLE_ARROW)) { - break; - } - else if (!at(COMMA)) { - errorUntilOffset("Expecting '=>' or ','", doubleArrowPos); - } - else { - advance(); // COMMA - } - } - - parameterList.done(VALUE_PARAMETER_LIST); - } - - expectNoAdvance(DOUBLE_ARROW, "Expecting '=>'"); } else { + if (at(IDENTIFIER)) { + // Try to parse a simple name list followed by an ARROW + // {a -> ...} + // {a, b -> ...} + PsiBuilder.Marker rollbackMarker = mark(); + parseFunctionLiteralShorthandParameterList(); + parseOptionalFunctionLiteralType(); + paramsFound = rollbackOrDropAt(rollbackMarker, ARROW); + } + if (!paramsFound && atSet(JetParsing.TYPE_REF_FIRST)) { + // Try to parse a type DOT valueParameterList ARROW + // {A.(b) -> ...} + PsiBuilder.Marker rollbackMarker = mark(); + int lastDot = matchTokenStreamPredicate(new LastBefore(new At(DOT), new AtSet(ARROW, RBRACE))); + if (lastDot >= 0) { // There is a receiver type + createTruncatedBuilder(lastDot).parseTypeRef(); + } + + if (at(DOT)) { + advance(); // DOT + parseFunctionLiteralParametersAndType(); + paramsFound = rollbackOrDropAt(rollbackMarker, ARROW); + } + else { + rollbackMarker.rollbackTo(); + } + } +// int doubleArrowPos = matchTokenStreamPredicate(new FirstBefore(new At(ARROW), new At(RBRACE)) { +// @Override +// public boolean isTopLevel(int openAngleBrackets, int openBrackets, int openBraces, int openParentheses) { +// return openBraces == 0; +// } +// }); +// +// boolean doubleArrowPresent = doubleArrowPos >= 0; +// if (doubleArrowPresent) { +// boolean dontExpectParameters = false; +// +// int lastDot = matchTokenStreamPredicate(new LastBefore(new At(DOT), new AtOffset(doubleArrowPos))); +// if (lastDot >= 0) { // There is a receiver type +// createTruncatedBuilder(lastDot).parseTypeRef(); +// +// expect(DOT, "Expecting '.'"); +// +// if (!at(LPAR)) { +// int firstLParPos = matchTokenStreamPredicate(new FirstBefore(new At(LPAR), new AtOffset(doubleArrowPos))); +// +// if (firstLParPos >= 0) { +// errorUntilOffset("Expecting '('", firstLParPos); +// } else { +// errorUntilOffset("To specify a receiver type, use the full notation: {ReceiverType.(parameters) [: ReturnType] => ...}", +// doubleArrowPos); +// dontExpectParameters = true; +// } +// } +// +// } +// +// if (at(LPAR)) { +// parseFunctionLiteralParametersAndType(); +// } +// else if (!dontExpectParameters) { +// parseFunctionLiteralShorthandParameterList(); +// } +// +// expectNoAdvance(ARROW, "Expecting '=>'"); +// } + } + if (!paramsFound) { if (preferBlock) { literal.drop(); parseStatements(); @@ -1175,12 +1209,80 @@ public class JetExpressionParsing extends AbstractJetParsing { literalExpression.done(FUNCTION_LITERAL_EXPRESSION); } + private boolean rollbackOrDropAt(PsiBuilder.Marker rollbackMarker, IElementType dropAt) { + if (at(dropAt)) { + advance(); // dropAt + rollbackMarker.drop(); + return true; + } + rollbackMarker.rollbackTo(); + return false; + } + + /* + * SimpleName{,} + */ + private void parseFunctionLiteralShorthandParameterList() { + PsiBuilder.Marker parameterList = mark(); + + while (!eof()) { + PsiBuilder.Marker parameter = mark(); + +// int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtOffset(doubleArrowPos))); +// createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, false); + + expect(IDENTIFIER, "Expecting parameter name", TokenSet.create(ARROW)); + + parameter.done(VALUE_PARAMETER); + + if (at(COLON)) { + PsiBuilder.Marker errorMarker = mark(); + advance(); // COLON + myJetParsing.parseTypeRef(); + errorMarker.error("To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType => ...}"); + } + else if (at(ARROW)) { + break; + } + else if (at(COMMA)) { + advance(); // COMMA + } + else { + error("Expecting '->' or ','"); + break; + } + } + + parameterList.done(VALUE_PARAMETER_LIST); + } + + private void parseFunctionLiteralParametersAndType() { + parseFunctionLiteralParameterList(); + + parseOptionalFunctionLiteralType(); + } + + /* + * (":" type)? + */ + private void parseOptionalFunctionLiteralType() { + if (at(COLON)) { + advance(); // COLON + if (at(ARROW)) { + error("Expecting a type"); + } + else { + myJetParsing.parseTypeRef(); + } + } + } + /* * "(" (modifiers SimpleName (":" type)?){","} ")" */ private void parseFunctionLiteralParameterList() { PsiBuilder.Marker list = mark(); - expect(LPAR, "Expecting a parameter list in parentheses (...)", TokenSet.create(DOUBLE_ARROW, COLON)); + expect(LPAR, "Expecting a parameter list in parentheses (...)", TokenSet.create(ARROW, COLON)); myBuilder.disableNewlines(); @@ -1189,7 +1291,7 @@ public class JetExpressionParsing extends AbstractJetParsing { if (at(COMMA)) errorAndAdvance("Expecting a parameter declaration"); PsiBuilder.Marker parameter = mark(); - int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtSet(COMMA, RPAR, COLON, DOUBLE_ARROW))); + int parameterNamePos = matchTokenStreamPredicate(new LastBefore(new At(IDENTIFIER), new AtSet(COMMA, RPAR, COLON, ARROW))); createTruncatedBuilder(parameterNamePos).parseModifierList(MODIFIER_LIST, false); expect(IDENTIFIER, "Expecting parameter declaration"); @@ -1211,7 +1313,7 @@ public class JetExpressionParsing extends AbstractJetParsing { myBuilder.restoreNewlinesState(); - expect(RPAR, "Expecting ')", TokenSet.create(DOUBLE_ARROW, COLON)); + expect(RPAR, "Expecting ')", TokenSet.create(ARROW, COLON)); list.done(VALUE_PARAMETER_LIST); } @@ -1567,29 +1669,43 @@ public class JetExpressionParsing extends AbstractJetParsing { } /* - * tupleLiteral // Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an element in parentheses - * // to put a tuple, write write ((e)) - * : "(" ((SimpleName "=")? element){","} ")" - * ; - * - * element - * : "(" element ")" - * ; - * - * TODO: duplication with valueArguments (but for the error messages) + * "(" expression ")" */ - private void parseParenthesizedExpressionOrTuple() { + private void parseParenthesizedExpression() { assert _at(LPAR); PsiBuilder.Marker mark = mark(); myBuilder.disableNewlines(); advance(); // LPAR - boolean tuple = false; + if (at(RPAR)) { + error("Expecting an expression"); + } + else { + parseExpression(); + } + + expect(RPAR, "Expecting ')'"); + myBuilder.restoreNewlinesState(); + + mark.done(PARENTHESIZED); + } + + /* + * tupleLiteral + * : "#" "(" (((SimpleName "=")? expression){","})? ")" + * ; + */ + private void parseTupleExpression() { + assert _at(HASH); + PsiBuilder.Marker mark = mark(); + + advance(); // HASH + advance(); // LPAR + myBuilder.disableNewlines(); if (!at(RPAR)) { while (true) { while (at(COMMA)) { - tuple = true; errorAndAdvance("Expecting a tuple entry (element)"); } @@ -1597,7 +1713,6 @@ public class JetExpressionParsing extends AbstractJetParsing { PsiBuilder.Marker entry = mark(); advance(); // IDENTIFIER advance(); // EQ - tuple = true; parseExpression(); entry.done(LABELED_TUPLE_ENTRY); } else { @@ -1606,21 +1721,18 @@ public class JetExpressionParsing extends AbstractJetParsing { if (!at(COMMA)) break; advance(); // COMMA - tuple = true; if (at(RPAR)) { error("Expecting a tuple entry (element)"); break; } } - } else { - tuple = true; - } + } expect(RPAR, "Expecting ')'"); myBuilder.restoreNewlinesState(); - mark.done(tuple ? TUPLE : PARENTHESIZED); + mark.done(TUPLE); } /* diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java index 479849c88c7..cf12d7e12b5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java @@ -37,7 +37,7 @@ public class JetParsing extends AbstractJetParsing { private static final TokenSet TYPE_PARAMETER_GT_RECOVERY_SET = TokenSet.create(WHERE_KEYWORD, LPAR, COLON, LBRACE, GT); private static final TokenSet PARAMETER_NAME_RECOVERY_SET = TokenSet.create(COLON, EQ, COMMA, RPAR); private static final TokenSet NAMESPACE_NAME_RECOVERY_SET = TokenSet.create(DOT, EOL_OR_SEMICOLON); - /*package*/ static final TokenSet TYPE_REF_FIRST = TokenSet.create(LBRACKET, IDENTIFIER, FUN_KEYWORD, LPAR, CAPITALIZED_THIS_KEYWORD); + /*package*/ static final TokenSet TYPE_REF_FIRST = TokenSet.create(LBRACKET, IDENTIFIER, FUN_KEYWORD, LPAR, CAPITALIZED_THIS_KEYWORD, HASH); private static final TokenSet RECEIVER_TYPE_TERMINATORS = TokenSet.create(DOT, SAFE_ACCESS); public static JetParsing createForTopLevel(SemanticWhitespaceAwarePsiBuilder builder) { @@ -826,12 +826,12 @@ public class JetParsing extends AbstractJetParsing { boolean typeParametersDeclared = at(LT) ? parseTypeParameterList(TokenSet.create(IDENTIFIER, EQ, COLON, SEMICOLON)) : false; - TokenSet propertyNameFollow = TokenSet.create(COLON, EQ, LBRACE, SEMICOLON); + TokenSet propertyNameFollow = TokenSet.create(COLON, EQ, LBRACE, SEMICOLON, VAL_KEYWORD, VAR_KEYWORD, FUN_KEYWORD, CLASS_KEYWORD); myBuilder.disableJoiningComplexTokens(); // TODO: extract constant - int lastDot = matchTokenStreamPredicate(new FirstBefore( + int lastDot = matchTokenStreamPredicate(new LastBefore( new AtSet(DOT, SAFE_ACCESS), new AbstractTokenStreamPredicate() { @Override @@ -847,7 +847,7 @@ public class JetParsing extends AbstractJetParsing { parseReceiverType("property", propertyNameFollow, lastDot); - myBuilder.enableJoiningComplexTokens(); + myBuilder.restoreJoiningComplexTokensState(); if (at(COLON)) { advance(); // COLON @@ -985,7 +985,7 @@ public class JetParsing extends AbstractJetParsing { myBuilder.disableJoiningComplexTokens(); int lastDot = findLastBefore(RECEIVER_TYPE_TERMINATORS, TokenSet.create(LPAR), true); parseReceiverType("function", TokenSet.create(LT, LPAR, COLON, EQ), lastDot); - myBuilder.enableJoiningComplexTokens(); + myBuilder.restoreJoiningComplexTokensState(); TokenSet valueParametersFollow = TokenSet.create(COLON, EQ, LBRACE, SEMICOLON, RPAR); @@ -1281,17 +1281,54 @@ public class JetParsing extends AbstractJetParsing { * : typeDescriptor "?" */ public void parseTypeRef() { + PsiBuilder.Marker typeRefMarker = parseTypeRefContents(); + typeRefMarker.done(TYPE_REFERENCE); + } + + private PsiBuilder.Marker parseTypeRefContents() { + // Disabling token merge is required for cases like + // Int?.(Foo) -> Bar + // we don't support this case now +// myBuilder.disableJoiningComplexTokens(); PsiBuilder.Marker typeRefMarker = mark(); parseAnnotations(false); if (at(IDENTIFIER) || at(NAMESPACE_KEYWORD)) { parseUserType(); } - else if (at(FUN_KEYWORD)) { - parseFunctionType(); + else if (at(HASH)) { + parseTupleType(); } else if (at(LPAR)) { - parseTupleType(); + PsiBuilder.Marker functionOrParenthesizedType = mark(); + + // This may be a function parameter list or just a prenthesized type + advance(); // LPAR + parseTypeRefContents().drop(); // parenthesized types, no reference element around it is needed + + if (at(RPAR)) { + advance(); // RPAR + if (at(ARROW)) { + // It's a function type with one parameter specified + // (A) -> B + functionOrParenthesizedType.rollbackTo(); + parseFunctionType(); + } + else { + // It's a parenthesized type + // (A) + functionOrParenthesizedType.drop(); + } + } + else { + // This must be a function type + // (A, B) -> C + // or + // (a : A) -> C + functionOrParenthesizedType.rollbackTo(); + parseFunctionType(); + } + } else if (at(CAPITALIZED_THIS_KEYWORD)) { parseSelfType(); @@ -1299,7 +1336,7 @@ public class JetParsing extends AbstractJetParsing { else { errorWithRecovery("Type expected", TokenSet.orSet(TOPLEVEL_OBJECT_FIRST, - TokenSet.create(EQ, COMMA, GT, RBRACKET, DOT, RPAR, RBRACE, LBRACE, SEMICOLON))); + TokenSet.create(EQ, COMMA, GT, RBRACKET, DOT, RPAR, RBRACE, LBRACE, SEMICOLON))); } while (at(QUEST)) { @@ -1310,20 +1347,29 @@ public class JetParsing extends AbstractJetParsing { typeRefMarker = precede; } - typeRefMarker.done(TYPE_REFERENCE); - } - /* - * selfType - * : "This" - * ; - */ - private void parseSelfType() { - assert _at(CAPITALIZED_THIS_KEYWORD); + if (at(DOT)) { + // This is a receiver for a function type + // A.(B) -> C + // ^ - PsiBuilder.Marker type = mark(); - advance(); // CAPITALIZED_THIS_KEYWORD - type.done(SELF_TYPE); + PsiBuilder.Marker precede = typeRefMarker.precede(); + typeRefMarker.done(TYPE_REFERENCE); + + advance(); // DOT + + if (at(LPAR)) { + parseFunctionTypeContents().drop(); + } + else { + error("Expecting function type"); + } + typeRefMarker = precede.precede(); + + precede.done(FUNCTION_TYPE); + } +// myBuilder.restoreJoiningComplexTokensState(); + return typeRefMarker; } /* @@ -1341,13 +1387,18 @@ public class JetParsing extends AbstractJetParsing { PsiBuilder.Marker reference = mark(); while (true) { - expect(IDENTIFIER, "Type name expected", TokenSet.orSet(JetExpressionParsing.EXPRESSION_FIRST, JetExpressionParsing.EXPRESSION_FOLLOW)); + expect(IDENTIFIER, "Expecting type name", TokenSet.orSet(JetExpressionParsing.EXPRESSION_FIRST, JetExpressionParsing.EXPRESSION_FOLLOW)); reference.done(REFERENCE_EXPRESSION); parseTypeArgumentList(-1); if (!at(DOT)) { break; } + if (lookahead(1) == LPAR) { + // This may be a receiver for a function type + // Int.(Int) -> Int + break; + } PsiBuilder.Marker precede = userType.precede(); userType.done(USER_TYPE); @@ -1360,6 +1411,19 @@ public class JetParsing extends AbstractJetParsing { userType.done(USER_TYPE); } + /* + * selfType + * : "This" + * ; + */ + private void parseSelfType() { + assert _at(CAPITALIZED_THIS_KEYWORD); + + PsiBuilder.Marker type = mark(); + advance(); // CAPITALIZED_THIS_KEYWORD + type.done(SELF_TYPE); + } + /* * (optionalProjection type){","} */ @@ -1410,18 +1474,18 @@ public class JetParsing extends AbstractJetParsing { /* * tupleType - * : "(" type{","}? ")" - * : "(" parameter{","} ")" // tuple with named entries, the names do not affect assignment compatibility + * : "#" "(" type{","}? ")" + * : "#" "(" parameter{","} ")" // tuple with named entries, the names do not affect assignment compatibility * ; */ private void parseTupleType() { - // TODO : prohibit (a) - assert _at(LPAR); + assert _at(HASH); PsiBuilder.Marker tuple = mark(); myBuilder.disableNewlines(); - advance(); // LPAR + advance(); // HASH + expect(LPAR, "Expecting a tuple type in the form of '#(...)"); if (!at(RPAR)) { while (true) { @@ -1456,32 +1520,38 @@ public class JetParsing extends AbstractJetParsing { /* * functionType - * : "fun" (type ".")? "(" (parameter | modifiers type){","} ")" (":" type)? // Unit by default + * : (type ".")? "(" (parameter | modifiers type){","} ")" "->" type? * ; */ private void parseFunctionType() { - assert _at(FUN_KEYWORD); + parseFunctionTypeContents().done(FUNCTION_TYPE); + } + private PsiBuilder.Marker parseFunctionTypeContents() { +// assert _at(LPAR) : tt(); + if (!_at(LPAR)) + System.out.println(myBuilder.getTokenText()); PsiBuilder.Marker functionType = mark(); - advance(); // FUN_KEYWORD - - int lastLPar = findLastBefore(TokenSet.create(LPAR), TokenSet.create(COLON), false); - if (lastLPar >= 0 && lastLPar > myBuilder.getCurrentOffset()) { - // TODO : -1 is a hack? - createTruncatedBuilder(lastLPar - 1).parseTypeRef(); - advance(); // DOT - } +// advance(); // LPAR +// +// int lastLPar = findLastBefore(TokenSet.create(LPAR), TokenSet.create(COLON), false); +// if (lastLPar >= 0 && lastLPar > myBuilder.getCurrentOffset()) { +// TODO : -1 is a hack? +// createTruncatedBuilder(lastLPar - 1).parseTypeRef(); +// advance(); // DOT +// } parseValueParameterList(true, TokenSet.EMPTY); - if (at(COLON)) { - advance(); // COLON // expect(COLON, "Expecting ':' followed by a return type", TYPE_REF_FIRST); +// if (at(COLON)) { +// advance(); // COLON // expect(COLON, "Expecting ':' followed by a return type", TYPE_REF_FIRST); - parseTypeRef(); - } + expect(ARROW, "Expecting '->' to specify return type of a function type", TYPE_REF_FIRST); + parseTypeRef(); +// } - functionType.done(FUNCTION_TYPE); + return functionType;//.done(FUNCTION_TYPE); } /* diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilder.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilder.java index 9c836948b2a..378350b3707 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilder.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilder.java @@ -13,6 +13,7 @@ public interface SemanticWhitespaceAwarePsiBuilder extends PsiBuilder { void enableNewlines(); void restoreNewlinesState(); + void restoreJoiningComplexTokensState(); void enableJoiningComplexTokens(); void disableJoiningComplexTokens(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderAdapter.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderAdapter.java index bdec327ec20..7215fcb90f1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderAdapter.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderAdapter.java @@ -35,6 +35,11 @@ public class SemanticWhitespaceAwarePsiBuilderAdapter extends PsiBuilderAdapter myBuilder.restoreNewlinesState(); } + @Override + public void restoreJoiningComplexTokensState() { + myBuilder.restoreJoiningComplexTokensState(); + } + @Override public void enableJoiningComplexTokens() { myBuilder.enableJoiningComplexTokens(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderImpl.java index 68ecfaafd88..39388d9db3c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/SemanticWhitespaceAwarePsiBuilderImpl.java @@ -16,11 +16,15 @@ import static org.jetbrains.jet.lexer.JetTokens.*; * @author abreslav */ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter implements SemanticWhitespaceAwarePsiBuilder { + private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS); + private final Stack joinComplexTokens = new Stack(); + private final Stack newlinesEnabled = new Stack(); public SemanticWhitespaceAwarePsiBuilderImpl(final PsiBuilder delegate) { super(delegate); newlinesEnabled.push(true); + joinComplexTokens.push(true); } @Override @@ -75,22 +79,28 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp newlinesEnabled.pop(); } - private final TokenSet complexTokens = TokenSet.create(SAFE_ACCESS, ELVIS); - private boolean joinComplexTokens = true; + private boolean joinComplexTokens() { + return joinComplexTokens.peek(); + } + + @Override + public void restoreJoiningComplexTokensState() { + joinComplexTokens.pop(); + } @Override public void enableJoiningComplexTokens() { - joinComplexTokens = true; + joinComplexTokens.push(true); } @Override public void disableJoiningComplexTokens() { - joinComplexTokens = false; + joinComplexTokens.push(false); } @Override public IElementType getTokenType() { - if (!joinComplexTokens) return super.getTokenType(); + if (!joinComplexTokens()) return super.getTokenType(); return getJoinedTokenType(super.getTokenType(), 1); } @@ -105,7 +115,7 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp @Override public void advanceLexer() { - if (!joinComplexTokens) { + if (!joinComplexTokens()) { super.advanceLexer(); return; } @@ -123,7 +133,7 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp @Override public String getTokenText() { - if (!joinComplexTokens) return super.getTokenText(); + if (!joinComplexTokens()) return super.getTokenText(); IElementType tokenType = getTokenType(); if (complexTokens.contains(tokenType)) { if (tokenType == ELVIS) return "?:"; @@ -134,7 +144,7 @@ public class SemanticWhitespaceAwarePsiBuilderImpl extends PsiBuilderAdapter imp @Override public IElementType lookAhead(int steps) { - if (!joinComplexTokens) return super.lookAhead(steps); + if (!joinComplexTokens()) return super.lookAhead(steps); if (complexTokens.contains(getTokenType())) { return super.lookAhead(steps + 1); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionLiteral.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionLiteral.java index 6f20e9a1478..c39e7fe49c1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionLiteral.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionLiteral.java @@ -30,7 +30,7 @@ public class JetFunctionLiteral extends JetFunction { } public boolean hasParameterSpecification() { - return findChildByType(JetTokens.DOUBLE_ARROW) != null; + return findChildByType(JetTokens.ARROW) != null; } @Override @@ -51,6 +51,6 @@ public class JetFunctionLiteral extends JetFunction { @Nullable public ASTNode getArrowNode() { - return getNode().findChildByType(JetTokens.DOUBLE_ARROW); + return getNode().findChildByType(JetTokens.ARROW); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionType.java b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionType.java index aaeffa8262b..d7f7cd4146f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/psi/JetFunctionType.java @@ -7,6 +7,7 @@ import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeTypes; +import org.jetbrains.jet.lexer.JetToken; import org.jetbrains.jet.lexer.JetTokens; import java.util.ArrayList; @@ -17,6 +18,9 @@ import java.util.List; * @author max */ public class JetFunctionType extends JetTypeElement { + + public static final JetToken RETURN_TYPE_SEPARATOR = JetTokens.ARROW; + public JetFunctionType(@NotNull ASTNode node) { super(node); } @@ -65,7 +69,7 @@ public class JetFunctionType extends JetTypeElement { PsiElement child = getFirstChild(); while (child != null) { IElementType tt = child.getNode().getElementType(); - if (tt == JetTokens.LPAR || tt == JetTokens.COLON) break; + if (tt == JetTokens.LPAR || tt == RETURN_TYPE_SEPARATOR) break; if (child instanceof JetTypeReference) { return (JetTypeReference) child; } @@ -81,7 +85,7 @@ public class JetFunctionType extends JetTypeElement { PsiElement child = getFirstChild(); while (child != null) { IElementType tt = child.getNode().getElementType(); - if (tt == JetTokens.COLON) { + if (tt == RETURN_TYPE_SEPARATOR) { colonPassed = true; } if (colonPassed && child instanceof JetTypeReference) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java index 8896830d305..35cd9d738a7 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java @@ -19,6 +19,7 @@ import java.util.Collections; import java.util.List; import static org.jetbrains.jet.lang.diagnostics.Errors.UNRESOLVED_REFERENCE; +import static org.jetbrains.jet.lang.diagnostics.Errors.UNSUPPORTED; import static org.jetbrains.jet.lang.diagnostics.Errors.WRONG_NUMBER_OF_TYPE_ARGUMENTS; import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET; @@ -173,13 +174,17 @@ public class TypeResolver { @Override public void visitJetElement(JetElement element) { - throw new IllegalArgumentException("Unsupported type: " + element); + trace.report(UNSUPPORTED.on(element, "Self-types are not supported yet")); +// throw new IllegalArgumentException("Unsupported type: " + element); } }); } if (result[0] == null) { return ErrorUtils.createErrorType(typeElement == null ? "No type element" : typeElement.getText()); } + if (nullable) { + return TypeUtils.makeNullable(result[0]); + } return result[0]; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex b/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex index a6136493b42..c69a622e730 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex +++ b/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex @@ -161,8 +161,8 @@ LONG_TEMPLATE_ENTRY_END=\} // TODO: Decide what to do with """ ... """" {RAW_STRING_LITERAL} { return JetTokens.RAW_STRING_LITERAL; } -"namespace" { return JetTokens.NAMESPACE_KEYWORD ;} "continue" { return JetTokens.CONTINUE_KEYWORD ;} +"package" { return JetTokens.NAMESPACE_KEYWORD ;} "return" { return JetTokens.RETURN_KEYWORD ;} "object" { return JetTokens.OBJECT_KEYWORD ;} "while" { return JetTokens.WHILE_KEYWORD ;} diff --git a/compiler/frontend/src/org/jetbrains/jet/lexer/JetTokens.java b/compiler/frontend/src/org/jetbrains/jet/lexer/JetTokens.java index c66e06e3a60..e2cd5e0282f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lexer/JetTokens.java +++ b/compiler/frontend/src/org/jetbrains/jet/lexer/JetTokens.java @@ -170,12 +170,14 @@ public interface JetTokens { TokenSet STRINGS = TokenSet.create(CHARACTER_LITERAL, REGULAR_STRING_PART, RAW_STRING_LITERAL); TokenSet OPERATIONS = TokenSet.create(AS_KEYWORD, AS_SAFE, IS_KEYWORD, IN_KEYWORD, DOT, PLUSPLUS, MINUSMINUS, MUL, PLUS, - MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, ARROW, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, + MINUS, EXCL, DIV, PERC, LT, GT, LTEQ, GTEQ, EQEQEQ, EXCLEQEQEQ, EQEQ, EXCLEQ, ANDAND, OROR, SAFE_ACCESS, ELVIS, // MAP, FILTER, QUEST, COLON, RANGE, EQ, MULTEQ, DIVEQ, PERCEQ, PLUSEQ, MINUSEQ, - NOT_IN, NOT_IS, HASH, IDENTIFIER, LABEL_IDENTIFIER, ATAT, AT); + NOT_IN, NOT_IS, +// HASH, + IDENTIFIER, LABEL_IDENTIFIER, ATAT, AT); TokenSet AUGMENTED_ASSIGNMENTS = TokenSet.create(PLUSEQ, MINUSEQ, MULTEQ, PERCEQ, DIVEQ); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lexer/_JetLexer.java b/compiler/frontend/src/org/jetbrains/jet/lexer/_JetLexer.java index 444c9e4fbdf..cfc7b187828 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lexer/_JetLexer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lexer/_JetLexer.java @@ -1,4 +1,4 @@ -/* The following code was generated by JFlex 1.4.3 on 12/15/11 8:19 PM */ +/* The following code was generated by JFlex 1.4.3 on 12/25/11 2:36 PM */ package org.jetbrains.jet.lexer; @@ -13,8 +13,8 @@ import org.jetbrains.jet.lexer.JetTokens; /** * This class is a scanner generated by * JFlex 1.4.3 - * on 12/15/11 8:19 PM from the specification file - * /Users/abreslav/work/jet-clean/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex + * on 12/25/11 2:36 PM from the specification file + * /Users/abreslav/work/jet/compiler/frontend/src/org/jetbrains/jet/lexer/Jet.flex */ class _JetLexer implements FlexLexer { /** initial size of the lookahead buffer */ @@ -44,10 +44,10 @@ class _JetLexer implements FlexLexer { "\1\10\1\67\1\65\1\23\1\72\1\73\1\13\1\62\1\76\1\21"+ "\1\17\1\12\1\14\11\1\1\74\1\75\1\63\1\60\1\64\1\61"+ "\1\11\1\2\1\16\2\2\1\20\1\2\11\4\1\22\3\4\1\54"+ - "\3\4\1\15\2\4\1\70\1\24\1\71\1\0\1\4\1\6\1\36"+ - "\1\45\1\42\1\56\1\40\1\52\1\4\1\32\1\33\1\46\1\51"+ - "\1\50\1\37\1\35\1\43\1\41\1\4\1\44\1\34\1\31\1\26"+ - "\1\55\1\47\1\15\1\53\1\4\1\27\1\66\1\30\54\0\1\4"+ + "\3\4\1\15\2\4\1\70\1\24\1\71\1\0\1\4\1\6\1\42"+ + "\1\46\1\35\1\56\1\40\1\52\1\44\1\32\1\33\1\47\1\43"+ + "\1\51\1\4\1\37\1\36\1\41\1\4\1\45\1\34\1\31\1\26"+ + "\1\55\1\50\1\15\1\53\1\4\1\27\1\66\1\30\54\0\1\4"+ "\12\0\1\4\4\0\1\4\5\0\27\4\1\0\37\4\1\0\u013f\4"+ "\31\0\162\4\4\0\14\4\16\0\5\4\11\0\1\4\213\0\1\4"+ "\13\0\1\4\1\0\3\4\1\0\1\4\1\0\24\4\1\0\54\4"+ @@ -121,27 +121,27 @@ class _JetLexer implements FlexLexer { private static final String ZZ_ACTION_PACKED_0 = "\4\0\1\1\1\2\1\3\1\4\2\1\1\5\1\6"+ "\1\7\1\2\1\10\1\11\1\12\1\13\1\14\1\15"+ - "\17\3\1\16\1\17\1\20\1\21\1\22\1\23\2\1"+ + "\20\3\1\16\1\17\1\20\1\21\1\22\1\23\2\1"+ "\1\24\1\25\1\26\1\27\1\30\1\31\1\32\1\33"+ "\1\34\1\35\1\36\1\35\1\0\1\37\1\40\1\0"+ "\1\40\1\41\1\42\1\0\1\43\1\0\1\44\1\0"+ "\1\45\1\0\1\46\1\47\1\50\1\51\1\52\1\43"+ "\2\2\1\43\1\53\1\54\1\55\1\56\2\12\1\0"+ - "\3\3\1\57\1\60\1\61\3\3\1\62\14\3\1\63"+ + "\3\3\1\57\1\60\1\61\7\3\1\62\10\3\1\63"+ "\1\0\1\64\1\65\1\66\1\67\1\70\1\71\1\72"+ "\1\73\1\74\1\75\1\76\1\0\1\77\2\100\1\0"+ "\1\40\1\101\1\43\1\3\2\0\1\50\1\102\4\0"+ - "\1\103\4\3\1\104\4\3\1\105\10\3\1\106\1\3"+ - "\1\107\1\3\1\110\1\111\1\112\1\113\1\114\1\115"+ - "\2\0\2\40\1\44\1\45\1\0\2\102\1\43\2\0"+ - "\1\116\1\3\1\117\1\3\1\120\1\3\1\121\1\3"+ - "\1\122\6\3\1\123\1\3\1\124\1\125\1\76\1\0"+ - "\1\126\1\50\2\0\1\127\1\130\1\131\2\3\1\132"+ - "\2\3\1\133\1\134\1\135\1\0\1\103\2\3\1\136"+ - "\1\137\3\3\1\140\1\141"; + "\1\103\4\3\1\104\10\3\1\105\4\3\1\106\1\107"+ + "\2\3\1\110\1\111\1\112\1\113\1\114\1\115\2\0"+ + "\2\40\1\44\1\45\1\0\2\102\1\43\2\0\1\116"+ + "\1\3\1\117\1\3\1\120\4\3\1\121\1\122\4\3"+ + "\1\123\1\3\1\124\1\125\1\76\1\0\1\126\1\50"+ + "\2\0\1\127\1\130\1\131\1\3\1\132\3\3\1\133"+ + "\1\134\1\135\1\0\1\103\1\3\1\136\1\3\1\137"+ + "\1\3\1\140\1\141"; private static int [] zzUnpackAction() { - int [] result = new int[225]; + int [] result = new int[224]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -170,34 +170,33 @@ class _JetLexer implements FlexLexer { "\0\u0200\0\u0240\0\u0280\0\u02c0\0\u0300\0\u0340\0\u0380\0\u03c0"+ "\0\u0400\0\u0440\0\u0100\0\u0100\0\u0480\0\u04c0\0\u0500\0\u0540"+ "\0\u0580\0\u05c0\0\u0600\0\u0640\0\u0680\0\u06c0\0\u0700\0\u0740"+ - "\0\u0780\0\u07c0\0\u0800\0\u0840\0\u0880\0\u0100\0\u08c0\0\u0900"+ - "\0\u0940\0\u0980\0\u09c0\0\u0a00\0\u0100\0\u0100\0\u0100\0\u0100"+ - "\0\u0100\0\u0100\0\u0100\0\u0100\0\u0a40\0\u0100\0\u0a80\0\u0ac0"+ - "\0\u0100\0\u0b00\0\u0b40\0\u0b80\0\u0100\0\u0100\0\u0bc0\0\u0c00"+ - "\0\u0c40\0\u0c80\0\u0cc0\0\u0d00\0\u0d40\0\u0100\0\u0d80\0\u0dc0"+ - "\0\u0100\0\u0100\0\u0e00\0\u0e40\0\u0e80\0\u0ec0\0\u0100\0\u0100"+ - "\0\u0100\0\u0100\0\u0100\0\u0f00\0\u0f40\0\u0f80\0\u0fc0\0\u1000"+ - "\0\u0180\0\u0180\0\u0180\0\u1040\0\u1080\0\u10c0\0\u1100\0\u1140"+ + "\0\u0780\0\u07c0\0\u0800\0\u0840\0\u0880\0\u08c0\0\u0100\0\u0900"+ + "\0\u0940\0\u0980\0\u09c0\0\u0a00\0\u0a40\0\u0100\0\u0100\0\u0100"+ + "\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0a80\0\u0100\0\u0ac0"+ + "\0\u0b00\0\u0100\0\u0b40\0\u0b80\0\u0bc0\0\u0100\0\u0100\0\u0c00"+ + "\0\u0c40\0\u0c80\0\u0cc0\0\u0d00\0\u0d40\0\u0d80\0\u0100\0\u0dc0"+ + "\0\u0e00\0\u0100\0\u0100\0\u0e40\0\u0e80\0\u0ec0\0\u0f00\0\u0100"+ + "\0\u0100\0\u0100\0\u0100\0\u0100\0\u0f40\0\u0f80\0\u0fc0\0\u1000"+ + "\0\u1040\0\u0180\0\u0180\0\u0180\0\u1080\0\u10c0\0\u1100\0\u1140"+ "\0\u1180\0\u11c0\0\u1200\0\u1240\0\u1280\0\u12c0\0\u1300\0\u1340"+ - "\0\u1380\0\u13c0\0\u1400\0\u0180\0\u1440\0\u1480\0\u14c0\0\u0100"+ - "\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u1500"+ - "\0\u1540\0\u0100\0\u0100\0\u1580\0\u15c0\0\u1600\0\u0100\0\u1640"+ - "\0\u0100\0\u1680\0\u16c0\0\u1700\0\u1740\0\u1780\0\u17c0\0\u1800"+ - "\0\u1840\0\u1880\0\u18c0\0\u1900\0\u1940\0\u1980\0\u0180\0\u19c0"+ - "\0\u1a00\0\u1a40\0\u1a80\0\u0100\0\u1ac0\0\u1b00\0\u1b40\0\u1b80"+ - "\0\u1bc0\0\u1c00\0\u1c40\0\u1c80\0\u0180\0\u1cc0\0\u0180\0\u1d00"+ - "\0\u0180\0\u0180\0\u1d40\0\u1d40\0\u0100\0\u0100\0\u1d80\0\u1dc0"+ - "\0\u0100\0\u1e00\0\u0100\0\u0100\0\u1e40\0\u1e80\0\u0100\0\u1ec0"+ - "\0\u1640\0\u1f00\0\u0180\0\u1f40\0\u0180\0\u1f80\0\u0180\0\u1fc0"+ - "\0\u0180\0\u2000\0\u0180\0\u2040\0\u2080\0\u20c0\0\u2100\0\u2140"+ - "\0\u2180\0\u0180\0\u21c0\0\u0180\0\u0100\0\u0100\0\u2200\0\u0b00"+ - "\0\u0100\0\u2240\0\u2280\0\u0180\0\u0180\0\u0180\0\u22c0\0\u2300"+ - "\0\u0180\0\u2340\0\u2380\0\u0180\0\u0180\0\u0180\0\u23c0\0\u0100"+ - "\0\u2400\0\u2440\0\u0180\0\u0180\0\u2480\0\u24c0\0\u2500\0\u0180"+ - "\0\u0180"; + "\0\u1380\0\u13c0\0\u1400\0\u1440\0\u0180\0\u1480\0\u14c0\0\u1500"+ + "\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100\0\u0100"+ + "\0\u1540\0\u1580\0\u0100\0\u0100\0\u15c0\0\u1600\0\u1640\0\u0100"+ + "\0\u1680\0\u0100\0\u16c0\0\u1700\0\u1740\0\u1780\0\u17c0\0\u1800"+ + "\0\u1840\0\u1880\0\u18c0\0\u1900\0\u1940\0\u1980\0\u19c0\0\u0180"+ + "\0\u1a00\0\u1a40\0\u1a80\0\u1ac0\0\u1b00\0\u1b40\0\u1b80\0\u1bc0"+ + "\0\u0100\0\u1c00\0\u1c40\0\u1c80\0\u1cc0\0\u0180\0\u0180\0\u1d00"+ + "\0\u1d40\0\u0180\0\u0180\0\u1d80\0\u1d80\0\u0100\0\u0100\0\u1dc0"+ + "\0\u1e00\0\u0100\0\u1e40\0\u0100\0\u0100\0\u1e80\0\u1ec0\0\u0100"+ + "\0\u1f00\0\u1680\0\u1f40\0\u0180\0\u1f80\0\u0180\0\u1fc0\0\u0180"+ + "\0\u2000\0\u2040\0\u2080\0\u20c0\0\u0180\0\u0180\0\u2100\0\u2140"+ + "\0\u2180\0\u21c0\0\u0180\0\u2200\0\u0180\0\u0100\0\u0100\0\u2240"+ + "\0\u0b40\0\u0100\0\u2280\0\u22c0\0\u0180\0\u0180\0\u0180\0\u2300"+ + "\0\u0180\0\u2340\0\u2380\0\u23c0\0\u0180\0\u0180\0\u0180\0\u2400"+ + "\0\u0100\0\u2440\0\u0180\0\u2480\0\u0180\0\u24c0\0\u0180\0\u0180"; private static int [] zzUnpackRowMap() { - int [] result = new int[225]; + int [] result = new int[224]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -223,241 +222,239 @@ class _JetLexer implements FlexLexer { "\1\5\1\6\1\7\1\10\1\7\1\5\1\11\1\10"+ "\1\12\1\13\1\14\1\15\1\16\2\7\1\17\1\7"+ "\1\20\1\7\1\21\1\5\1\22\1\7\1\23\1\24"+ - "\1\25\1\7\1\26\1\27\1\30\1\31\1\7\1\32"+ - "\1\7\1\33\1\34\1\35\1\36\1\7\1\37\2\7"+ - "\1\40\1\7\1\41\1\42\1\43\1\44\1\45\1\46"+ - "\1\47\1\50\1\51\1\52\1\53\1\54\1\55\1\56"+ - "\1\57\1\60\1\61\1\62\1\63\1\64\7\65\1\66"+ - "\1\67\13\65\1\70\1\71\52\65\2\0\1\72\1\0"+ - "\1\72\1\0\1\73\6\0\2\72\1\0\1\72\1\0"+ - "\1\72\3\0\1\72\2\0\1\74\25\72\21\0\1\5"+ + "\1\25\1\7\1\26\1\27\1\30\1\31\1\32\1\33"+ + "\1\34\1\35\2\7\1\36\1\37\1\7\1\40\1\7"+ + "\1\41\1\7\1\42\1\43\1\44\1\45\1\46\1\47"+ + "\1\50\1\51\1\52\1\53\1\54\1\55\1\56\1\57"+ + "\1\60\1\61\1\62\1\63\1\64\1\65\7\66\1\67"+ + "\1\70\13\66\1\71\1\72\52\66\2\0\1\73\1\0"+ + "\1\73\1\0\1\74\6\0\2\73\1\0\1\73\1\0"+ + "\1\73\3\0\1\73\2\0\1\75\25\73\21\0\1\5"+ "\1\6\1\7\1\10\1\7\1\5\1\11\1\10\1\12"+ "\1\13\1\14\1\15\1\16\2\7\1\17\1\7\1\20"+ - "\1\7\1\21\1\5\1\22\1\7\1\75\1\76\1\25"+ - "\1\7\1\26\1\27\1\30\1\31\1\7\1\32\1\7"+ - "\1\33\1\34\1\35\1\36\1\7\1\37\2\7\1\40"+ - "\1\7\1\41\1\42\1\43\1\44\1\45\1\46\1\47"+ - "\1\50\1\51\1\52\1\53\1\54\1\55\1\56\1\57"+ - "\1\60\1\61\1\62\1\63\1\64\101\0\1\6\12\0"+ - "\1\6\2\0\1\77\1\100\17\0\1\100\40\0\2\7"+ + "\1\7\1\21\1\5\1\22\1\7\1\76\1\77\1\25"+ + "\1\7\1\26\1\27\1\30\1\31\1\32\1\33\1\34"+ + "\1\35\2\7\1\36\1\37\1\7\1\40\1\7\1\41"+ + "\1\7\1\42\1\43\1\44\1\45\1\46\1\47\1\50"+ + "\1\51\1\52\1\53\1\54\1\55\1\56\1\57\1\60"+ + "\1\61\1\62\1\63\1\64\1\65\101\0\1\6\12\0"+ + "\1\6\2\0\1\100\1\101\17\0\1\101\40\0\2\7"+ "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ "\3\0\1\7\2\0\26\7\24\0\1\10\3\0\1\10"+ - "\70\0\6\101\2\0\70\101\2\0\1\102\1\0\1\102"+ - "\1\0\1\103\6\0\2\102\1\0\1\102\1\0\1\102"+ - "\3\0\1\102\2\0\26\102\23\0\1\104\1\0\1\104"+ - "\1\0\1\105\2\0\1\106\3\0\2\104\1\0\1\104"+ - "\1\0\1\104\3\0\1\104\2\0\26\104\33\0\1\107"+ - "\1\110\44\0\1\111\77\0\1\112\20\0\1\113\12\0"+ - "\1\113\1\114\1\115\1\77\1\100\17\0\1\100\4\0"+ - "\1\115\33\0\1\116\12\0\1\116\2\0\1\117\101\0"+ - "\1\120\36\0\1\121\3\0\1\122\13\0\7\21\1\0"+ - "\13\21\1\123\1\124\53\21\25\0\1\125\53\0\2\7"+ + "\70\0\6\102\2\0\70\102\2\0\1\103\1\0\1\103"+ + "\1\0\1\104\6\0\2\103\1\0\1\103\1\0\1\103"+ + "\3\0\1\103\2\0\26\103\23\0\1\105\1\0\1\105"+ + "\1\0\1\106\2\0\1\107\3\0\2\105\1\0\1\105"+ + "\1\0\1\105\3\0\1\105\2\0\26\105\33\0\1\110"+ + "\1\111\44\0\1\112\77\0\1\113\20\0\1\114\12\0"+ + "\1\114\1\115\1\116\1\100\1\101\17\0\1\101\5\0"+ + "\1\116\32\0\1\117\12\0\1\117\2\0\1\120\101\0"+ + "\1\121\36\0\1\122\3\0\1\123\13\0\7\21\1\0"+ + "\13\21\1\124\1\125\53\21\25\0\1\126\53\0\2\7"+ "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ - "\3\0\1\7\2\0\1\7\1\126\11\7\1\127\6\7"+ - "\1\130\3\7\22\0\2\7\1\0\2\7\6\0\3\7"+ + "\3\0\1\7\2\0\1\7\1\127\12\7\1\130\5\7"+ + "\1\131\3\7\22\0\2\7\1\0\2\7\6\0\3\7"+ "\1\0\1\7\1\0\1\7\3\0\1\7\2\0\3\7"+ - "\1\131\1\132\14\7\1\133\4\7\22\0\2\7\1\0"+ - "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ - "\1\134\2\0\26\7\22\0\2\7\1\0\2\7\6\0"+ - "\3\7\1\0\1\7\1\0\1\7\3\0\1\135\2\0"+ - "\5\7\1\136\20\7\22\0\2\7\1\0\2\7\6\0"+ - "\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+ - "\3\7\1\137\22\7\22\0\2\7\1\0\2\7\6\0"+ - "\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+ - "\17\7\1\140\6\7\22\0\2\7\1\0\2\7\6\0"+ - "\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+ - "\12\7\1\141\4\7\1\142\6\7\22\0\2\7\1\0"+ - "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ - "\1\7\2\0\14\7\1\143\11\7\22\0\2\7\1\0"+ - "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ - "\1\7\2\0\7\7\1\144\16\7\22\0\2\7\1\0"+ - "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ - "\1\7\2\0\13\7\1\145\12\7\22\0\2\7\1\0"+ - "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ - "\1\7\2\0\1\7\1\146\24\7\22\0\2\7\1\0"+ - "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ - "\1\147\2\0\5\7\1\150\4\7\1\151\13\7\22\0"+ - "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\1\7\1\152\24\7\22\0"+ - "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\5\7\1\153\20\7\22\0"+ - "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\12\7\1\154\13\7\54\0"+ - "\1\155\24\0\1\156\77\0\1\157\3\0\1\160\73\0"+ - "\1\161\1\0\1\162\75\0\1\163\77\0\1\164\104\0"+ - "\1\165\100\0\1\166\71\0\1\167\17\0\7\65\2\0"+ - "\13\65\2\0\52\65\2\0\1\170\1\0\1\170\1\0"+ - "\1\171\6\0\2\170\1\0\1\170\1\0\1\170\3\0"+ - "\1\170\1\172\1\0\26\170\21\0\7\173\1\0\16\173"+ - "\1\174\51\173\1\0\2\72\1\0\2\72\6\0\3\72"+ - "\1\0\1\72\1\0\1\72\3\0\1\72\2\0\26\72"+ - "\21\0\6\175\2\0\70\175\1\0\2\72\1\0\2\72"+ - "\6\0\3\72\1\0\1\72\1\0\1\72\3\0\1\72"+ - "\2\0\1\72\1\176\24\72\22\0\1\116\12\0\1\116"+ - "\2\0\1\177\61\0\1\200\12\0\1\200\4\0\1\200"+ - "\40\0\1\200\15\0\6\101\1\201\1\0\70\101\1\0"+ - "\2\102\1\0\2\102\6\0\3\102\1\0\1\102\1\0"+ - "\1\102\3\0\1\102\2\0\26\102\21\0\6\202\2\0"+ - "\70\202\1\0\2\104\1\0\2\104\6\0\3\104\1\0"+ - "\1\104\1\0\1\104\3\0\1\104\2\0\26\104\21\0"+ - "\6\203\2\0\70\203\7\107\1\0\70\107\13\204\1\205"+ - "\64\204\1\0\1\113\12\0\1\113\2\0\1\206\1\100"+ - "\17\0\1\100\40\0\2\114\11\0\1\114\1\0\1\114"+ - "\1\207\1\114\1\0\1\210\13\0\1\114\1\0\1\114"+ - "\1\210\1\114\2\0\1\114\4\0\1\114\3\0\1\114"+ - "\22\0\1\115\12\0\1\115\2\0\1\211\61\0\1\116"+ - "\12\0\1\116\3\0\1\100\17\0\1\100\37\0\7\21"+ - "\1\0\70\21\25\0\1\212\53\0\2\7\1\0\2\7"+ - "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\2\7\1\213\10\7\1\214\12\7\22\0\2\7"+ + "\1\132\2\7\1\133\12\7\1\134\4\7\22\0\2\7"+ "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ - "\3\0\1\215\2\0\5\7\1\216\14\7\1\217\3\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\10\7\1\220\15\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\10\7\1\221\15\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\17\7\1\222\6\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\6\7\1\223\17\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\26\7\2\0\1\224"+ - "\17\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\3\7\1\225\22\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\4\7\1\226\21\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\5\7\1\227\20\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\15\7\1\230\10\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\1\231\25\7\22\0"+ + "\3\0\1\135\2\0\26\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ + "\2\0\5\7\1\136\12\7\1\137\5\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\7\2\0\15\7\1\140\10\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\141\2\0\26\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ + "\2\0\20\7\1\142\5\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ + "\2\0\11\7\1\143\14\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ + "\2\0\3\7\1\144\22\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ + "\2\0\7\7\1\145\16\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ + "\2\0\14\7\1\146\11\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ + "\2\0\1\7\1\147\24\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\150"+ + "\2\0\5\7\1\151\3\7\1\152\14\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\7\2\0\1\7\1\153\24\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\7\2\0\11\7\1\154\14\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\7\2\0\5\7\1\155\20\7\54\0\1\156"+ + "\24\0\1\157\77\0\1\160\3\0\1\161\73\0\1\162"+ + "\1\0\1\163\75\0\1\164\77\0\1\165\104\0\1\166"+ + "\100\0\1\167\71\0\1\170\17\0\7\66\2\0\13\66"+ + "\2\0\52\66\2\0\1\171\1\0\1\171\1\0\1\172"+ + "\6\0\2\171\1\0\1\171\1\0\1\171\3\0\1\171"+ + "\1\173\1\0\26\171\21\0\7\174\1\0\16\174\1\175"+ + "\51\174\1\0\2\73\1\0\2\73\6\0\3\73\1\0"+ + "\1\73\1\0\1\73\3\0\1\73\2\0\26\73\21\0"+ + "\6\176\2\0\70\176\1\0\2\73\1\0\2\73\6\0"+ + "\3\73\1\0\1\73\1\0\1\73\3\0\1\73\2\0"+ + "\1\73\1\177\24\73\22\0\1\117\12\0\1\117\2\0"+ + "\1\200\61\0\1\201\12\0\1\201\4\0\1\201\40\0"+ + "\1\201\15\0\6\102\1\202\1\0\70\102\1\0\2\103"+ + "\1\0\2\103\6\0\3\103\1\0\1\103\1\0\1\103"+ + "\3\0\1\103\2\0\26\103\21\0\6\203\2\0\70\203"+ + "\1\0\2\105\1\0\2\105\6\0\3\105\1\0\1\105"+ + "\1\0\1\105\3\0\1\105\2\0\26\105\21\0\6\204"+ + "\2\0\70\204\7\110\1\0\70\110\13\205\1\206\64\205"+ + "\1\0\1\114\12\0\1\114\2\0\1\207\1\101\17\0"+ + "\1\101\40\0\2\115\11\0\1\115\1\0\1\115\1\210"+ + "\1\115\1\0\1\211\12\0\1\115\2\0\1\115\1\211"+ + "\1\115\3\0\1\115\3\0\1\115\3\0\1\115\22\0"+ + "\1\116\12\0\1\116\2\0\1\212\61\0\1\117\12\0"+ + "\1\117\3\0\1\101\17\0\1\101\37\0\7\21\1\0"+ + "\70\21\25\0\1\213\53\0\2\7\1\0\2\7\6\0"+ + "\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+ + "\2\7\1\214\11\7\1\215\11\7\22\0\2\7\1\0"+ + "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ + "\1\216\2\0\11\7\1\217\10\7\1\220\3\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\7\7\1\232\16\7\22\0"+ + "\1\7\3\0\1\7\2\0\10\7\1\221\15\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\2\7\1\233\4\7\1\234"+ - "\16\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+ - "\1\7\1\0\1\7\3\0\1\7\2\0\4\7\1\235"+ - "\21\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+ - "\1\7\1\0\1\7\3\0\1\7\2\0\17\7\1\236"+ - "\6\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+ - "\1\7\1\0\1\7\3\0\1\7\2\0\13\7\1\237"+ - "\12\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+ - "\1\7\1\0\1\7\3\0\1\7\2\0\2\7\1\240"+ - "\23\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+ - "\1\7\1\0\1\7\3\0\1\7\2\0\13\7\1\241"+ - "\3\7\1\242\6\7\55\0\1\243\1\244\122\0\1\245"+ - "\77\0\1\246\20\0\2\170\1\0\2\170\6\0\3\170"+ - "\1\0\1\170\1\0\1\170\3\0\1\170\2\0\26\170"+ - "\21\0\6\247\2\0\70\247\1\0\2\250\11\0\1\250"+ - "\1\0\1\250\1\0\1\250\15\0\1\250\1\0\1\250"+ - "\1\0\1\250\2\0\1\250\4\0\1\250\3\0\1\250"+ - "\21\0\6\175\1\251\1\0\70\175\1\0\2\72\1\0"+ - "\2\72\6\0\3\72\1\0\1\72\1\0\1\72\3\0"+ - "\1\72\2\0\2\72\1\252\23\72\22\0\1\200\12\0"+ - "\1\200\63\0\6\202\1\253\1\0\70\202\6\203\1\254"+ - "\1\0\70\203\13\204\1\255\64\204\12\256\1\257\1\205"+ - "\64\256\1\0\1\116\12\0\1\116\64\0\2\260\11\0"+ - "\1\260\1\0\1\260\1\177\1\260\15\0\1\260\1\0"+ - "\1\260\1\0\1\260\2\0\1\260\4\0\1\260\3\0"+ - "\1\260\22\0\1\200\12\0\1\200\4\0\1\261\40\0"+ - "\1\261\34\0\1\177\60\0\25\212\1\262\52\212\1\0"+ + "\1\7\3\0\1\7\2\0\10\7\1\222\15\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\3\7\1\263\22\7\22\0"+ + "\1\7\3\0\1\7\2\0\6\7\1\223\17\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\12\7\1\264\13\7\22\0"+ + "\1\7\3\0\1\7\2\0\11\7\1\224\14\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\7\7\1\265\16\7\22\0"+ + "\1\7\3\0\1\7\2\0\16\7\1\225\7\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\2\7\1\266\23\7\22\0"+ + "\1\7\3\0\1\7\2\0\20\7\1\226\5\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\7\7\1\267\16\7\22\0"+ + "\1\7\3\0\1\7\2\0\3\7\1\227\22\7\22\0"+ + "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ + "\1\7\3\0\1\7\2\0\4\7\1\230\21\7\22\0"+ + "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ + "\1\7\3\0\1\7\2\0\26\7\2\0\1\231\17\0"+ + "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ + "\1\7\3\0\1\7\2\0\1\232\25\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\7\2\0\7\7\1\233\16\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\7\2\0\2\7\1\234\4\7\1\235\16\7"+ + "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ + "\1\0\1\7\3\0\1\7\2\0\6\7\1\236\17\7"+ + "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ + "\1\0\1\7\3\0\1\7\2\0\14\7\1\237\11\7"+ + "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ + "\1\0\1\7\3\0\1\7\2\0\20\7\1\240\5\7"+ + "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ + "\1\0\1\7\3\0\1\7\2\0\2\7\1\241\23\7"+ + "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ + "\1\0\1\7\3\0\1\7\2\0\14\7\1\242\3\7"+ + "\1\243\5\7\55\0\1\244\2\0\1\245\120\0\1\246"+ + "\77\0\1\247\20\0\2\171\1\0\2\171\6\0\3\171"+ + "\1\0\1\171\1\0\1\171\3\0\1\171\2\0\26\171"+ + "\21\0\6\250\2\0\70\250\1\0\2\251\11\0\1\251"+ + "\1\0\1\251\1\0\1\251\14\0\1\251\2\0\1\251"+ + "\1\0\1\251\3\0\1\251\3\0\1\251\3\0\1\251"+ + "\21\0\6\176\1\252\1\0\70\176\1\0\2\73\1\0"+ + "\2\73\6\0\3\73\1\0\1\73\1\0\1\73\3\0"+ + "\1\73\2\0\2\73\1\253\23\73\22\0\1\201\12\0"+ + "\1\201\63\0\6\203\1\254\1\0\70\203\6\204\1\255"+ + "\1\0\70\204\13\205\1\256\64\205\12\257\1\260\1\206"+ + "\64\257\1\0\1\117\12\0\1\117\64\0\2\261\11\0"+ + "\1\261\1\0\1\261\1\200\1\261\14\0\1\261\2\0"+ + "\1\261\1\0\1\261\3\0\1\261\3\0\1\261\3\0"+ + "\1\261\22\0\1\201\12\0\1\201\4\0\1\262\40\0"+ + "\1\262\34\0\1\200\60\0\25\213\1\263\52\213\1\0"+ + "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ + "\1\7\3\0\1\7\2\0\3\7\1\264\22\7\22\0"+ + "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ + "\1\7\3\0\1\7\2\0\5\7\1\265\20\7\22\0"+ + "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ + "\1\7\3\0\1\7\2\0\7\7\1\266\16\7\22\0"+ + "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ + "\1\7\3\0\1\7\2\0\2\7\1\267\23\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ "\1\7\3\0\1\7\2\0\7\7\1\270\16\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\17\7\1\271\6\7\22\0"+ + "\1\7\3\0\1\7\2\0\7\7\1\271\16\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\7\7\1\272\16\7\22\0"+ - "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\7\7\1\273\16\7\22\0"+ - "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\1\274\25\7\22\0\2\7"+ + "\1\7\3\0\1\7\2\0\1\272\25\7\22\0\2\7"+ "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ - "\3\0\1\7\2\0\3\7\1\275\22\7\22\0\2\7"+ + "\3\0\1\7\2\0\3\7\1\273\22\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\7\2\0\7\7\1\274\16\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\7\2\0\20\7\1\275\5\7\22\0\2\7"+ "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ "\3\0\1\7\2\0\7\7\1\276\16\7\22\0\2\7"+ "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ - "\3\0\1\277\2\0\26\7\22\0\2\7\1\0\2\7"+ + "\3\0\1\7\2\0\12\7\1\277\13\7\22\0\2\7"+ + "\1\0\2\7\6\0\3\7\1\0\1\7\1\0\1\7"+ + "\3\0\1\300\2\0\26\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\5\7\1\300\20\7\22\0\2\7\1\0\2\7"+ + "\2\0\11\7\1\301\14\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\17\7\1\301\6\7\22\0\2\7\1\0\2\7"+ + "\2\0\20\7\1\302\5\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\4\7\1\302\21\7\22\0\2\7\1\0\2\7"+ + "\2\0\6\7\1\303\17\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\3\7\1\303\22\7\22\0\2\7\1\0\2\7"+ + "\2\0\3\7\1\304\22\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\3\7\1\304\22\7\22\0\2\305\1\0\2\305"+ - "\6\0\3\305\1\0\1\305\1\0\1\305\3\0\1\305"+ - "\2\0\26\305\21\0\6\247\1\306\1\0\70\247\1\0"+ - "\2\307\11\0\1\307\1\0\1\307\1\0\1\307\15\0"+ - "\1\307\1\0\1\307\1\0\1\307\2\0\1\307\4\0"+ - "\1\307\3\0\1\307\22\0\2\72\1\0\2\72\6\0"+ - "\3\72\1\0\1\72\1\0\1\72\3\0\1\72\2\0"+ - "\3\72\1\310\22\72\21\0\12\204\1\311\1\255\64\204"+ - "\13\256\1\312\64\256\1\0\2\260\11\0\1\260\1\0"+ - "\1\260\1\0\1\260\1\0\1\210\13\0\1\260\1\0"+ - "\1\260\1\210\1\260\2\0\1\260\4\0\1\260\3\0"+ - "\1\260\21\0\25\212\1\313\52\212\1\0\2\7\1\0"+ + "\2\0\3\7\1\305\22\7\22\0\2\306\1\0\2\306"+ + "\6\0\3\306\1\0\1\306\1\0\1\306\3\0\1\306"+ + "\2\0\26\306\21\0\6\250\1\307\1\0\70\250\1\0"+ + "\2\310\11\0\1\310\1\0\1\310\1\0\1\310\14\0"+ + "\1\310\2\0\1\310\1\0\1\310\3\0\1\310\3\0"+ + "\1\310\3\0\1\310\22\0\2\73\1\0\2\73\6\0"+ + "\3\73\1\0\1\73\1\0\1\73\3\0\1\73\2\0"+ + "\3\73\1\311\22\73\21\0\12\205\1\312\1\256\64\205"+ + "\13\257\1\313\64\257\1\0\2\261\11\0\1\261\1\0"+ + "\1\261\1\0\1\261\1\0\1\211\12\0\1\261\2\0"+ + "\1\261\1\211\1\261\3\0\1\261\3\0\1\261\3\0"+ + "\1\261\21\0\25\213\1\314\52\213\1\0\2\7\1\0"+ "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ - "\1\7\2\0\16\7\1\314\7\7\22\0\2\7\1\0"+ + "\1\7\2\0\17\7\1\315\6\7\22\0\2\7\1\0"+ "\2\7\6\0\3\7\1\0\1\7\1\0\1\7\3\0"+ - "\1\7\2\0\1\315\25\7\22\0\2\7\1\0\2\7"+ + "\1\7\2\0\1\316\25\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\13\7\1\316\12\7\22\0\2\7\1\0\2\7"+ - "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\3\7\1\317\22\7\22\0\2\7\1\0\2\7"+ + "\2\0\14\7\1\317\11\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ "\2\0\2\7\1\320\23\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ "\2\0\3\7\1\321\22\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\11\7\1\322\14\7\22\0\2\7\1\0\2\7"+ + "\2\0\4\7\1\322\21\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\13\7\1\323\12\7\22\0\2\7\1\0\2\7"+ + "\2\0\11\7\1\323\14\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\20\7\1\324\5\7\22\0\2\7\1\0\2\7"+ + "\2\0\14\7\1\324\11\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\7\7\1\325\16\7\22\0\2\7\1\0\2\7"+ + "\2\0\12\7\1\325\13\7\22\0\2\7\1\0\2\7"+ "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ - "\2\0\7\7\1\326\16\7\22\0\2\327\11\0\1\327"+ - "\1\0\1\327\1\0\1\327\15\0\1\327\1\0\1\327"+ - "\1\0\1\327\2\0\1\327\4\0\1\327\3\0\1\327"+ - "\21\0\12\256\1\257\1\312\64\256\25\212\1\330\52\212"+ + "\2\0\7\7\1\326\16\7\22\0\2\7\1\0\2\7"+ + "\6\0\3\7\1\0\1\7\1\0\1\7\3\0\1\7"+ + "\2\0\7\7\1\327\16\7\22\0\2\330\11\0\1\330"+ + "\1\0\1\330\1\0\1\330\14\0\1\330\2\0\1\330"+ + "\1\0\1\330\3\0\1\330\3\0\1\330\3\0\1\330"+ + "\21\0\12\257\1\260\1\313\64\257\25\213\1\331\52\213"+ "\1\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\10\7\1\331\15\7"+ - "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ - "\1\0\1\7\3\0\1\7\2\0\4\7\1\332\21\7"+ + "\1\0\1\7\3\0\1\7\2\0\6\7\1\332\17\7"+ "\22\0\2\7\1\0\2\7\6\0\3\7\1\0\1\7"+ "\1\0\1\7\3\0\1\7\2\0\1\333\25\7\22\0"+ "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ - "\1\7\3\0\1\7\2\0\4\7\1\334\21\7\22\0"+ - "\2\173\11\0\1\173\1\0\1\173\1\0\1\173\15\0"+ - "\1\173\1\0\1\173\1\0\1\173\2\0\1\173\4\0"+ - "\1\173\3\0\1\173\22\0\2\7\1\0\2\7\6\0"+ - "\3\7\1\0\1\7\1\0\1\7\3\0\1\7\2\0"+ - "\5\7\1\335\20\7\22\0\2\7\1\0\2\7\6\0"+ + "\1\7\3\0\1\7\2\0\13\7\1\334\12\7\22\0"+ + "\2\7\1\0\2\7\6\0\3\7\1\0\1\7\1\0"+ + "\1\7\3\0\1\7\2\0\6\7\1\335\17\7\22\0"+ + "\2\174\11\0\1\174\1\0\1\174\1\0\1\174\14\0"+ + "\1\174\2\0\1\174\1\0\1\174\3\0\1\174\3\0"+ + "\1\174\3\0\1\174\22\0\2\7\1\0\2\7\6\0"+ "\3\7\1\0\1\7\1\0\1\7\3\0\1\336\2\0"+ "\26\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+ - "\1\7\1\0\1\7\3\0\1\7\2\0\11\7\1\337"+ - "\14\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+ - "\1\7\1\0\1\7\3\0\1\7\2\0\7\7\1\340"+ + "\1\7\1\0\1\7\3\0\1\7\2\0\7\7\1\337"+ "\16\7\22\0\2\7\1\0\2\7\6\0\3\7\1\0"+ - "\1\7\1\0\1\7\3\0\1\7\2\0\7\7\1\341"+ + "\1\7\1\0\1\7\3\0\1\7\2\0\7\7\1\340"+ "\16\7\21\0"; private static int [] zzUnpackTrans() { - int [] result = new int[9536]; + int [] result = new int[9472]; int offset = 0; offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result); return result; @@ -498,18 +495,18 @@ class _JetLexer implements FlexLexer { private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute(); private static final String ZZ_ATTRIBUTE_PACKED_0 = - "\4\0\1\11\15\1\2\11\21\1\1\11\6\1\10\11"+ + "\4\0\1\11\15\1\2\11\22\1\1\11\6\1\10\11"+ "\1\1\1\11\1\1\1\0\1\11\1\1\1\0\1\1"+ "\2\11\1\0\1\1\1\0\1\1\1\0\1\1\1\0"+ "\1\11\2\1\2\11\4\1\5\11\1\1\1\0\27\1"+ "\1\0\2\1\10\11\1\1\1\0\2\11\1\1\1\0"+ - "\1\1\1\11\1\1\1\11\2\0\2\1\4\0\12\1"+ - "\1\11\20\1\2\11\2\0\1\11\1\1\2\11\1\0"+ + "\1\1\1\11\1\1\1\11\2\0\2\1\4\0\16\1"+ + "\1\11\14\1\2\11\2\0\1\11\1\1\2\11\1\0"+ "\1\1\1\11\1\1\2\0\22\1\2\11\1\0\1\1"+ - "\1\11\2\0\13\1\1\0\1\11\11\1"; + "\1\11\2\0\13\1\1\0\1\11\7\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[225]; + int [] result = new int[224]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -1025,7 +1022,7 @@ class _JetLexer implements FlexLexer { { return JetTokens.MINUSMINUS; } case 142: break; - case 96: + case 97: { return JetTokens.CONTINUE_KEYWORD ; } case 143: break; @@ -1077,7 +1074,7 @@ class _JetLexer implements FlexLexer { { return TokenType.BAD_CHARACTER; } case 155: break; - case 97: + case 96: { return JetTokens.NAMESPACE_KEYWORD ; } case 156: break; diff --git a/compiler/testData/cfg/Basic.instructions b/compiler/testData/cfg/Basic.instructions index 970f555349b..fb9dddf0e69 100644 --- a/compiler/testData/cfg/Basic.instructions +++ b/compiler/testData/cfg/Basic.instructions @@ -121,17 +121,17 @@ sink: NEXT:[] PREV:[] ===================== == flfun == -fun flfun(f : fun () : Any) : Unit {} +fun flfun(f : () -> Any) : Unit {} --------------------- l0: - NEXT:[v(f : fun () : Any)] PREV:[] - v(f : fun () : Any) NEXT:[w(f)] PREV:[] - w(f) NEXT:[read (Unit)] PREV:[v(f : fun () : Any)] - read (Unit) NEXT:[] PREV:[w(f)] + NEXT:[v(f : () -> Any)] PREV:[] + v(f : () -> Any) NEXT:[w(f)] PREV:[] + w(f) NEXT:[read (Unit)] PREV:[v(f : () -> Any)] + read (Unit) NEXT:[] PREV:[w(f)] l1: - NEXT:[] PREV:[read (Unit)] + NEXT:[] PREV:[read (Unit)] error: - NEXT:[] PREV:[] + NEXT:[] PREV:[] sink: - NEXT:[] PREV:[] + NEXT:[] PREV:[] ===================== diff --git a/compiler/testData/cfg/Basic.jet b/compiler/testData/cfg/Basic.jet index 870c40513a0..f71bf2fd807 100644 --- a/compiler/testData/cfg/Basic.jet +++ b/compiler/testData/cfg/Basic.jet @@ -20,4 +20,4 @@ fun foo(a : Boolean, b : Int) : Unit {} fun genfun() : Unit {} -fun flfun(f : fun () : Any) : Unit {} \ No newline at end of file +fun flfun(f : () -> Any) : Unit {} \ No newline at end of file diff --git a/compiler/testData/codegen/PSVM.jet b/compiler/testData/codegen/PSVM.jet index dcef3d78bf1..a53f9b5a26f 100644 --- a/compiler/testData/codegen/PSVM.jet +++ b/compiler/testData/codegen/PSVM.jet @@ -1,4 +1,4 @@ -namespace foo; +package foo; fun main(args : Array) { diff --git a/compiler/testData/codegen/classes/closureWithParameter.jet b/compiler/testData/codegen/classes/closureWithParameter.jet index 0c556d628c1..e0b5d616951 100644 --- a/compiler/testData/codegen/classes/closureWithParameter.jet +++ b/compiler/testData/codegen/classes/closureWithParameter.jet @@ -1,7 +1,7 @@ fun box() : String { - return apply( "OK", {(arg: String) => arg } ) + return apply( "OK", {(arg: String) -> arg } ) } -fun apply(arg : String, f : fun (p:String) : String) : String { +fun apply(arg : String, f : (p:String) -> String) : String { return f(arg) } diff --git a/compiler/testData/codegen/classes/closureWithParameterAndBoxing.jet b/compiler/testData/codegen/classes/closureWithParameterAndBoxing.jet index 6d0a4ffa658..2b64a547d29 100644 --- a/compiler/testData/codegen/classes/closureWithParameterAndBoxing.jet +++ b/compiler/testData/codegen/classes/closureWithParameterAndBoxing.jet @@ -1,7 +1,7 @@ fun box() : String { - return if (apply( 5, {(arg: Int) => arg + 13 } ) == 18) "OK" else "fail" + return if (apply( 5, {(arg: Int) -> arg + 13 } ) == 18) "OK" else "fail" } -fun apply(arg : Int, f : fun (p:Int) : Int) : Int { +fun apply(arg : Int, f : (p:Int) -> Int) : Int { return f(arg) } diff --git a/compiler/testData/codegen/classes/doubleEnclosedLocalVariable.jet b/compiler/testData/codegen/classes/doubleEnclosedLocalVariable.jet index d8e5ea789f2..96ac7f2ef19 100644 --- a/compiler/testData/codegen/classes/doubleEnclosedLocalVariable.jet +++ b/compiler/testData/codegen/classes/doubleEnclosedLocalVariable.jet @@ -3,6 +3,6 @@ fun box() : String { return if (sum(200, { val ff = {cl}; ff() }) == 239) "OK" else "FAIL" } -fun sum(arg:Int, f : fun () : Int) : Int { +fun sum(arg:Int, f : () -> Int) : Int { return arg + f() } diff --git a/compiler/testData/codegen/classes/enclosingLocalVariable.jet b/compiler/testData/codegen/classes/enclosingLocalVariable.jet index d2dbe243469..01e1a103ff2 100644 --- a/compiler/testData/codegen/classes/enclosingLocalVariable.jet +++ b/compiler/testData/codegen/classes/enclosingLocalVariable.jet @@ -3,6 +3,6 @@ fun box() : String { return if (sum(200, { val m = { val r = { cl }; r() }; m() }) == 239) "OK" else "FAIL" } -fun sum(arg:Int, f : fun () : Int) : Int { +fun sum(arg:Int, f : () -> Int) : Int { return arg + f() } diff --git a/compiler/testData/codegen/classes/enclosingThis.jet b/compiler/testData/codegen/classes/enclosingThis.jet index 93ae48c580f..d227b3a2cc9 100644 --- a/compiler/testData/codegen/classes/enclosingThis.jet +++ b/compiler/testData/codegen/classes/enclosingThis.jet @@ -1,10 +1,10 @@ class Point(val x:Int, val y:Int) { - fun mul() : fun (scalar:Int):Point { - return { (scalar:Int):Point => Point(x * scalar, y * scalar) } + fun mul() : (scalar:Int)->Point { + return { (scalar:Int):Point -> Point(x * scalar, y * scalar) } } } -val m = Point(2, 3).mul() : fun (scalar:Int):Point +val m = Point(2, 3).mul() : (scalar:Int)->Point fun box() : String { val answer = m(5) diff --git a/compiler/testData/codegen/classes/extensionClosure.jet b/compiler/testData/codegen/classes/extensionClosure.jet index 11fd11b3816..21307ea42ab 100644 --- a/compiler/testData/codegen/classes/extensionClosure.jet +++ b/compiler/testData/codegen/classes/extensionClosure.jet @@ -1,13 +1,13 @@ class Point(val x : Int, val y : Int) fun box() : String { - val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point => + val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point -> Point(x * scalar, y * scalar) }) return if (answer.x == 6 && answer.y == 10) "OK" else "FAIL" } -fun apply(arg:Point, f : fun Point.(scalar : Int) : Point) : Point { +fun apply(arg:Point, f : Point.(scalar : Int) -> Point) : Point { return arg.f(2) } diff --git a/compiler/testData/codegen/classes/simplestClosure.jet b/compiler/testData/codegen/classes/simplestClosure.jet index c851416e4f1..7a9f3b439cf 100644 --- a/compiler/testData/codegen/classes/simplestClosure.jet +++ b/compiler/testData/codegen/classes/simplestClosure.jet @@ -2,6 +2,6 @@ fun box() : String { return invoker( {"OK"} ) } -fun invoker(gen : fun () : String) : String { +fun invoker(gen : () -> String) : String { return gen() } diff --git a/compiler/testData/codegen/classes/simplestClosureAndBoxing.jet b/compiler/testData/codegen/classes/simplestClosureAndBoxing.jet index 8e3bedb2f37..50f22fbeb8d 100644 --- a/compiler/testData/codegen/classes/simplestClosureAndBoxing.jet +++ b/compiler/testData/codegen/classes/simplestClosureAndBoxing.jet @@ -2,6 +2,6 @@ fun box() : String { return if (int_invoker( { 7 } ) == 7) "OK" else "fail" } -fun int_invoker(gen : fun () : Int) : Int { +fun int_invoker(gen : () -> Int) : Int { return gen() } diff --git a/compiler/testData/codegen/controlStructures/sync.jet b/compiler/testData/codegen/controlStructures/sync.jet index 408db40ca36..6af5e9af150 100644 --- a/compiler/testData/codegen/controlStructures/sync.jet +++ b/compiler/testData/codegen/controlStructures/sync.jet @@ -1,7 +1,7 @@ import java.util.concurrent.* import java.util.concurrent.atomic.* -fun thread(block: fun():Unit ) { +fun thread(block: ()->Unit ) { val thread = object: Thread() { override fun run() { block() diff --git a/compiler/testData/codegen/extensionFunctions/generic.jet b/compiler/testData/codegen/extensionFunctions/generic.jet index fdc73cc4e0e..5b27d7fb271 100644 --- a/compiler/testData/codegen/extensionFunctions/generic.jet +++ b/compiler/testData/codegen/extensionFunctions/generic.jet @@ -1,6 +1,6 @@ import java.util.* -fun ArrayList.findAll(predicate: fun (T) : Boolean): ArrayList { +fun ArrayList.findAll(predicate: (T) -> Boolean): ArrayList { val result = ArrayList() for(val t in this) { if (predicate(t)) result.add(t) @@ -16,6 +16,6 @@ fun box(): String { list.add("Moscow") list.add("Munich") - val m: ArrayList = list.findAll({(name: String) => name.startsWith("M")}) + val m: ArrayList = list.findAll({(name: String) -> name.startsWith("M")}) return if (m.size() == 2) "OK" else "fail" } diff --git a/compiler/testData/codegen/extensionFunctions/shared.kt b/compiler/testData/codegen/extensionFunctions/shared.kt index 216ba549ba3..977376ca391 100644 --- a/compiler/testData/codegen/extensionFunctions/shared.kt +++ b/compiler/testData/codegen/extensionFunctions/shared.kt @@ -2,7 +2,7 @@ fun T.mustBe(t : T) { assert("$this must be $t") {this == t} } -inline fun assert(message : String, condition : fun() : Boolean) { +inline fun assert(message : String, condition : () -> Boolean) { if (!condition()) throw AssertionError(message) } diff --git a/compiler/testData/codegen/extensionFunctions/virtual.jet b/compiler/testData/codegen/extensionFunctions/virtual.jet index 18a774867ac..cc8a6a72f1a 100644 --- a/compiler/testData/codegen/extensionFunctions/virtual.jet +++ b/compiler/testData/codegen/extensionFunctions/virtual.jet @@ -3,7 +3,7 @@ class Request(val path: String) { } class Handler() { - fun Int.times(op: fun(): Unit) { + fun Int.times(op: ()-> Unit) { for(i in 0..this) op() } diff --git a/compiler/testData/codegen/extensionFunctions/whenFail.jet b/compiler/testData/codegen/extensionFunctions/whenFail.jet index 94f1e1492e4..bc38886f110 100644 --- a/compiler/testData/codegen/extensionFunctions/whenFail.jet +++ b/compiler/testData/codegen/extensionFunctions/whenFail.jet @@ -8,7 +8,7 @@ fun StringBuilder.takeFirst(): Char { fun foo(expr: StringBuilder): Int { val c = expr.takeFirst() when(c) { - 0.chr => throw Exception("zero") - else => throw Exception("nonzero" + c) + 0.chr -> throw Exception("zero") + else -> throw Exception("nonzero" + c) } } diff --git a/compiler/testData/codegen/functions/defaultargs.jet b/compiler/testData/codegen/functions/defaultargs.jet index 137e1b3be9e..4278ca81773 100644 --- a/compiler/testData/codegen/functions/defaultargs.jet +++ b/compiler/testData/codegen/functions/defaultargs.jet @@ -5,7 +5,7 @@ fun reformat( divideByCamelHumps : Boolean = true, wordSeparator : String = " " ) = - (normalizeCase, uppercaseFirstLetter, divideByCamelHumps, wordSeparator) + #(normalizeCase, uppercaseFirstLetter, divideByCamelHumps, wordSeparator) trait A { fun bar2(arg: Int = 239) : Int @@ -38,7 +38,7 @@ class C() : B() { fun T.toPrefixedString(prefix: String = "", suffix: String="") = prefix + (this as java.lang.Object).toString() + suffix fun box() : String { - val expected = (true, true, true, " ") + val expected = #(true, true, true, " ") if("mama".toPrefixedString(suffix="321", prefix="papa") != "papamama321") return "fail" if("mama".toPrefixedString(prefix="papa") != "papamama") return "fail" diff --git a/compiler/testData/codegen/functions/functionExpression.jet b/compiler/testData/codegen/functions/functionExpression.jet index 6e9611f2441..aaeadaf0c56 100644 --- a/compiler/testData/codegen/functions/functionExpression.jet +++ b/compiler/testData/codegen/functions/functionExpression.jet @@ -1,24 +1,24 @@ -fun Any.foo1() : fun(): String { +fun Any.foo1() : ()-> String { return { "239" + this } } -fun Int.foo2() : fun(i : Int) : Int { - return { x => x + this } +fun Int.foo2() : (i : Int) -> Int { + return { x -> x + this } } fun fooT1(t : T) = { t.toString() } -fun fooT2(t: T) = { (x:T) => t.toString() + x.toString() } +fun fooT2(t: T) = { (x:T) -> t.toString() + x.toString() } fun box() : String { if( (10.foo1())() != "23910") return "foo1 fail" if( (10.foo2())(1) != 11 ) return "foo2 fail" - if(1.{Int.() => this + 1}() != 2) return "test 3 failed"; + if(1.{Int.() -> this + 1}() != 2) return "test 3 failed"; if( {1}() != 1) return "test 4 failed"; - if( {(x : Int) => x}(1) != 1) return "test 5 failed"; - if( 1.{Int.(x : Int) => x + this}(1) != 2) return "test 6 failed"; - if( 1.({Int.() => this})() != 1) return "test 7 failed"; + if( {(x : Int) -> x}(1) != 1) return "test 5 failed"; + if( 1.{Int.(x : Int) -> x + this}(1) != 2) return "test 6 failed"; + if( 1.({Int.() -> this})() != 1) return "test 7 failed"; if( (fooT1("mama"))() != "mama") return "test 8 failed"; if( (fooT2("mama"))("papa") != "mamapapa") return "test 9 failed"; return "OK" diff --git a/compiler/testData/codegen/functions/nothisnoclosure.jet b/compiler/testData/codegen/functions/nothisnoclosure.jet index a53afefb72e..3c7b59679f2 100644 --- a/compiler/testData/codegen/functions/nothisnoclosure.jet +++ b/compiler/testData/codegen/functions/nothisnoclosure.jet @@ -1,6 +1,6 @@ fun loop(var times : Int) { while(times > 0) { - val u : fun(value : Int) : Unit = { + val u : (value : Int) -> Unit = { System.out?.println(it) } u(times--) diff --git a/compiler/testData/codegen/functions/withtypeparams.jet b/compiler/testData/codegen/functions/withtypeparams.jet index 291ebe1c04b..b88aad83cfb 100644 --- a/compiler/testData/codegen/functions/withtypeparams.jet +++ b/compiler/testData/codegen/functions/withtypeparams.jet @@ -1,5 +1,5 @@ class X () { - fun getTypeChecker() = { (a : Any) => a is T } + fun getTypeChecker() = { (a : Any) -> a is T } } fun box() : String { diff --git a/compiler/testData/codegen/namespaceQualifiedMethod.jet b/compiler/testData/codegen/namespaceQualifiedMethod.jet index b532836e3e2..0a8dd2c6f87 100644 --- a/compiler/testData/codegen/namespaceQualifiedMethod.jet +++ b/compiler/testData/codegen/namespaceQualifiedMethod.jet @@ -1,4 +1,4 @@ -namespace Foo { +package Foo { fun bar() = 610 } diff --git a/compiler/testData/codegen/patternMatching/constant.jet b/compiler/testData/codegen/patternMatching/constant.jet index a6af8ca9236..e74aa2568a2 100644 --- a/compiler/testData/codegen/patternMatching/constant.jet +++ b/compiler/testData/codegen/patternMatching/constant.jet @@ -1,4 +1,4 @@ fun isZero(x: Int) = when(x) { - 0 => true - else => false + 0 -> true + else -> false } diff --git a/compiler/testData/codegen/patternMatching/exceptionOnNoMatch.jet b/compiler/testData/codegen/patternMatching/exceptionOnNoMatch.jet index b8d62ebe77e..f5e668b9faf 100644 --- a/compiler/testData/codegen/patternMatching/exceptionOnNoMatch.jet +++ b/compiler/testData/codegen/patternMatching/exceptionOnNoMatch.jet @@ -1,3 +1,3 @@ fun isZero(x: Int) = when(x) { - 0 => true + 0 -> true } diff --git a/compiler/testData/codegen/patternMatching/is.jet b/compiler/testData/codegen/patternMatching/is.jet index 9fac50c586b..4c8a88fce5c 100644 --- a/compiler/testData/codegen/patternMatching/is.jet +++ b/compiler/testData/codegen/patternMatching/is.jet @@ -1,7 +1,7 @@ fun typeName(a: Any?) : String { return when(a) { - is java.util.ArrayList<*> => "array list" - else => "no idea" + is java.util.ArrayList<*> -> "array list" + else -> "no idea" } } diff --git a/compiler/testData/codegen/patternMatching/pattern.jet b/compiler/testData/codegen/patternMatching/pattern.jet index 25f8167886a..e87965a0fc8 100644 --- a/compiler/testData/codegen/patternMatching/pattern.jet +++ b/compiler/testData/codegen/patternMatching/pattern.jet @@ -1,4 +1,4 @@ fun isString(x: Any) = when(x) { - is String => "string" - else => "something" + is String -> "string" + else -> "something" } diff --git a/compiler/testData/codegen/patternMatching/range.jet b/compiler/testData/codegen/patternMatching/range.jet index 5010f350b68..f1200c681e0 100644 --- a/compiler/testData/codegen/patternMatching/range.jet +++ b/compiler/testData/codegen/patternMatching/range.jet @@ -3,9 +3,9 @@ fun isDigit(a: Int) : String { aa.add(239) return when(a) { - in aa => "array list" - in 0..9 => "digit" - !in 0..100 => "not small" - else => "something" + in aa -> "array list" + in 0..9 -> "digit" + !in 0..100 -> "not small" + else -> "something" } } diff --git a/compiler/testData/codegen/patternMatching/rangeChar.jet b/compiler/testData/codegen/patternMatching/rangeChar.jet index 744855a20eb..7ab6b77512f 100644 --- a/compiler/testData/codegen/patternMatching/rangeChar.jet +++ b/compiler/testData/codegen/patternMatching/rangeChar.jet @@ -1,4 +1,4 @@ fun isDigit(a: Char) = when(a) { - in '0'..'9' => "digit" - else => "something" + in '0'..'9' -> "digit" + else -> "something" } diff --git a/compiler/testData/codegen/regressions/kt237.jet b/compiler/testData/codegen/regressions/kt237.jet index aaa60b5904f..c82ae4277a9 100644 --- a/compiler/testData/codegen/regressions/kt237.jet +++ b/compiler/testData/codegen/regressions/kt237.jet @@ -1,11 +1,11 @@ fun main(args: Array?) { - val y: Unit = () //do not compile + val y: Unit = #() //do not compile A() //do not compile - C(()) //do not compile + C(#()) //do not compile //do not compile - System.out?.println(fff(())) //do not compile + System.out?.println(fff(#())) //do not compile System.out?.println(id(y)) //do not compile - System.out?.println(fff(id(y)) == id(foreach(Array(0,{0}),{(e : Int) : Unit => }))) //do not compile + System.out?.println(fff(id(y)) == id(foreach(Array(0,{0}),{(e : Int) : Unit -> }))) //do not compile } class A() @@ -17,13 +17,13 @@ fun fff(x: T) : T { return x } fun id(value: T): T = value -fun foreach(array: Array?, action: fun(Int): Unit) { +fun foreach(array: Array?, action: (Int)-> Unit) { for (el in array) { action(el) //exception through compilation (see below) } } -fun almostFilter(array: Array, action: fun(Int): Int) { +fun almostFilter(array: Array, action: (Int)-> Int) { for (el in array) { action(el) } @@ -34,8 +34,8 @@ fun box() : String { a[0] = 0 a[1] = 1 a[2] = 2 - foreach(a, { (el : Int) : Unit => System.out?.println(el) }) - almostFilter(a, { (el : Int) : Int => el }) + foreach(a, { (el : Int) : Unit -> System.out?.println(el) }) + almostFilter(a, { (el : Int) : Int -> el }) main(null) return "OK" } \ No newline at end of file diff --git a/compiler/testData/codegen/regressions/kt249.jet b/compiler/testData/codegen/regressions/kt249.jet index bf15ae39c99..e4906c74b27 100644 --- a/compiler/testData/codegen/regressions/kt249.jet +++ b/compiler/testData/codegen/regressions/kt249.jet @@ -1,4 +1,4 @@ -namespace x +package x class Outer() { class object { diff --git a/compiler/testData/codegen/regressions/kt326.jet b/compiler/testData/codegen/regressions/kt326.jet index 3d9b4ad8e54..09ab793d03c 100644 --- a/compiler/testData/codegen/regressions/kt326.jet +++ b/compiler/testData/codegen/regressions/kt326.jet @@ -1,4 +1,4 @@ -namespace test +package test class List(len: Int) { val a : Array = Array(len) diff --git a/compiler/testData/codegen/regressions/kt343.jet b/compiler/testData/codegen/regressions/kt343.jet index 49a8dc9c487..1820bbe0ffb 100644 --- a/compiler/testData/codegen/regressions/kt343.jet +++ b/compiler/testData/codegen/regressions/kt343.jet @@ -1,12 +1,12 @@ import java.util.ArrayList -fun launch(f : fun() : Unit) { +fun launch(f : () -> Unit) { f() } fun box(): String { val list = ArrayList() - val foo : fun() : Unit = { + val foo : () -> Unit = { list.add(2) //first exception } foo() diff --git a/compiler/testData/codegen/regressions/kt344.jet b/compiler/testData/codegen/regressions/kt344.jet index 39a8f550b74..c48a17af8e2 100644 --- a/compiler/testData/codegen/regressions/kt344.jet +++ b/compiler/testData/codegen/regressions/kt344.jet @@ -27,7 +27,7 @@ fun t1() : Boolean { x = x + "45" + y x = x.substring(3) x += "aaa" - () + #() } foo() @@ -43,7 +43,7 @@ fun t2() : Boolean { x = x + 5 + y x += 5 x++ - () + #() } foo() x -= 55 @@ -55,7 +55,7 @@ fun t3() : Boolean { var x = true val foo = { x = false - () + #() } foo() return !x @@ -67,7 +67,7 @@ fun t4() : Boolean { val foo = { x = x + 200.flt + y x += 18 - () + #() } foo() System.out?.println(x) @@ -80,7 +80,7 @@ fun t5() : Boolean { val foo = { x = x + 200.dbl + y x -= 22 - () + #() } foo() System.out?.println(x) @@ -94,7 +94,7 @@ fun t6() : Boolean { x = (x + 20.byt + y).byt x += 2 x-- - () + #() } foo() System.out?.println(x) @@ -105,7 +105,7 @@ fun t7() : Boolean { var x : Char = 'a' val foo = { x = 'b' - () + #() } foo() System.out?.println(x) @@ -117,10 +117,10 @@ fun t8() : Boolean { val foo = { val bar = { x = 30.sht - () + #() } bar() - () + #() } foo() return x == 30.sht diff --git a/compiler/testData/codegen/regressions/kt395.jet b/compiler/testData/codegen/regressions/kt395.jet index 1febc10ffc5..11f1deb9334 100644 --- a/compiler/testData/codegen/regressions/kt395.jet +++ b/compiler/testData/codegen/regressions/kt395.jet @@ -1,6 +1,6 @@ -fun Any.with(operation : fun Any.() : Any) = operation().toString() +fun Any.with(operation : Any.() -> Any) = operation().toString() -val f = { (a : Int) :Unit => } +val f = { (a : Int) :Unit -> } fun box () : String { return if(20.with { diff --git a/compiler/testData/codegen/regressions/kt508.jet b/compiler/testData/codegen/regressions/kt508.jet index 088bd1fd6bd..134aa72670b 100644 --- a/compiler/testData/codegen/regressions/kt508.jet +++ b/compiler/testData/codegen/regressions/kt508.jet @@ -1,4 +1,4 @@ -namespace mult_constructors_3_bug +package mult_constructors_3_bug public open class Identifier() { private var myNullable : Boolean = true diff --git a/compiler/testData/codegen/regressions/kt511.jet b/compiler/testData/codegen/regressions/kt511.jet index a9bc915346c..0fe6d87cc32 100644 --- a/compiler/testData/codegen/regressions/kt511.jet +++ b/compiler/testData/codegen/regressions/kt511.jet @@ -1,4 +1,4 @@ -namespace one_extends_base +package one_extends_base open class Base(name : T?) { var myName : T? diff --git a/compiler/testData/codegen/regressions/kt528.kt b/compiler/testData/codegen/regressions/kt528.kt index 8cfe1707aee..d656fb2f6f7 100644 --- a/compiler/testData/codegen/regressions/kt528.kt +++ b/compiler/testData/codegen/regressions/kt528.kt @@ -1,4 +1,4 @@ -namespace mask +package mask import std.io.* import java.io.* @@ -52,7 +52,7 @@ class Luhny() { fun check() { if (digits.size() < 14) return print("check") - val sum = digits.sum { i, d => + val sum = digits.sum { i, d -> // println("$i -> $d") if (i % 2 == digits.size()) { val f = d * 2 / 10 @@ -94,12 +94,12 @@ class Luhny() { } } -fun T.pr(f : fun(T) : Unit) : T { +fun T.pr(f : (T) -> Unit) : T { f(this) return this } -fun LinkedList.sum(f : fun(Int, Int ): Int): Int { +fun LinkedList.sum(f : (Int, Int )-> Int): Int { var sum = 0 for (i in 1..size()) { val j = size() - i @@ -120,7 +120,7 @@ fun LinkedList.sum(f : fun(Int, Int ): Int): Int { fun Char.isDigit() = Character.isDigit(this) -fun Reader.forEachChar(body : fun(Char) : Unit) { +fun Reader.forEachChar(body : (Char) -> Unit) { do { var i = read(); if (i == -1) break diff --git a/compiler/testData/codegen/regressions/kt529.kt b/compiler/testData/codegen/regressions/kt529.kt index 84a6d3edc52..546a345b1c7 100644 --- a/compiler/testData/codegen/regressions/kt529.kt +++ b/compiler/testData/codegen/regressions/kt529.kt @@ -1,4 +1,4 @@ -namespace mask +package mask import std.io.* import java.io.* @@ -46,7 +46,7 @@ class Luhny() { private fun check() { val size = digits.size() if (size < 14) return - val sum = digits.sum {i, d => + val sum = digits.sum {i, d -> if (i % 2 == size % 2) double(d) else d } // var sum = 0 @@ -89,7 +89,7 @@ class Luhny() { fun Char.isDigit() = Character.isDigit(this) -fun java.lang.Iterable.sum(f : fun(index : Int, value : Int) : Int) : Int { +fun java.lang.Iterable.sum(f : (index : Int, value : Int) -> Int) : Int { var sum = 0 var i = 0 for (d in this) { @@ -99,7 +99,7 @@ fun java.lang.Iterable.sum(f : fun(index : Int, value : Int) : Int) : Int { return sum } -fun Reader.forEachChar(body : fun(Char) : Unit) { +fun Reader.forEachChar(body : (Char) -> Unit) { do { var i = read(); if (i == -1) break diff --git a/compiler/testData/codegen/regressions/kt533.kt b/compiler/testData/codegen/regressions/kt533.kt index 7e7ef961ffd..3ad813a6e0b 100644 --- a/compiler/testData/codegen/regressions/kt533.kt +++ b/compiler/testData/codegen/regressions/kt533.kt @@ -1,4 +1,4 @@ -namespace mask +package mask import std.io.* import java.io.* @@ -50,7 +50,7 @@ class Luhny() { fun check() { if (digits.size() < 14) return - val sum = digits.sum { i, d => + val sum = digits.sum { i, d -> if (i % 2 != 0) d * 2 / 10 + d * 2 % 10 else d @@ -85,7 +85,7 @@ class Luhny() { } } -fun LinkedList.sum(f : fun(Int, Int) : Int) : Int { +fun LinkedList.sum(f : (Int, Int) -> Int) : Int { var sum = 0 var i = 0 for (d in backwards()) { @@ -136,7 +136,7 @@ fun Char.isDigit() = Character.isDigit(this) // fun clear() {} //} -fun Reader.forEachChar(body : fun(Char) : Unit) { +fun Reader.forEachChar(body : (Char) -> Unit) { do { var i = read(); if (i == -1) break diff --git a/compiler/testData/codegen/regressions/kt560.jet b/compiler/testData/codegen/regressions/kt560.jet index 630cf37d654..cb3944e1f27 100644 --- a/compiler/testData/codegen/regressions/kt560.jet +++ b/compiler/testData/codegen/regressions/kt560.jet @@ -1,4 +1,4 @@ -namespace while_bug_1 +package while_bug_1 import java.io.* diff --git a/compiler/testData/codegen/regressions/kt581.jet b/compiler/testData/codegen/regressions/kt581.jet index 0f8d7162122..4480994e57e 100644 --- a/compiler/testData/codegen/regressions/kt581.jet +++ b/compiler/testData/codegen/regressions/kt581.jet @@ -1,4 +1,4 @@ -namespace whats.the.difference +package whats.the.difference import java.util.HashSet diff --git a/compiler/testData/codegen/regressions/kt594.jet b/compiler/testData/codegen/regressions/kt594.jet index 70d94715100..93c5580e600 100644 --- a/compiler/testData/codegen/regressions/kt594.jet +++ b/compiler/testData/codegen/regressions/kt594.jet @@ -1,4 +1,4 @@ -namespace array_test +package array_test fun box() : String { var array : IntArray? = IntArray(10) diff --git a/compiler/testData/codegen/regressions/kt613.jet b/compiler/testData/codegen/regressions/kt613.jet index 463b77aa909..b35b35959a4 100644 --- a/compiler/testData/codegen/regressions/kt613.jet +++ b/compiler/testData/codegen/regressions/kt613.jet @@ -1,4 +1,4 @@ -namespace name +package name class Test() { var i = 5 diff --git a/compiler/testData/codegen/regressions/kt640.jet b/compiler/testData/codegen/regressions/kt640.jet index 705fc1f338c..4171c7419c5 100644 --- a/compiler/testData/codegen/regressions/kt640.jet +++ b/compiler/testData/codegen/regressions/kt640.jet @@ -1,4 +1,4 @@ -namespace demo +package demo public open class Identifier(myName : T?, myHasDollar : Boolean) { { diff --git a/compiler/testData/codegen/regressions/kt684.jet b/compiler/testData/codegen/regressions/kt684.jet index 41048cec7c5..21fb4860c63 100644 --- a/compiler/testData/codegen/regressions/kt684.jet +++ b/compiler/testData/codegen/regressions/kt684.jet @@ -1,8 +1,8 @@ fun escapeChar(c : Char) : String? = when (c) { - '\\' => "\\\\" - '\n' => "\\n" - '"' => "\\\"" - else => String.valueOf(c) + '\\' -> "\\\\" + '\n' -> "\\n" + '"' -> "\\\"" + else -> String.valueOf(c) } fun String.escape(i : Int = 0, result : String = "") : String = diff --git a/compiler/testData/codegen/regressions/kt694.jet b/compiler/testData/codegen/regressions/kt694.jet index 698558d3642..f45c6815711 100644 --- a/compiler/testData/codegen/regressions/kt694.jet +++ b/compiler/testData/codegen/regressions/kt694.jet @@ -1,4 +1,4 @@ -namespace org2 +package org2 enum class Test { A diff --git a/compiler/testData/codegen/regressions/kt707.jet b/compiler/testData/codegen/regressions/kt707.jet index 47d245455aa..a12afa2b3cd 100644 --- a/compiler/testData/codegen/regressions/kt707.jet +++ b/compiler/testData/codegen/regressions/kt707.jet @@ -1,6 +1,6 @@ class List(val head: T, val tail: List? = null) -fun List.mapHead(f: fun(T): T): List = List(f(head), null) +fun List.mapHead(f: (T)-> T): List = List(f(head), null) fun box() : String { val a: Int = List(1).mapHead{it * 2}.head diff --git a/compiler/testData/codegen/regressions/kt752.jet b/compiler/testData/codegen/regressions/kt752.jet index 20132c9f6a8..2f6ab3d7d69 100644 --- a/compiler/testData/codegen/regressions/kt752.jet +++ b/compiler/testData/codegen/regressions/kt752.jet @@ -1,4 +1,4 @@ -namespace demo_range +package demo_range fun Int?.rangeTo(other : Int?) : IntRange = this.sure().rangeTo(other.sure()) diff --git a/compiler/testData/codegen/regressions/kt753.jet b/compiler/testData/codegen/regressions/kt753.jet index a1b81de8138..75a54b5ca33 100644 --- a/compiler/testData/codegen/regressions/kt753.jet +++ b/compiler/testData/codegen/regressions/kt753.jet @@ -1,4 +1,4 @@ -namespace bitwise_demo +package bitwise_demo fun Long?.shl(bits : Int?) : Long = this.sure().shl(bits.sure()) diff --git a/compiler/testData/codegen/regressions/kt756.jet b/compiler/testData/codegen/regressions/kt756.jet index 4cff1aecd11..e47c2612f1f 100644 --- a/compiler/testData/codegen/regressions/kt756.jet +++ b/compiler/testData/codegen/regressions/kt756.jet @@ -1,4 +1,4 @@ -namespace demo_range +package demo_range fun Int?.plus() : Int = this.sure().plus() fun Int?.dec() : Int = this.sure().dec() diff --git a/compiler/testData/codegen/regressions/kt757.jet b/compiler/testData/codegen/regressions/kt757.jet index 8ddfb3d879a..925391944fb 100644 --- a/compiler/testData/codegen/regressions/kt757.jet +++ b/compiler/testData/codegen/regressions/kt757.jet @@ -1,4 +1,4 @@ -namespace demo_long +package demo_long fun Long?.inv() : Long = this.sure().inv() diff --git a/compiler/testData/codegen/regressions/kt769.jet b/compiler/testData/codegen/regressions/kt769.jet index 266af79d867..0bfe012e7be 100644 --- a/compiler/testData/codegen/regressions/kt769.jet +++ b/compiler/testData/codegen/regressions/kt769.jet @@ -1,10 +1,10 @@ -namespace w_range +package w_range fun box() : String { var i = 0 when (i) { - 1 => i-- - else => { i = 2 } + 1 -> i-- + else -> { i = 2 } } System.out?.println(i) return "OK" diff --git a/compiler/testData/codegen/regressions/kt772.jet b/compiler/testData/codegen/regressions/kt772.jet index 6cad8d6ae03..bb45a0c94d1 100644 --- a/compiler/testData/codegen/regressions/kt772.jet +++ b/compiler/testData/codegen/regressions/kt772.jet @@ -1,18 +1,18 @@ -namespace demo2 +package demo2 fun print(o : Any?) {} fun test(i : Int) { var monthString : String? = "" when (i) { - 1 => { + 1 -> { print(1) print(2) print(3) print(4) print(5) } - else => { + else -> { monthString = "Invalid month" } } diff --git a/compiler/testData/codegen/regressions/kt773.jet b/compiler/testData/codegen/regressions/kt773.jet index 6cad8d6ae03..bb45a0c94d1 100644 --- a/compiler/testData/codegen/regressions/kt773.jet +++ b/compiler/testData/codegen/regressions/kt773.jet @@ -1,18 +1,18 @@ -namespace demo2 +package demo2 fun print(o : Any?) {} fun test(i : Int) { var monthString : String? = "" when (i) { - 1 => { + 1 -> { print(1) print(2) print(3) print(4) print(5) } - else => { + else -> { monthString = "Invalid month" } } diff --git a/compiler/testData/codegen/regressions/kt785.jet b/compiler/testData/codegen/regressions/kt785.jet index 1b10c8c73d7..add8bb72789 100644 --- a/compiler/testData/codegen/regressions/kt785.jet +++ b/compiler/testData/codegen/regressions/kt785.jet @@ -1,7 +1,7 @@ class A() { var x : Int = 0 - var z = { () => + var z = { () -> x++ } } diff --git a/compiler/testData/codegen/regressions/kt789.jet b/compiler/testData/codegen/regressions/kt789.jet index e071cfdf507..79014973767 100644 --- a/compiler/testData/codegen/regressions/kt789.jet +++ b/compiler/testData/codegen/regressions/kt789.jet @@ -1,4 +1,4 @@ -namespace foo +package foo import java.util.*; diff --git a/compiler/testData/codegen/regressions/kt828.kt b/compiler/testData/codegen/regressions/kt828.kt index 34801b54b8d..06e63bec23c 100644 --- a/compiler/testData/codegen/regressions/kt828.kt +++ b/compiler/testData/codegen/regressions/kt828.kt @@ -1,4 +1,4 @@ -namespace demo +package demo fun box() : String { var res : Boolean = true diff --git a/compiler/testData/codegen/regressions/kt857.jet b/compiler/testData/codegen/regressions/kt857.jet new file mode 100644 index 00000000000..3335eeac8b5 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt857.jet @@ -0,0 +1,7 @@ +package container_test + +class Container(var t : T) { + fun getT() : T = t +} + +fun box() = Container("OK").getT() diff --git a/compiler/testData/codegen/regressions/kt870.jet b/compiler/testData/codegen/regressions/kt870.jet new file mode 100644 index 00000000000..9f83928b716 --- /dev/null +++ b/compiler/testData/codegen/regressions/kt870.jet @@ -0,0 +1,5 @@ +fun box() = when { + 1 > 2 -> "false" + 1 >= 1 -> "OK" + else -> "else" + } \ No newline at end of file diff --git a/compiler/testData/codegen/traits/stdlib.jet b/compiler/testData/codegen/traits/stdlib.jet index af0db549b40..235263a95eb 100644 --- a/compiler/testData/codegen/traits/stdlib.jet +++ b/compiler/testData/codegen/traits/stdlib.jet @@ -36,7 +36,7 @@ trait WriteOnlyArray : ISized { } } -class MutableArray(length: Int, init : fun(Int) : T) : ReadOnlyArray, WriteOnlyArray { +class MutableArray(length: Int, init : (Int) -> T) : ReadOnlyArray, WriteOnlyArray { private val array = Array(length, init) override fun get(index : Int) : T = array[index] diff --git a/compiler/testData/compiler/smoke/Smoke.kt b/compiler/testData/compiler/smoke/Smoke.kt index d41ccce56b7..c5ece2faf60 100644 --- a/compiler/testData/compiler/smoke/Smoke.kt +++ b/compiler/testData/compiler/smoke/Smoke.kt @@ -1,4 +1,4 @@ -namespace Smoke +package Smoke import std.io.* diff --git a/compiler/testData/compiler/smoke/Smoke.kts b/compiler/testData/compiler/smoke/Smoke.kts index 6cdcff74a64..d9429cd1b65 100644 --- a/compiler/testData/compiler/smoke/Smoke.kts +++ b/compiler/testData/compiler/smoke/Smoke.kts @@ -1,8 +1,6 @@ -import kotlin.modules.ModuleSetBuilder +import kotlin.modules.* -fun ModuleSetBuilder.defineModules() { - module("smoke") { - source files "Smoke.kt" - jar name System.getProperty("java.io.tmpdir") + "/smoke.jar" - } +val modules = module("smoke") { + source files "Smoke.kt" + jar name System.getProperty("java.io.tmpdir") + "/smoke.jar" } diff --git a/compiler/testData/diagnostics/checkerTestUtil/test.jet b/compiler/testData/diagnostics/checkerTestUtil/test.jet index e78606b8885..699dfbd5ce5 100644 --- a/compiler/testData/diagnostics/checkerTestUtil/test.jet +++ b/compiler/testData/diagnostics/checkerTestUtil/test.jet @@ -2,7 +2,7 @@ fun foo(u : Unit) : Int = 1 fun test() : Int { foo(1) - val a : fun() : Unit = { + val a : () -> Unit = { foo(1) } return 1 - "1" diff --git a/compiler/testData/diagnostics/tests/Abstract.jet b/compiler/testData/diagnostics/tests/Abstract.jet index d36e7769f63..30cb42c416d 100644 --- a/compiler/testData/diagnostics/tests/Abstract.jet +++ b/compiler/testData/diagnostics/tests/Abstract.jet @@ -1,6 +1,6 @@ // +JDK -namespace abstract +package abstract class MyClass() { //properties @@ -180,7 +180,7 @@ enum class MyEnum() { abstract enum class MyAbstractEnum() {} -namespace MyNamespace { +package MyNamespace { //properties val a: Int val a1: Int = 1 diff --git a/compiler/testData/diagnostics/tests/AutoCreatedIt.jet b/compiler/testData/diagnostics/tests/AutoCreatedIt.jet index b9aa7b90c6b..c89b3d01850 100644 --- a/compiler/testData/diagnostics/tests/AutoCreatedIt.jet +++ b/compiler/testData/diagnostics/tests/AutoCreatedIt.jet @@ -1,10 +1,10 @@ fun text() { "direct:a" to "mock:a" "direct:a" on {it.body == ""} to "mock:a" - "direct:a" on {it => it.body == ""} to "mock:a" + "direct:a" on {it -> it.body == ""} to "mock:a" bar {1} bar {it + 1} - bar {it, it1 => it} + bar {it, it1 -> it} bar1 {1} bar1 {it + 1} @@ -12,18 +12,18 @@ fun text() { bar2 {} bar2 {1} bar2 {it} - bar2 {it => it} + bar2 {it -> it} } -fun bar(f : fun (Int, Int) : Int) {} -fun bar1(f : fun (Int) : Int) {} -fun bar2(f : fun () : Int) {} +fun bar(f : (Int, Int) -> Int) {} +fun bar1(f : (Int) -> Int) {} +fun bar2(f : () -> Int) {} fun String.to(dest : String) { } -fun String.on(predicate : fun (s : URI) : Boolean) : URI { +fun String.on(predicate : (s : URI) -> Boolean) : URI { return URI(this) } diff --git a/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.jet b/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.jet index f6ccdfc8a0a..82805cf8bfb 100644 --- a/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.jet +++ b/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.jet @@ -1,6 +1,6 @@ -namespace example; +package example; -namespace ns { +package ns { val y : Any? = 2 } diff --git a/compiler/testData/diagnostics/tests/Basic.jet b/compiler/testData/diagnostics/tests/Basic.jet index 4dc3161b26a..0a0673ca5eb 100644 --- a/compiler/testData/diagnostics/tests/Basic.jet +++ b/compiler/testData/diagnostics/tests/Basic.jet @@ -2,7 +2,7 @@ fun foo(u : Unit) : Int = 1 fun test() : Int { foo(1) - val a : fun() : Unit = { + val a : () -> Unit = { foo(1) } return 1 - "1" diff --git a/compiler/testData/diagnostics/tests/Bounds.jet b/compiler/testData/diagnostics/tests/Bounds.jet index 37066cb74ab..e2b7cf1ce86 100644 --- a/compiler/testData/diagnostics/tests/Bounds.jet +++ b/compiler/testData/diagnostics/tests/Bounds.jet @@ -1,4 +1,4 @@ -namespace boundsWithSubstitutors { +package boundsWithSubstitutors { open class A class B>() @@ -18,10 +18,10 @@ namespace boundsWithSubstitutors { open class A {} open class B() - abstract class CInt>, X : fun (B<Char>) : (B<Any>, B)>() : B<Any>() { // 2 errors + abstract class CInt>, X : (B<Char>) -> #(B<Any>, B)>() : B<Any>() { // 2 errors val a = B<Char>() // error - abstract val x : fun (B<Char>) : B<Any> + abstract val x : (B<Char>) -> B<Any> } diff --git a/compiler/testData/diagnostics/tests/Builders.jet b/compiler/testData/diagnostics/tests/Builders.jet index 10791f68875..497950f941f 100644 --- a/compiler/testData/diagnostics/tests/Builders.jet +++ b/compiler/testData/diagnostics/tests/Builders.jet @@ -2,7 +2,7 @@ import java.util.* -namespace html { +package html { abstract class Factory { abstract fun create() : T @@ -16,7 +16,7 @@ namespace html { val children = ArrayList() val attributes = HashMap() - protected fun initTag(init : fun T.() : Unit) : T + protected fun initTag(init : T.() -> Unit) : T where class object T : Factory{ val tag = T.create() tag.init() @@ -36,9 +36,9 @@ namespace html { override fun create() = HTML() } - fun head(init : fun Head.() : Unit) = initTag(init) + fun head(init : Head.() -> Unit) = initTag(init) - fun body(init : fun Body.() : Unit) = initTag(init) + fun body(init : Body.() -> Unit) = initTag(init) } class Head() : TagWithText("head") { @@ -46,7 +46,7 @@ namespace html { override fun create() = Head() } - fun title(init : fun Title.() : Unit) = initTag(init) + fun title(init : Title.() -> Unit) = initTag<Title>(init) } class Title() : TagWithText("title") @@ -59,10 +59,10 @@ namespace html { override fun create() = Body() } - fun b(init : fun B.() : Unit) = initTag<B>(init) - fun p(init : fun P.() : Unit) = initTag<P>(init) - fun h1(init : fun H1.() : Unit) = initTag<H1>(init) - fun a(href : String, init : fun A.() : Unit) { + fun b(init : B.() -> Unit) = initTag<B>(init) + fun p(init : P.() -> Unit) = initTag<P>(init) + fun h1(init : H1.() -> Unit) = initTag<H1>(init) + fun a(href : String, init : A.() -> Unit) { val a = initTag<A>(init) a.href = href } @@ -79,7 +79,7 @@ namespace html { fun Map<String, String>.set(key : String, value : String) = this.put(key, value) - fun html(init : fun HTML.() : Unit) : HTML { + fun html(init : HTML.() -> Unit) : HTML { val html = HTML() html.init() return html @@ -87,7 +87,7 @@ namespace html { } -namespace foo { +package foo { import html.* diff --git a/compiler/testData/diagnostics/tests/Casts.jet b/compiler/testData/diagnostics/tests/Casts.jet index 163619fd4d0..b63af35a916 100644 --- a/compiler/testData/diagnostics/tests/Casts.jet +++ b/compiler/testData/diagnostics/tests/Casts.jet @@ -12,5 +12,5 @@ fun test() : Unit { y <!USELESS_CAST!>as?<!> Int : Int? x <!USELESS_CAST!>as?<!> Int? : Int? y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as?<!> Int? : Int? - () + #() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/ClassObjects.jet b/compiler/testData/diagnostics/tests/ClassObjects.jet index f933004a4d5..019fc084e6f 100644 --- a/compiler/testData/diagnostics/tests/ClassObjects.jet +++ b/compiler/testData/diagnostics/tests/ClassObjects.jet @@ -1,6 +1,6 @@ // +JDK -namespace Jet86 +package Jet86 class A { class object { diff --git a/compiler/testData/diagnostics/tests/ConflictingOverloads.jet b/compiler/testData/diagnostics/tests/ConflictingOverloads.jet index 6f13050d3ae..bb5554d2d32 100644 --- a/compiler/testData/diagnostics/tests/ConflictingOverloads.jet +++ b/compiler/testData/diagnostics/tests/ConflictingOverloads.jet @@ -13,7 +13,7 @@ class A { } } -namespace deepSpace { +package deepSpace { <!CONFLICTING_OVERLOADS!>fun c(<!UNUSED_PARAMETER!>s<!>: String)<!> { } @@ -32,23 +32,23 @@ namespace deepSpace { // check no error in overload in different namespaces -namespace ns1 { +package ns1 { fun e() = 1 } -namespace ns2 { +package ns2 { fun e() = 1 } -namespace ns3 { - namespace ns1 { +package ns3 { + package ns1 { fun e() = 1 } } // check same rules apply for ext functions -namespace extensionFunctions { +package extensionFunctions { <!CONFLICTING_OVERLOADS!>fun Int.qwe(<!UNUSED_PARAMETER!>a<!>: Float)<!> = 1 <!CONFLICTING_OVERLOADS!>fun Int.qwe(<!UNUSED_PARAMETER!>a<!>: Float)<!> = 2 @@ -60,7 +60,7 @@ namespace extensionFunctions { // check no error when regular function and extension function have same name -namespace extensionAndRegular { +package extensionAndRegular { fun who() = 1 fun Int.who() = 1 @@ -68,7 +68,7 @@ namespace extensionAndRegular { // constructor vs. fun overload -namespace constructorVsFun { +package constructorVsFun { class <!CONFLICTING_OVERLOADS!>a()<!> { } <!CONFLICTING_OVERLOADS!>fun a()<!> = 1 diff --git a/compiler/testData/diagnostics/tests/Dollar.jet b/compiler/testData/diagnostics/tests/Dollar.jet index 7966eb21ab9..1adf1bd99ea 100644 --- a/compiler/testData/diagnostics/tests/Dollar.jet +++ b/compiler/testData/diagnostics/tests/Dollar.jet @@ -1,4 +1,4 @@ -namespace dollar +package dollar open class `$$$$$`() { } diff --git a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.jet b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.jet index 852e49c45fe..32fc8be4b84 100644 --- a/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.jet +++ b/compiler/testData/diagnostics/tests/FunctionCalleeExpressions.jet @@ -1,22 +1,22 @@ -namespace foo +package foo -fun Any.foo() : fun() : Unit { +fun Any.foo() : () -> Unit { return {} } -fun Any.foo1() : fun(i : Int) : Unit { +fun Any.foo1() : (i : Int) -> Unit { return {} } -fun foo2() : fun(i : fun()) : Unit { +fun foo2() : (i : () -> Unit) -> Unit { return {} } -fun fooT1<T>(t : T) : fun() : T { +fun fooT1<T>(t : T) : () -> T { return {t} } -fun fooT2<T>() : fun(t : T) : T { +fun fooT2<T>() : (t : T) -> T { return {it} } @@ -34,8 +34,8 @@ fun main(args : Array<String>) { foo2()({}) foo2()<!TOO_MANY_ARGUMENTS!>{}<!> (foo2()){} - (foo2())<!TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE!>x<!> => }<!> - foo2()(<!TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE!>x<!> => }<!>) + (foo2())<!TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE!>x<!> -> }<!> + foo2()(<!TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE!>x<!> -> }<!>) val a = fooT1(1)() a : Int @@ -49,19 +49,19 @@ fun main(args : Array<String>) { <!CALLEE_NOT_A_FUNCTION!>1<!>(){} } -fun f() : fun Int.() : Unit = {} +fun f() : Int.() -> Unit = {} fun main1() { - 1.{Int.() => 1}(); + 1.{Int.() -> 1}(); {1}() - {(x : Int) => x}(1) - 1.{Int.(x : Int) => x}(1) + {(x : Int) -> x}(1) + 1.{Int.(x : Int) -> x}(1) @l{1}() - 1.({Int.() => 1})() + 1.({Int.() -> 1})() 1.(f())() 1.if(true){f()}else{f()}() - 1.if(true){Int.() => 1}else{f()}() - 1.if(true){Int.() => 1}else{Int.() => 1}() + 1.if(true){Int.() -> 1}else{f()}() + 1.if(true){Int.() -> 1}else{Int.() -> 1}() 1.<!CALLEE_NOT_A_FUNCTION!>"sdf"<!>() @@ -71,12 +71,12 @@ fun main1() { } fun test() { - {(x : Int) => 1}<!NO_VALUE_FOR_PARAMETER!>()<!> - <!MISSING_RECEIVER!>{Int.() => 1}<!>() - <!TYPE_MISMATCH!>"sd"<!>.{Int.() => 1}() + {(x : Int) -> 1}<!NO_VALUE_FOR_PARAMETER!>()<!> + <!MISSING_RECEIVER!>{Int.() -> 1}<!>() + <!TYPE_MISMATCH!>"sd"<!>.{Int.() -> 1}() val i : Int? = null - i<!UNSAFE_CALL!>.<!>{Int.() => 1}() + i<!UNSAFE_CALL!>.<!>{Int.() -> 1}() {}<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>() - 1<!UNNECESSARY_SAFE_CALL!>?.<!>{Int.() => 1}() + 1<!UNNECESSARY_SAFE_CALL!>?.<!>{Int.() -> 1}() 1.<!NO_RECEIVER_ADMITTED!>{}<!>() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/FunctionReturnTypes.jet b/compiler/testData/diagnostics/tests/FunctionReturnTypes.jet index 0bab0cf8335..11d8bcde513 100644 --- a/compiler/testData/diagnostics/tests/FunctionReturnTypes.jet +++ b/compiler/testData/diagnostics/tests/FunctionReturnTypes.jet @@ -6,11 +6,11 @@ fun unitEmptyInfer() {} fun unitEmpty() : Unit {} fun unitEmptyReturn() : Unit {return} fun unitIntReturn() : Unit {return <!TYPE_MISMATCH!>1<!>} -fun unitUnitReturn() : Unit {return ()} +fun unitUnitReturn() : Unit {return #()} fun test1() : Any = {<!RETURN_TYPE_MISMATCH, RETURN_NOT_ALLOWED!>return<!>} fun test2() : Any = @a {return@a 1} fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> } -fun test4(): fun(): Unit = { <!RETURN_TYPE_MISMATCH, RETURN_NOT_ALLOWED!>return@test4<!> } +fun test4(): ()-> Unit = { <!RETURN_TYPE_MISMATCH, RETURN_NOT_ALLOWED!>return@test4<!> } fun test5(): Any = @{ return@ } fun test6(): Any = {<!RETURN_NOT_ALLOWED!>return 1<!>} @@ -21,13 +21,13 @@ fun bbb() { fun foo(<!UNUSED_PARAMETER!>expr<!>: StringBuilder): Int { val c = 'a' when(c) { - 0.chr => throw Exception("zero") - else => throw Exception("nonzero" + c) + 0.chr -> throw Exception("zero") + else -> throw Exception("nonzero" + c) } } -fun unitShort() : Unit = () +fun unitShort() : Unit = #() fun unitShortConv() : Unit = <!TYPE_MISMATCH!>1<!> fun unitShortNull() : Unit = <!TYPE_MISMATCH!>null<!> @@ -44,7 +44,7 @@ fun intFunctionLiteral(): Int = <!TYPE_MISMATCH!>{ 10 }<!> fun blockReturnUnitMismatch() : Int {<!RETURN_TYPE_MISMATCH!>return<!>} fun blockReturnValueTypeMismatch() : Int {return <!ERROR_COMPILE_TIME_VALUE!>3.4<!>} fun blockReturnValueTypeMatch() : Int {return 1} -fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>()<!>} +fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>#()<!>} fun blockAndAndMismatch() : Int { <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true && false<!> @@ -176,37 +176,37 @@ class B() { } fun testFunctionLiterals() { - val <!UNUSED_VARIABLE!>endsWithVarDeclaration<!> : fun() : Boolean = { + val <!UNUSED_VARIABLE!>endsWithVarDeclaration<!> : () -> Boolean = { <!EXPECTED_TYPE_MISMATCH!>val x = 2<!> } - val <!UNUSED_VARIABLE!>endsWithAssignment<!> = { () : Int => + val <!UNUSED_VARIABLE!>endsWithAssignment<!> = { () : Int -> var x = 1 <!EXPECTED_TYPE_MISMATCH!>x = 333<!> } - val <!UNUSED_VARIABLE!>endsWithReAssignment<!> = { () : Int => + val <!UNUSED_VARIABLE!>endsWithReAssignment<!> = { () : Int -> var x = 1 <!ASSIGNMENT_TYPE_MISMATCH!>x += 333<!> } - val <!UNUSED_VARIABLE!>endsWithFunDeclaration<!> : fun() : String = { + val <!UNUSED_VARIABLE!>endsWithFunDeclaration<!> : () -> String = { var x = 1 x = 333 <!EXPECTED_TYPE_MISMATCH!>fun meow() : Unit {}<!> } - val <!UNUSED_VARIABLE!>endsWithObjectDeclaration<!> : fun() : Int = { + val <!UNUSED_VARIABLE!>endsWithObjectDeclaration<!> : () -> Int = { var x = 1 x = 333 <!EXPECTED_TYPE_MISMATCH!>object A {}<!> } - val <!UNUSED_VARIABLE!>expectedUnitReturnType1<!> = { () : Unit => + val <!UNUSED_VARIABLE!>expectedUnitReturnType1<!> = { () : Unit -> val x = 1 } - val <!UNUSED_VARIABLE!>expectedUnitReturnType2<!> = { () : Unit => + val <!UNUSED_VARIABLE!>expectedUnitReturnType2<!> = { () : Unit -> fun meow() : Unit {} object A {} } diff --git a/compiler/testData/diagnostics/tests/GenericArgumentConsistency.jet b/compiler/testData/diagnostics/tests/GenericArgumentConsistency.jet index fafd2cf98c8..b9ab728653d 100644 --- a/compiler/testData/diagnostics/tests/GenericArgumentConsistency.jet +++ b/compiler/testData/diagnostics/tests/GenericArgumentConsistency.jet @@ -13,28 +13,28 @@ trait BB1 : BA1<Int> {} trait BB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>BA1<Any>, BB1<!> {} -namespace x { +package x { trait AA1<out T> {} trait AB1 : AA1<Int> {} trait AB3 : AA1<Comparable<Int>> {} trait AB2 : AA1<Number>, AB1, AB3 {} } -namespace x2 { +package x2 { trait AA1<out T> {} trait AB1 : AA1<Any> {} trait AB3 : AA1<Comparable<Int>> {} trait AB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>AA1<Number>, AB1, AB3<!> {} } -namespace x3 { +package x3 { trait AA1<in T> {} trait AB1 : AA1<Any> {} trait AB3 : AA1<Comparable<Int>> {} trait AB2 : AA1<Number>, AB1, AB3 {} } -namespace sx2 { +package sx2 { trait AA1<in T> {} trait AB1 : AA1<Int> {} trait AB3 : AA1<Comparable<Int>> {} diff --git a/compiler/testData/diagnostics/tests/IllegalModifiers.jet b/compiler/testData/diagnostics/tests/IllegalModifiers.jet index a3585e341de..94e23907adf 100644 --- a/compiler/testData/diagnostics/tests/IllegalModifiers.jet +++ b/compiler/testData/diagnostics/tests/IllegalModifiers.jet @@ -1,4 +1,4 @@ -namespace illegal_modifiers +package illegal_modifiers abstract class A() { <!INCOMPATIBLE_MODIFIERS!>abstract<!> <!INCOMPATIBLE_MODIFIERS!>final<!> fun f() diff --git a/compiler/testData/diagnostics/tests/ImportResolutionOrder.jet b/compiler/testData/diagnostics/tests/ImportResolutionOrder.jet index acaeadc053c..7e0ecfe19e0 100644 --- a/compiler/testData/diagnostics/tests/ImportResolutionOrder.jet +++ b/compiler/testData/diagnostics/tests/ImportResolutionOrder.jet @@ -1,22 +1,22 @@ // KT-355 Resolve imports after all symbols are built -namespace a { +package a { import b.* val x : X = X() } -namespace b { +package b { class X() { } } -namespace c { +package c { import d.X val x : X = X() } -namespace d { +package d { class X() { } diff --git a/compiler/testData/diagnostics/tests/LValueAssignment.jet b/compiler/testData/diagnostics/tests/LValueAssignment.jet index e9551afa2fd..7752029c1db 100644 --- a/compiler/testData/diagnostics/tests/LValueAssignment.jet +++ b/compiler/testData/diagnostics/tests/LValueAssignment.jet @@ -1,4 +1,4 @@ -namespace lvalue_assignment +package lvalue_assignment open class B() { var b: Int = 2 @@ -38,7 +38,7 @@ class D() { fun cannotBe(var <!UNUSED_PARAMETER!>i<!>: Int) { <!UNRESOLVED_REFERENCE!>z<!> = 30; - <!VARIABLE_EXPECTED!>()<!> = (); + <!VARIABLE_EXPECTED!>#()<!> = #(); (<!VARIABLE_EXPECTED!>i <!USELESS_CAST!>as<!> Int<!>) = 34 (<!VARIABLE_EXPECTED!>i is Int<!>) = false diff --git a/compiler/testData/diagnostics/tests/MergePackagesWithJava.jet b/compiler/testData/diagnostics/tests/MergePackagesWithJava.jet index 9da16a7c82d..727852d39df 100644 --- a/compiler/testData/diagnostics/tests/MergePackagesWithJava.jet +++ b/compiler/testData/diagnostics/tests/MergePackagesWithJava.jet @@ -2,7 +2,7 @@ // KT-689 Allow to put Java and Kotlin files in the same packages // This is a stub test. One should not extend Java packages that come from libraries. -namespace java +package java val c : lang.Class<*>? = null diff --git a/compiler/testData/diagnostics/tests/MultipleBounds.jet b/compiler/testData/diagnostics/tests/MultipleBounds.jet index 773ebaea33f..49c333a7b87 100644 --- a/compiler/testData/diagnostics/tests/MultipleBounds.jet +++ b/compiler/testData/diagnostics/tests/MultipleBounds.jet @@ -1,4 +1,4 @@ -namespace Jet87 +package Jet87 open class A() { fun foo() : Int = 1 diff --git a/compiler/testData/diagnostics/tests/NamespaceAsExpression.jet b/compiler/testData/diagnostics/tests/NamespaceAsExpression.jet index de5e97fe5b8..b4e08dfe704 100644 --- a/compiler/testData/diagnostics/tests/NamespaceAsExpression.jet +++ b/compiler/testData/diagnostics/tests/NamespaceAsExpression.jet @@ -1,8 +1,8 @@ -namespace root +package root -namespace a { +package a { } val x = <!EXPRESSION_EXPECTED_NAMESPACE_FOUND!>a<!> -val y2 = <!NAMESPACE_IS_NOT_AN_EXPRESSION!>namespace<!> +val y2 = <!NAMESPACE_IS_NOT_AN_EXPRESSION!>package<!> diff --git a/compiler/testData/diagnostics/tests/NamespaceInExpressionPosition.jet b/compiler/testData/diagnostics/tests/NamespaceInExpressionPosition.jet index f8520b087f1..9a6d9805a2a 100644 --- a/compiler/testData/diagnostics/tests/NamespaceInExpressionPosition.jet +++ b/compiler/testData/diagnostics/tests/NamespaceInExpressionPosition.jet @@ -1,6 +1,6 @@ // +JDK -namespace foo +package foo class X {} diff --git a/compiler/testData/diagnostics/tests/NamespaceQualified.jet b/compiler/testData/diagnostics/tests/NamespaceQualified.jet index 194c1047e24..f57a483de32 100644 --- a/compiler/testData/diagnostics/tests/NamespaceQualified.jet +++ b/compiler/testData/diagnostics/tests/NamespaceQualified.jet @@ -1,8 +1,8 @@ // +JDK -namespace foobar +package foobar -namespace a { +package a { import java.* val a : util.List<Int>? = null @@ -14,7 +14,7 @@ abstract class Foo<T>() { abstract val x : T<Int> } -namespace a { +package a { import java.util.* val b : List<Int>? = a diff --git a/compiler/testData/diagnostics/tests/Nullability.jet b/compiler/testData/diagnostics/tests/Nullability.jet index 95e8ebb3700..14ba1b28652 100644 --- a/compiler/testData/diagnostics/tests/Nullability.jet +++ b/compiler/testData/diagnostics/tests/Nullability.jet @@ -40,28 +40,28 @@ fun test() { out.println(); } - if (out == null || out.println(0) == ()) { + if (out == null || out.println(0) == #()) { out?.println(1) } else { out.println(2) } - if (out != null && out.println() == ()) { + if (out != null && out.println() == #()) { out.println(); } else { out?.println(); } - if (out == null || out != null && out.println() == ()) { + if (out == null || out != null && out.println() == #()) { out?.println(); } else { out.println(); } - if (1 == 2 || out != null && out.println(1) == ()) { + if (1 == 2 || out != null && out.println(1) == #()) { out?.println(2); } else { @@ -96,28 +96,28 @@ fun test() { out.println(); } - if (out == null || out.println(0) == ()) { + if (out == null || out.println(0) == #()) { out?.println(1) } else { out.println(2) } - if (out != null && out.println() == ()) { + if (out != null && out.println() == #()) { out.println(); } else { out?.println(); } - if (out == null || out != null && out.println() == ()) { + if (out == null || out != null && out.println() == #()) { out?.println(); } else { out.println(); } - if (1 == 2 || out != null && out.println(1) == ()) { + if (1 == 2 || out != null && out.println(1) == #()) { out?.println(2); } else { diff --git a/compiler/testData/diagnostics/tests/Objects.jet b/compiler/testData/diagnostics/tests/Objects.jet index 79ed4e42644..14ce45145bd 100644 --- a/compiler/testData/diagnostics/tests/Objects.jet +++ b/compiler/testData/diagnostics/tests/Objects.jet @@ -1,4 +1,4 @@ -namespace toplevelObjectDeclarations { +package toplevelObjectDeclarations { open class Foo(y : Int) { open fun foo() : Int = 1 } @@ -28,7 +28,7 @@ namespace toplevelObjectDeclarations { val z = y.foo() } -namespace nestedObejcts { +package nestedObejcts { object A { val b = B val d = A.B.A @@ -58,7 +58,7 @@ namespace nestedObejcts { val e = B.<!UNRESOLVED_REFERENCE!>A<!>.B } -namespace localObjects { +package localObjects { object A { val x : Int = 0 } diff --git a/compiler/testData/diagnostics/tests/Override.jet b/compiler/testData/diagnostics/tests/Override.jet index ce46dadac07..6884e82eb42 100644 --- a/compiler/testData/diagnostics/tests/Override.jet +++ b/compiler/testData/diagnostics/tests/Override.jet @@ -1,6 +1,6 @@ -namespace override +package override -namespace normal { +package normal { trait MyTrait { fun foo() val pr : Unit @@ -16,8 +16,8 @@ namespace normal { override fun foo() {} override fun bar() {} - override val pr : Unit = () - override val prr : Unit = () + override val pr : Unit = #() + override val prr : Unit = #() } class MyChildClass() : MyClass() {} @@ -26,14 +26,14 @@ namespace normal { class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass2<!>() : MyTrait, MyAbstractClass { override fun foo() {} - override val pr : Unit = () - override val prr : Unit = () + override val pr : Unit = #() + override val prr : Unit = #() } class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass3<!>() : MyTrait, MyAbstractClass { override fun bar() {} - override val pr : Unit = () - override val prr : Unit = () + override val pr : Unit = #() + override val prr : Unit = #() } class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass4<!>() : MyTrait, MyAbstractClass { @@ -45,13 +45,13 @@ namespace normal { class MyChildClass1() : MyClass() { fun <!VIRTUAL_MEMBER_HIDDEN!>foo<!>() {} - val <!VIRTUAL_MEMBER_HIDDEN!>pr<!> : Unit = () + val <!VIRTUAL_MEMBER_HIDDEN!>pr<!> : Unit = #() override fun bar() {} - override val prr : Unit = () + override val prr : Unit = #() } } -namespace generics { +package generics { trait MyTrait<T> { fun foo(t: T) : T } diff --git a/compiler/testData/diagnostics/tests/QualifiedExpressions.jet b/compiler/testData/diagnostics/tests/QualifiedExpressions.jet index 187c745ef63..135fbc2e89a 100644 --- a/compiler/testData/diagnostics/tests/QualifiedExpressions.jet +++ b/compiler/testData/diagnostics/tests/QualifiedExpressions.jet @@ -1,4 +1,4 @@ -namespace qualified_expressions +package qualified_expressions fun test(s: String?) { val <!UNUSED_VARIABLE!>a<!>: Int = <!TYPE_MISMATCH!>s?.length<!> diff --git a/compiler/testData/diagnostics/tests/QualifiedThis.jet b/compiler/testData/diagnostics/tests/QualifiedThis.jet index 7fab8479b4b..82d44c804ce 100644 --- a/compiler/testData/diagnostics/tests/QualifiedThis.jet +++ b/compiler/testData/diagnostics/tests/QualifiedThis.jet @@ -21,7 +21,7 @@ fun foo1() : Unit { this<!UNRESOLVED_REFERENCE!>@a<!> } -namespace closures { +package closures { class A(val a:Int) { class B() { @@ -31,10 +31,10 @@ namespace closures { val Int.xx = this : Int fun Char.xx() : Any { this : Char - val <!UNUSED_VARIABLE!>a<!> = {Double.() => this : Double + this@xx : Char} - val <!UNUSED_VARIABLE!>b<!> = @a{Double.() => this@a : Double + this@xx : Char} - val <!UNUSED_VARIABLE!>c<!> = @a{() => <!NO_THIS!>this@a<!> + this@xx : Char} - return (@a{Double.() => this@a : Double + this@xx : Char}) + val <!UNUSED_VARIABLE!>a<!> = {Double.() -> this : Double + this@xx : Char} + val <!UNUSED_VARIABLE!>b<!> = @a{Double.() -> this@a : Double + this@xx : Char} + val <!UNUSED_VARIABLE!>c<!> = @a{() -> <!NO_THIS!>this@a<!> + this@xx : Char} + return (@a{Double.() -> this@a : Double + this@xx : Char}) } } } diff --git a/compiler/testData/diagnostics/tests/RecursiveTypeInference.jet b/compiler/testData/diagnostics/tests/RecursiveTypeInference.jet index 46e2f2ae7c7..47e0d6aeb58 100644 --- a/compiler/testData/diagnostics/tests/RecursiveTypeInference.jet +++ b/compiler/testData/diagnostics/tests/RecursiveTypeInference.jet @@ -1,16 +1,16 @@ -namespace a { +package a { val foo = bar() fun bar() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>foo<!> } -namespace b { +package b { fun foo() = bar() fun bar() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>foo()<!> } -namespace c { +package c { fun bazz() = bar() fun foo() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bazz()<!> @@ -18,21 +18,21 @@ namespace c { fun bar() = foo() } -namespace ok { +package ok { - namespace a { + package a { val foo = bar() fun bar() : Int = foo } - namespace b { + package b { fun foo() : Int = bar() fun bar() = foo() } - namespace c { + package c { fun bazz() = bar() fun foo() : Int = bazz() diff --git a/compiler/testData/diagnostics/tests/Redeclarations.jet b/compiler/testData/diagnostics/tests/Redeclarations.jet index 3068a16b54d..18756b8ba9a 100644 --- a/compiler/testData/diagnostics/tests/Redeclarations.jet +++ b/compiler/testData/diagnostics/tests/Redeclarations.jet @@ -1,11 +1,11 @@ -namespace redeclarations { +package redeclarations { object <!REDECLARATION, REDECLARATION!>A<!> { val x : Int = 0 val A = 1 } - namespace <!REDECLARATION!>A<!> { + package <!REDECLARATION!>A<!> { class A {} } diff --git a/compiler/testData/diagnostics/tests/ResolveToJava.jet b/compiler/testData/diagnostics/tests/ResolveToJava.jet index 28d49d5ee3f..8275b2c842c 100644 --- a/compiler/testData/diagnostics/tests/ResolveToJava.jet +++ b/compiler/testData/diagnostics/tests/ResolveToJava.jet @@ -49,6 +49,6 @@ fun test(<!UNUSED_PARAMETER!>l<!> : java.util.List<Int>) { } -namespace xxx { +package xxx { import java.lang.Class; } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/Return.jet b/compiler/testData/diagnostics/tests/Return.jet index 2426ecb933c..146783a46fd 100644 --- a/compiler/testData/diagnostics/tests/Return.jet +++ b/compiler/testData/diagnostics/tests/Return.jet @@ -1,4 +1,4 @@ -namespace <!SYNTAX!>return<!> +package <!SYNTAX!>return<!> class A { fun outer() { diff --git a/compiler/testData/diagnostics/tests/ShiftFunctionTypes.jet b/compiler/testData/diagnostics/tests/ShiftFunctionTypes.jet new file mode 100644 index 00000000000..31e951a535b --- /dev/null +++ b/compiler/testData/diagnostics/tests/ShiftFunctionTypes.jet @@ -0,0 +1,51 @@ +class A { +} + +package n { + class B +} +abstract class XXX() { + abstract val a : Int + abstract val a1 : package.<!UNRESOLVED_REFERENCE!>Int<!> + abstract val a2 : n.B + abstract val a3 : (A) + abstract val a31 : (n.B) + abstract val a4 : A? + abstract val a5 : (A)? + abstract val a6 : (A?) + abstract val a7 : (A) -> n.B + abstract val a8 : (A, n.B) -> n.B + +//val a9 : (A, B) +//val a10 : (B)? -> B + + val a11 : ((Int) -> Int)? = null + val a12 : ((Int) -> (Int))? = null + abstract val a13 : Int.(Int) -> Int + abstract val a14 : n.B.(Int) -> Int + abstract val a15 : Int? .(Int) -> Int + abstract val a152 : (Int?).(Int) -> Int +// abstract val a151 : Int?.(Int) -> Int + abstract val a16 : (Int) -> (Int) -> Int + abstract val a17 : ((Int) -> Int).(Int) -> Int + abstract val a18 : (Int) -> ((Int) -> Int) + abstract val a19 : ((Int) -> Int) -> Int +} + +abstract class YYY() { + abstract val a7 : (a : A) -> n.B + abstract val a8 : (a : A, b : n.B) -> n.B +//val a9 : (A, B) +//val a10 : (B)? -> B + val a11 : ((a : Int) -> Int)? = null + val a12 : ((a : Int) -> (Int))? = null + abstract val a13 : Int.(a : Int) -> Int + abstract val a14 : n.B.(a : Int) -> Int + abstract val a15 : Int? .(a : Int) -> Int + abstract val a152 : (Int?).(a : Int) -> Int +//abstract val a151 : Int?.(a : Int) -> Int + abstract val a16 : (a : Int) -> (a : Int) -> Int + abstract val a17 : ((a : Int) -> Int).(a : Int) -> Int + abstract val a18 : (a : Int) -> ((a : Int) -> Int) + abstract val a19 : (b : (a : Int) -> Int) -> Int +} diff --git a/compiler/testData/diagnostics/tests/StringTemplates.jet b/compiler/testData/diagnostics/tests/StringTemplates.jet index 79b4e562f17..976a06e3a02 100644 --- a/compiler/testData/diagnostics/tests/StringTemplates.jet +++ b/compiler/testData/diagnostics/tests/StringTemplates.jet @@ -3,8 +3,8 @@ fun demo() { val a = "" val asd = 1 val bar = 5 - fun map(f : fun () : Any?) : Int = 1 - fun buzz(f : fun () : Any?) : Int = 1 + fun map(f : () -> Any?) : Int = 1 + fun buzz(f : () -> Any?) : Int = 1 val sdf = 1 val foo = 3; "$abc" diff --git a/compiler/testData/diagnostics/tests/Super.jet b/compiler/testData/diagnostics/tests/Super.jet index 749b17c322f..1f41daa88ce 100644 --- a/compiler/testData/diagnostics/tests/Super.jet +++ b/compiler/testData/diagnostics/tests/Super.jet @@ -1,4 +1,4 @@ -namespace example; +package example; fun any(<!UNUSED_PARAMETER!>a<!> : Any) {} @@ -7,7 +7,7 @@ fun notAnExpression() { if (<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) {} else {} // not an expression val <!UNUSED_VARIABLE!>x<!> = <!SUPER_IS_NOT_AN_EXPRESSION!>super<!> // not an expression when (1) { - <!SUPER_IS_NOT_AN_EXPRESSION!>super<!> => 1 // not an expression + <!SUPER_IS_NOT_AN_EXPRESSION!>super<!> -> 1 // not an expression } } @@ -33,8 +33,8 @@ class A<E>() : C(), T { super<<!NOT_A_SUPERTYPE!>E<!>>@A.bar() super<<!NOT_A_SUPERTYPE!>Int<!>>.foo() super<<!SYNTAX!><!>>.foo() - super<<!NOT_A_SUPERTYPE!>fun() : Unit<!>>.foo() - super<<!NOT_A_SUPERTYPE!>()<!>>.foo() + super<<!NOT_A_SUPERTYPE!>() -> Unit<!>>.foo() + super<<!NOT_A_SUPERTYPE!>#()<!>>.foo() super<T><!UNRESOLVED_REFERENCE!>@B<!>.foo() super<C><!UNRESOLVED_REFERENCE!>@B<!>.bar() } diff --git a/compiler/testData/diagnostics/tests/UninitializedOrReassignedVariables.jet b/compiler/testData/diagnostics/tests/UninitializedOrReassignedVariables.jet index 22cfde8fdaa..964b8dfbb54 100644 --- a/compiler/testData/diagnostics/tests/UninitializedOrReassignedVariables.jet +++ b/compiler/testData/diagnostics/tests/UninitializedOrReassignedVariables.jet @@ -1,4 +1,4 @@ -namespace uninitialized_reassigned_variables +package uninitialized_reassigned_variables fun doSmth(<!UNUSED_PARAMETER!>s<!>: String) {} fun doSmth(<!UNUSED_PARAMETER!>i<!>: Int) {} diff --git a/compiler/testData/diagnostics/tests/UnitByDefaultForFunctionTypes.jet b/compiler/testData/diagnostics/tests/UnitByDefaultForFunctionTypes.jet index 9a14ad7a471..9848e76942e 100644 --- a/compiler/testData/diagnostics/tests/UnitByDefaultForFunctionTypes.jet +++ b/compiler/testData/diagnostics/tests/UnitByDefaultForFunctionTypes.jet @@ -1,3 +1,3 @@ -fun foo(f : fun()) { +fun foo(f : () -> Unit) { val <!UNUSED_VARIABLE!>x<!> : Unit = f() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/Unresolved.jet b/compiler/testData/diagnostics/tests/Unresolved.jet index b5b6018377d..0ec39c5fcbe 100644 --- a/compiler/testData/diagnostics/tests/Unresolved.jet +++ b/compiler/testData/diagnostics/tests/Unresolved.jet @@ -1,8 +1,8 @@ -namespace unresolved +package unresolved fun testGenericArgumentsCount() { - val <!UNUSED_VARIABLE!>p1<!>: Tuple2<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!> = (2, 2) - val <!UNUSED_VARIABLE!>p2<!>: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Tuple2<!> = (2, 2) + val <!UNUSED_VARIABLE!>p1<!>: Tuple2<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!> = #(2, 2) + val <!UNUSED_VARIABLE!>p2<!>: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Tuple2<!> = #(2, 2) } fun testUnresolved() { @@ -16,8 +16,8 @@ fun testUnresolved() { s.<!UNRESOLVED_REFERENCE!>foo<!>() when(<!UNRESOLVED_REFERENCE!>a<!>) { - is Int => <!UNRESOLVED_REFERENCE!>a<!> - is String => <!UNRESOLVED_REFERENCE!>a<!> + is Int -> <!UNRESOLVED_REFERENCE!>a<!> + is String -> <!UNRESOLVED_REFERENCE!>a<!> } //TODO diff --git a/compiler/testData/diagnostics/tests/UnusedVariables.jet b/compiler/testData/diagnostics/tests/UnusedVariables.jet index b41e4ab4002..a623c336836 100644 --- a/compiler/testData/diagnostics/tests/UnusedVariables.jet +++ b/compiler/testData/diagnostics/tests/UnusedVariables.jet @@ -1,4 +1,4 @@ -namespace unused_variables +package unused_variables fun testSimpleCases() { var i = <!VARIABLE_WITH_REDUNDANT_INITIALIZER!>2<!> @@ -103,11 +103,11 @@ fun testInnerFunctions() { fun testFunctionLiterals() { var x = 1 - var <!UNUSED_VARIABLE!>fl<!> = { (): Int => + var <!UNUSED_VARIABLE!>fl<!> = { (): Int -> x } var y = 2 - var <!UNUSED_VARIABLE!>fl1<!> = { (): Unit => + var <!UNUSED_VARIABLE!>fl1<!> = { (): Unit -> doSmth(y) } } diff --git a/compiler/testData/diagnostics/tests/Varargs.jet b/compiler/testData/diagnostics/tests/Varargs.jet index 5986ce0982d..e9a33960df3 100644 --- a/compiler/testData/diagnostics/tests/Varargs.jet +++ b/compiler/testData/diagnostics/tests/Varargs.jet @@ -1,5 +1,5 @@ fun v(<!UNUSED_PARAMETER!>x<!> : Int, <!UNUSED_PARAMETER!>y<!> : String, vararg <!UNUSED_PARAMETER!>f<!> : Long) {} -fun v1(vararg <!UNUSED_PARAMETER!>f<!> : fun (Int) : Unit) {} +fun v1(vararg <!UNUSED_PARAMETER!>f<!> : (Int) -> Unit) {} fun test() { v(1, "") diff --git a/compiler/testData/diagnostics/tests/Variance.jet b/compiler/testData/diagnostics/tests/Variance.jet index 8785dfd87cb..da27ecfa5ba 100644 --- a/compiler/testData/diagnostics/tests/Variance.jet +++ b/compiler/testData/diagnostics/tests/Variance.jet @@ -1,4 +1,4 @@ -namespace variance +package variance abstract class Consumer<in T> {} diff --git a/compiler/testData/diagnostics/tests/When.jet b/compiler/testData/diagnostics/tests/When.jet index bff65aac380..0943aa7cdb6 100644 --- a/compiler/testData/diagnostics/tests/When.jet +++ b/compiler/testData/diagnostics/tests/When.jet @@ -4,19 +4,19 @@ fun foo() : Int { val s = "" val x = 1 when (x) { - is * => 1 - is <!INCOMPATIBLE_TYPES!>String<!> => 1 - !is Int => 1 - is Any? => 1 - <!INCOMPATIBLE_TYPES!>s<!> => 1 - 1 => 1 - 1 + <!UNRESOLVED_REFERENCE!>a<!> => 1 - in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1 - !in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1 + is * -> 1 + is <!INCOMPATIBLE_TYPES!>String<!> -> 1 + !is Int -> 1 + is Any? -> 1 + <!INCOMPATIBLE_TYPES!>s<!> -> 1 + 1 -> 1 + 1 + <!UNRESOLVED_REFERENCE!>a<!> -> 1 + in 1..<!UNRESOLVED_REFERENCE!>a<!> -> 1 + !in 1..<!UNRESOLVED_REFERENCE!>a<!> -> 1 // Commented for KT-621 .<!!UNRESOLVED_REFERENCE!>a<!!> => 1 // Commented for KT-621 .equals(1).<!!UNRESOLVED_REFERENCE!>a<!!> => 1 // Commented for KT-621 <!UNNECESSARY_SAFE_CALL!!>?.<!!>equals(1) => 1 - else => 1 + else -> 1 } // Commented for KT-621 @@ -35,33 +35,33 @@ fun test() { val s = ""; when (x) { - <!INCOMPATIBLE_TYPES!>s<!> => 1 - is <!INCOMPATIBLE_TYPES!>""<!> => 1 - x => 1 - is 1 => 1 - is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, 1)<!> => 1 + <!INCOMPATIBLE_TYPES!>s<!> -> 1 + is <!INCOMPATIBLE_TYPES!>""<!> -> 1 + x -> 1 + is 1 -> 1 + is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, 1)<!> -> 1 } - val z = (1, 1) + val z = #(1, 1) when (z) { - is (*, *) => 1 - is (*, 1) => 1 - is (1, 1) => 1 - is (1, <!INCOMPATIBLE_TYPES!>"1"<!>) => 1 - is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, "1", *)<!> => 1 - is boo @ (1, <!INCOMPATIBLE_TYPES!>"a"<!>, *) => 1 - is boo @ <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, *)<!> => 1 + is #(*, *) -> 1 + is #(*, 1) -> 1 + is #(1, 1) -> 1 + is #(1, <!INCOMPATIBLE_TYPES!>"1"<!>) -> 1 + is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, "1", *)<!> -> 1 + is boo #(1, <!INCOMPATIBLE_TYPES!>"a"<!>, *) -> 1 + is boo <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>#(1, *)<!> -> 1 } when (z) { - <!ELSE_MISPLACED_IN_WHEN!>else => 1<!> - (1, 1) => 2 + <!ELSE_MISPLACED_IN_WHEN!>else -> 1<!> + #(1, 1) -> 2 } when (z) { - else => 1 + else -> 1 } } -val (Int, Int).boo : (Int, Int, Int) = (1, 1, 1) +val #(Int, Int).boo : #(Int, Int, Int) = #(1, 1, 1) diff --git a/compiler/testData/diagnostics/tests/backingField/CustomGetValGlobal.jet b/compiler/testData/diagnostics/tests/backingField/CustomGetValGlobal.jet index 6962636adec..0a26ab8d578 100644 --- a/compiler/testData/diagnostics/tests/backingField/CustomGetValGlobal.jet +++ b/compiler/testData/diagnostics/tests/backingField/CustomGetValGlobal.jet @@ -1,4 +1,4 @@ -namespace customGetValGlobal { +package customGetValGlobal { val zz = 1 get() = $zz * 2 diff --git a/compiler/testData/diagnostics/tests/backingField/kt462BackingFieldsResolve.jet b/compiler/testData/diagnostics/tests/backingField/kt462BackingFieldsResolve.jet index af0ec07ea8d..3520c94aa5e 100644 --- a/compiler/testData/diagnostics/tests/backingField/kt462BackingFieldsResolve.jet +++ b/compiler/testData/diagnostics/tests/backingField/kt462BackingFieldsResolve.jet @@ -1,7 +1,7 @@ //KT-462 Consider allowing initializing properties via property names when it is safe //KT-598 Allow to use backing fields after this expression -namespace kt462 +package kt462 abstract class TestInitializationWithoutBackingField() { val valWithBackingField : Int diff --git a/compiler/testData/diagnostics/tests/backingField/kt782namespaceLevel.jet b/compiler/testData/diagnostics/tests/backingField/kt782namespaceLevel.jet index 70e44773cdf..0d12bc57aa8 100644 --- a/compiler/testData/diagnostics/tests/backingField/kt782namespaceLevel.jet +++ b/compiler/testData/diagnostics/tests/backingField/kt782namespaceLevel.jet @@ -1,6 +1,6 @@ // KT-782 Allow backing field usage for accessors of variables on namespace level -namespace kt782 +package kt782 val z : Int = 34 diff --git a/compiler/testData/diagnostics/tests/cast/WhenErasedDisallowFromAny.jet b/compiler/testData/diagnostics/tests/cast/WhenErasedDisallowFromAny.jet index 2f424e3b9ad..d4ad8b264b0 100644 --- a/compiler/testData/diagnostics/tests/cast/WhenErasedDisallowFromAny.jet +++ b/compiler/testData/diagnostics/tests/cast/WhenErasedDisallowFromAny.jet @@ -3,6 +3,6 @@ import java.util.List; fun ff(l: Any) = when(l) { - is <!CANNOT_CHECK_FOR_ERASED!>List<String><!> => 1 + is <!CANNOT_CHECK_FOR_ERASED!>List<String><!> -> 1 else <!SYNTAX!>2<!> } diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt510.jet b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt510.jet index 41feb040f2a..15407891604 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt510.jet +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt510.jet @@ -1,6 +1,6 @@ //KT-510 `this.` allows initialization without backing field -namespace kt510 +package kt510 public open class Identifier1() { var field : Boolean diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt607.jet b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt607.jet index 238661318d1..06ff50dd689 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt607.jet +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt607.jet @@ -1,6 +1,6 @@ //KT-607 Val reassignment is not marked as an error -namespace kt607 +package kt607 fun foo(a: A) { val o = object { diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt609.jet b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt609.jet index 56f75e247e2..8ea0f2ef92b 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt609.jet +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt609.jet @@ -1,6 +1,6 @@ //KT-609 Analyze not only local variables, but function parameters as well in 'unused values' analysis -namespace kt609 +package kt609 fun test(var a: Int) { a = <!UNUSED_VALUE!>324<!> //should be an 'unused value' warning here diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt610.jet b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt610.jet index 916704e6c03..93838a62884 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt610.jet +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt610.jet @@ -1,6 +1,6 @@ //KT-610 Distinguish errors 'unused variable' and 'variable is assigned but never accessed' -namespace kt610 +package kt610 fun foo() { var <!UNUSED_VARIABLE!>j<!> = 9 //'unused variable' error diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt843.jet b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt843.jet index 3e276fe45d3..eeefb8d96f2 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt843.jet +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/kt843.jet @@ -1,6 +1,6 @@ //KT-843 Don't highlight incomplete variables as unused -namespace kt843 +package kt843 fun main(args : Array<String>) { // Integer type diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.jet b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.jet index f9d9a50e4f4..878cce20769 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.jet +++ b/compiler/testData/diagnostics/tests/controlStructures/kt770.kt351.kt735_StatementType.jet @@ -1,4 +1,4 @@ -namespace kt770_351_735 +package kt770_351_735 //+JDK @@ -6,9 +6,9 @@ namespace kt770_351_735 fun main(args : Array<String>) { var i = 0 when (i) { - 1 => i-- - 2 => i = 2 // i is surrounded by a black border - else => <!UNRESOLVED_REFERENCE!>j<!> = 2 + 1 -> i-- + 2 -> i = 2 // i is surrounded by a black border + else -> <!UNRESOLVED_REFERENCE!>j<!> = 2 } System.out?.println(i) } @@ -26,8 +26,8 @@ fun foo() { z = <!UNUSED_VALUE!>34<!> } } - val <!UNUSED_VARIABLE!>f<!>: fun(): Int = <!TYPE_MISMATCH!>r<!> - val <!UNUSED_VARIABLE!>g<!>: fun(): Any = r + val <!UNUSED_VARIABLE!>f<!>: ()-> Int = <!TYPE_MISMATCH!>r<!> + val <!UNUSED_VARIABLE!>g<!>: ()-> Any = r } //KT-735 Statements without braces are prohibited on the right side of when entries. @@ -35,8 +35,8 @@ fun box() : Int { val d = 2 var z = 0 when(d) { - is 5, is 3 => z++ - else => z = -1000 + is 5, is 3 -> z++ + else -> z = -1000 } return z } @@ -47,10 +47,10 @@ fun test1() = while(true) {} fun test2(): Unit = while(true) {} fun testCoercionToUnit() { - val <!UNUSED_VARIABLE!>simple<!>: fun(): Unit = { + val <!UNUSED_VARIABLE!>simple<!>: ()-> Unit = { 41 } - val <!UNUSED_VARIABLE!>withIf<!>: fun(): Unit = { + val <!UNUSED_VARIABLE!>withIf<!>: ()-> Unit = { if (true) { 3 } else { @@ -58,16 +58,16 @@ fun testCoercionToUnit() { } } val i = 34 - val <!UNUSED_VARIABLE!>withWhen<!> : fun() : Unit = { + val <!UNUSED_VARIABLE!>withWhen<!> : () -> Unit = { when(i) { - is 1 => { + is 1 -> { val d = 34 "1" doSmth(d) } - is 2 => '4' - else => true + is 2 -> '4' + else -> true } } @@ -79,7 +79,7 @@ fun testCoercionToUnit() { 45 } } - val <!UNUSED_VARIABLE!>f<!> : fun() : String = <!TYPE_MISMATCH!>checkType<!> + val <!UNUSED_VARIABLE!>f<!> : () -> String = <!TYPE_MISMATCH!>checkType<!> } fun doSmth(<!UNUSED_PARAMETER!>i<!>: Int) {} @@ -88,16 +88,16 @@ fun testImplicitCoercion() { val d = 21 var z = 0 var <!UNUSED_VARIABLE!>i<!> = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>when(d) { - is 3 => null - is 4 => { val <!NAME_SHADOWING, UNUSED_VARIABLE!>z<!> = 23 } - else => z = 20 + is 3 -> null + is 4 -> { val <!NAME_SHADOWING, UNUSED_VARIABLE!>z<!> = 23 } + else -> z = 20 }<!> var <!UNUSED_VARIABLE!>u<!> = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>when(d) { - is 3 => { + is 3 -> { z = <!UNUSED_VALUE!>34<!> } - else => <!UNUSED_CHANGED_VALUE!>z--<!> + else -> <!UNUSED_CHANGED_VALUE!>z--<!> }<!> var <!UNUSED_VARIABLE!>iff<!> = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>if (true) { diff --git a/compiler/testData/diagnostics/tests/controlStructures/kt786.jet b/compiler/testData/diagnostics/tests/controlStructures/kt786.jet index 665af148d31..e82c47aa5fc 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/kt786.jet +++ b/compiler/testData/diagnostics/tests/controlStructures/kt786.jet @@ -1,13 +1,13 @@ -namespace kt786 +package kt786 //KT-786 Exception on incomplete code with 'when' fun foo() : Int { val d = 2 var z = 0 when(d) { - is 5, is 3 => <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY, UNUSED_CHANGED_VALUE!>z++<!> - <!ELSE_MISPLACED_IN_WHEN!>else => { <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>z = <!UNUSED_VALUE!>-1000<!><!> }<!> - return z => <!UNREACHABLE_CODE!>34<!> + is 5, is 3 -> <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY, UNUSED_CHANGED_VALUE!>z++<!> + <!ELSE_MISPLACED_IN_WHEN!>else -> { <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>z = <!UNUSED_VALUE!>-1000<!><!> }<!> + return z -> <!UNREACHABLE_CODE!>34<!> } } @@ -15,10 +15,10 @@ fun foo() : Int { fun fff(): Int { var d = 3 when(d) { - is 4 => 21 - return 2 => <!UNREACHABLE_CODE!>return 47<!> - <!UNREACHABLE_CODE!>bar()<!> => <!UNREACHABLE_CODE!>45<!> - <!UNREACHABLE_CODE!>444<!> => <!UNREACHABLE_CODE!>true<!> + is 4 -> 21 + return 2 -> <!UNREACHABLE_CODE!>return 47<!> + <!UNREACHABLE_CODE!>bar()<!> -> <!UNREACHABLE_CODE!>45<!> + <!UNREACHABLE_CODE!>444<!> -> <!UNREACHABLE_CODE!>true<!> } return 34 } diff --git a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.jet b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.jet index e7e3c1cebf4..0e963b6a6d6 100644 --- a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.jet +++ b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.jet @@ -1,7 +1,7 @@ // +JDK fun Int?.optint() : Unit {} -val Int?.optval : Unit = () +val Int?.optval : Unit = #() fun <T, E> T.foo(<!UNUSED_PARAMETER!>x<!> : E, y : A) : T { y.plus(1) @@ -39,7 +39,7 @@ val <T> T.<!MUST_BE_INITIALIZED!>foo<!> : T fun Int.foo() = this -namespace null_safety { +package null_safety { fun parse(<!UNUSED_PARAMETER!>cmd<!>: String): Command? { return null } class Command() { diff --git a/compiler/testData/diagnostics/tests/infos/Autocasts.jet b/compiler/testData/diagnostics/tests/infos/Autocasts.jet index 38a9005de0b..a869d644ed6 100644 --- a/compiler/testData/diagnostics/tests/infos/Autocasts.jet +++ b/compiler/testData/diagnostics/tests/infos/Autocasts.jet @@ -20,7 +20,7 @@ fun f9(init : A?) { a?.<!UNRESOLVED_REFERENCE!>bar<!>() a?.foo() } - if (!(a is B) || a.bar() == ()) { + if (!(a is B) || a.bar() == #()) { a?.<!UNRESOLVED_REFERENCE!>bar<!>() } if (!(a is B)) { @@ -54,24 +54,24 @@ fun f101(a : A?) { fun f11(a : A?) { when (a) { - is B => a.bar() - is A => a.foo() - is Any => a.foo() - is Any? => a.<!UNRESOLVED_REFERENCE!>bar<!>() - else => a?.foo() + is B -> a.bar() + is A -> a.foo() + is Any -> a.foo() + is Any? -> a.<!UNRESOLVED_REFERENCE!>bar<!>() + else -> a?.foo() } } fun f12(a : A?) { when (a) { - is B => a.bar() - is A => a.foo() - is Any => a.foo(); - is Any? => a.<!UNRESOLVED_REFERENCE!>bar<!>() - is val c : <!TYPE_MISMATCH_IN_BINDING_PATTERN!>B<!> => c.foo() - is val c is C => c.bar() - is val c is C => a.bar() - else => a?.foo() + is B -> a.bar() + is A -> a.foo() + is Any -> a.foo(); + is Any? -> a.<!UNRESOLVED_REFERENCE!>bar<!>() + is val c : <!TYPE_MISMATCH_IN_BINDING_PATTERN!>B<!> -> c.foo() + is val c is C -> c.bar() + is val c is C -> a.bar() + else -> a?.foo() } if (a is val b) { @@ -106,7 +106,7 @@ fun f13(a : A?) { } a?.foo() - if (a is val c is B && a.foo() == () && c.bar() == ()) { + if (a is val c is B && a.foo() == #() && c.bar() == #()) { c.foo() c.bar() } @@ -154,18 +154,18 @@ fun getStringLength(obj : Any) : Char? { fun toInt(i: Int?): Int = if (i != null) i else 0 fun illegalWhenBody(a: Any): Int = when(a) { - is Int => a - is String => <!TYPE_MISMATCH!>a<!> + is Int -> a + is String -> <!TYPE_MISMATCH!>a<!> } fun illegalWhenBlock(a: Any): Int { when(a) { - is Int => return a - is String => return <!TYPE_MISMATCH!>a<!> + is Int -> return a + is String -> return <!TYPE_MISMATCH!>a<!> } } fun declarations(a: Any?) { if (a is String) { - val <!UNUSED_VARIABLE!>p4<!>: (Int, String) = (2, a) + val <!UNUSED_VARIABLE!>p4<!>: #(Int, String) = #(2, a) } if (a is String?) { if (a != null) { @@ -186,21 +186,21 @@ fun vars(a: Any?) { } fun tuples(a: Any?) { if (a != null) { - val <!UNUSED_VARIABLE!>s<!>: (Any, String) = (a, <!TYPE_MISMATCH!>a<!>) + val <!UNUSED_VARIABLE!>s<!>: #(Any, String) = #(a, <!TYPE_MISMATCH!>a<!>) } if (a is String) { - val <!UNUSED_VARIABLE!>s<!>: (Any, String) = (a, a) + val <!UNUSED_VARIABLE!>s<!>: #(Any, String) = #(a, a) } - fun illegalTupleReturnType(): (Any, String) = (<!TYPE_MISMATCH!>a<!>, <!TYPE_MISMATCH!>a<!>) + fun illegalTupleReturnType(): #(Any, String) = #(<!TYPE_MISMATCH!>a<!>, <!TYPE_MISMATCH!>a<!>) if (a is String) { - fun legalTupleReturnType(): (Any, String) = (a, a) + fun legalTupleReturnType(): #(Any, String) = #(a, a) } val <!UNUSED_VARIABLE!>illegalFunctionLiteral<!>: Function0<Int> = <!TYPE_MISMATCH!>{ <!TYPE_MISMATCH!>a<!> }<!> - val <!UNUSED_VARIABLE!>illegalReturnValueInFunctionLiteral<!>: Function0<Int> = { (): Int => <!TYPE_MISMATCH!>a<!> } + val <!UNUSED_VARIABLE!>illegalReturnValueInFunctionLiteral<!>: Function0<Int> = { (): Int -> <!TYPE_MISMATCH!>a<!> } if (a is Int) { val <!UNUSED_VARIABLE!>legalFunctionLiteral<!>: Function0<Int> = { a } - val <!UNUSED_VARIABLE!>alsoLegalFunctionLiteral<!>: Function0<Int> = { (): Int => a } + val <!UNUSED_VARIABLE!>alsoLegalFunctionLiteral<!>: Function0<Int> = { (): Int -> a } } } fun returnFunctionLiteralBlock(a: Any?): Function0<Int> { @@ -208,12 +208,12 @@ fun returnFunctionLiteralBlock(a: Any?): Function0<Int> { else return { 1 } } fun returnFunctionLiteral(a: Any?): Function0<Int> = - if (a is Int) { (): Int => a } - else { () => 1 } + if (a is Int) { (): Int -> a } + else { () -> 1 } -fun illegalTupleReturnType(a: Any): (Any, String) = (a, <!TYPE_MISMATCH!>a<!>) +fun illegalTupleReturnType(a: Any): #(Any, String) = #(a, <!TYPE_MISMATCH!>a<!>) -fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => a; else => "something" } +fun declarationInsidePattern(x: #(Any, Any)): String = when(x) { is #(val a is String, *) -> a; else -> "something" } fun mergeAutocasts(a: Any?) { if (a is String || a is Int) { @@ -224,7 +224,7 @@ fun mergeAutocasts(a: Any?) { a.<!UNRESOLVED_REFERENCE!>compareTo<!>("") } when (a) { - is String, is Any => a.<!UNRESOLVED_REFERENCE!>compareTo<!>("") + is String, is Any -> a.<!UNRESOLVED_REFERENCE!>compareTo<!>("") } if (a is String && a is Any) { val <!UNUSED_VARIABLE!>i<!>: Int = a.compareTo("") diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.jet b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.jet index 3fdb3fc0a75..3e19f906169 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.jet +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.jet @@ -1,4 +1,4 @@ -namespace kt244 +package kt244 //+JDK diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.jet b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.jet index 5fd5f72bfb1..a934b77d046 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.jet +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.jet @@ -1,7 +1,7 @@ // KT-362 Don't allow autocasts on vals that are not internal -namespace example; +package example; -namespace test { +package test { public class Public() { public val public : Int? = 1; protected val protected : Int? = 1; diff --git a/compiler/testData/diagnostics/tests/regressions/AmbiguityOnLazyTypeComputation.jet b/compiler/testData/diagnostics/tests/regressions/AmbiguityOnLazyTypeComputation.jet index cdced141c6a..0f387418f9d 100644 --- a/compiler/testData/diagnostics/tests/regressions/AmbiguityOnLazyTypeComputation.jet +++ b/compiler/testData/diagnostics/tests/regressions/AmbiguityOnLazyTypeComputation.jet @@ -1,7 +1,7 @@ // One of the two passes is making a scope and turning vals into functions // See KT-76 -namespace x +package x val b : Foo = Foo() val a1 = b.compareTo(2) diff --git a/compiler/testData/diagnostics/tests/regressions/CoercionToUnit.jet b/compiler/testData/diagnostics/tests/regressions/CoercionToUnit.jet index 765036145b7..3fbbafe7fa4 100644 --- a/compiler/testData/diagnostics/tests/regressions/CoercionToUnit.jet +++ b/compiler/testData/diagnostics/tests/regressions/CoercionToUnit.jet @@ -2,7 +2,7 @@ fun foo(<!UNUSED_PARAMETER!>u<!> : Unit) : Int = 1 fun test() : Int { foo(<!TYPE_MISMATCH!>1<!>) - val <!UNUSED_VARIABLE!>a<!> : fun() : Unit = { + val <!UNUSED_VARIABLE!>a<!> : () -> Unit = { foo(<!TYPE_MISMATCH!>1<!>) } return 1 diff --git a/compiler/testData/diagnostics/tests/regressions/Jet121.jet b/compiler/testData/diagnostics/tests/regressions/Jet121.jet index fc29dfe5293..4dda2b95c51 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet121.jet +++ b/compiler/testData/diagnostics/tests/regressions/Jet121.jet @@ -1,6 +1,6 @@ -namespace jet121 { +package jet121 { fun box() : String { - val answer = apply("OK") { String.() : Int => + val answer = apply("OK") { String.() : Int -> get(0) length } @@ -8,7 +8,7 @@ namespace jet121 { return if (answer == 2) "OK" else "FAIL" } - fun apply(arg:String, f : fun String.() : Int) : Int { + fun apply(arg:String, f : String.() -> Int) : Int { return arg.f() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/Jet124.jet b/compiler/testData/diagnostics/tests/regressions/Jet124.jet index 317b1438f41..5e8088b3e08 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet124.jet +++ b/compiler/testData/diagnostics/tests/regressions/Jet124.jet @@ -1,8 +1,8 @@ -fun foo1() : fun (Int) : Int = { (x: Int) => x } +fun foo1() : (Int) -> Int = { (x: Int) -> x } fun foo() { - val h : fun (Int) : Int = foo1(); + val h : (Int) -> Int = foo1(); h(1) - val m : fun (Int) : Int = {(a : Int) => 1}//foo1() + val m : (Int) -> Int = {(a : Int) -> 1}//foo1() m(1) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/Jet169.jet b/compiler/testData/diagnostics/tests/regressions/Jet169.jet index c0196a2543d..8c28c04b4c3 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet169.jet +++ b/compiler/testData/diagnostics/tests/regressions/Jet169.jet @@ -1,8 +1,8 @@ fun set(<!UNUSED_PARAMETER!>key<!> : String, <!UNUSED_PARAMETER!>value<!> : String) { val a : String? = "" when (a) { - "" => a<!UNSAFE_CALL!>.<!>get(0) - is String, is Any => a.compareTo("") - else => a.toString() + "" -> a<!UNSAFE_CALL!>.<!>get(0) + is String, is Any -> a.compareTo("") + else -> a.toString() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/UnavaliableQualifiedThis.jet b/compiler/testData/diagnostics/tests/regressions/UnavaliableQualifiedThis.jet index 301ded436a1..06f60005347 100644 --- a/compiler/testData/diagnostics/tests/regressions/UnavaliableQualifiedThis.jet +++ b/compiler/testData/diagnostics/tests/regressions/UnavaliableQualifiedThis.jet @@ -2,7 +2,7 @@ trait Iterator<out T> { fun next() : T val hasNext : Boolean - fun <R> map(transform: fun(element: T) : R) : Iterator<R> = + fun <R> map(transform: (element: T) -> R) : Iterator<R> = object : Iterator<R> { override fun next() : R = transform(<!NO_THIS!>this@map<!>.next()) diff --git a/compiler/testData/diagnostics/tests/regressions/kt128.jet b/compiler/testData/diagnostics/tests/regressions/kt128.jet index ca9b223cd02..f136de1a55a 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt128.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt128.jet @@ -1,6 +1,6 @@ // KT-128 Support passing only the last closure if all the other parameters have default values -fun div(<!UNUSED_PARAMETER!>c<!> : String = "", <!UNUSED_PARAMETER!>f<!> : fun()) {} +fun div(<!UNUSED_PARAMETER!>c<!> : String = "", <!UNUSED_PARAMETER!>f<!> : () -> Unit) {} fun f() { div { // Nothing passed, but could have been... // ... diff --git a/compiler/testData/diagnostics/tests/regressions/kt235.jet b/compiler/testData/diagnostics/tests/regressions/kt235.jet index 0f0c33183a5..0fd87b03479 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt235.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt235.jet @@ -1,36 +1,36 @@ //KT-235 Illegal assignment return type // +JDK -namespace kt235 +package kt235 fun main(args: Array<String>) { val array = MyArray() - val <!UNUSED_VARIABLE!>f<!> = { (): String => + val <!UNUSED_VARIABLE!>f<!> = { (): String -> <!EXPECTED_TYPE_MISMATCH!>array[2] = 23<!> //error: Type mismatch: inferred type is Int (!!!) but String was expected } - val <!UNUSED_VARIABLE!>g<!> = {(): String => + val <!UNUSED_VARIABLE!>g<!> = {(): String -> var x = 1 <!EXPECTED_TYPE_MISMATCH!>x += 2<!> //no error, but it should be here } - val <!UNUSED_VARIABLE!>h<!> = {(): String => + val <!UNUSED_VARIABLE!>h<!> = {(): String -> var x = 1 <!EXPECTED_TYPE_MISMATCH!>x = 2<!> //the same } val array1 = MyArray1() - val <!UNUSED_VARIABLE!>i<!> = { (): String => + val <!UNUSED_VARIABLE!>i<!> = { (): String -> <!EXPECTED_TYPE_MISMATCH!>array1[2] = 23<!> } - val <!UNUSED_VARIABLE!>fi<!> = { (): Int => + val <!UNUSED_VARIABLE!>fi<!> = { (): Int -> <!ASSIGNMENT_TYPE_MISMATCH!>array[2] = 23<!> } - val <!UNUSED_VARIABLE!>gi<!> = {(): Int => + val <!UNUSED_VARIABLE!>gi<!> = {(): Int -> var x = 1 <!ASSIGNMENT_TYPE_MISMATCH!>x += 21<!> } var m: MyNumber = MyNumber() - val <!UNUSED_VARIABLE!>a<!> = { (): MyNumber => + val <!UNUSED_VARIABLE!>a<!> = { (): MyNumber -> <!UNUSED_CHANGED_VALUE!>m++<!> } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt26-1.jet b/compiler/testData/diagnostics/tests/regressions/kt26-1.jet index ff27f3515f3..d749ca77a99 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt26-1.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt26-1.jet @@ -1,7 +1,7 @@ // KT-26 Import namespaces defined in this file -namespace foo { +package foo { import bar.* // Must not be an error } -namespace bar {} \ No newline at end of file +package bar {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt26.jet b/compiler/testData/diagnostics/tests/regressions/kt26.jet index f79b7a901f8..816545f24b4 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt26.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt26.jet @@ -2,7 +2,7 @@ import html.* // Must not be an error -namespace html { +package html { abstract class Factory<T> { fun create() : T? = null diff --git a/compiler/testData/diagnostics/tests/regressions/kt302.jet b/compiler/testData/diagnostics/tests/regressions/kt302.jet index df3d68e0d55..25fe84153e2 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt302.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt302.jet @@ -1,6 +1,6 @@ // KT-302 Report an error when inheriting many implementations of the same member -namespace kt302 +package kt302 trait A { open fun foo() {} diff --git a/compiler/testData/diagnostics/tests/regressions/kt306.jet b/compiler/testData/diagnostics/tests/regressions/kt306.jet index 4356fe5e10c..b78f2902f9d 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt306.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt306.jet @@ -1,14 +1,14 @@ // KT-306 Ambiguity when different this's have same-looking functions fun test() { - {Foo.() => + {Foo.() -> bar() - {Barr.() => + {Barr.() -> this.bar() bar() } } - {Barr.() => + {Barr.() -> bar() } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt328.jet b/compiler/testData/diagnostics/tests/regressions/kt328.jet index 79ac13f9e0d..f396b3f67e1 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt328.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt328.jet @@ -21,7 +21,7 @@ val x = { <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>x<!> } val z = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>z<!> //KT-329 Assertion failure on local function -fun block(f : fun() : Unit) = f() +fun block(f : () -> Unit) = f() fun bar3() = block{ <!UNRESOLVED_REFERENCE!>foo3<!>() // <-- missing closing curly bracket fun foo3() = block{ <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar3()<!> }<!SYNTAX!><!> diff --git a/compiler/testData/diagnostics/tests/regressions/kt352.jet b/compiler/testData/diagnostics/tests/regressions/kt352.jet index 74f9ddecdb0..52eb5122d37 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt352.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt352.jet @@ -1,26 +1,26 @@ //KT-352 Function variable declaration type isn't checked inside a function body -namespace kt352 +package kt352 -val f : fun(Any) : Unit = <!TYPE_MISMATCH!>{ () : Unit => }<!> //type mismatch +val f : (Any) -> Unit = <!TYPE_MISMATCH!>{ () : Unit -> }<!> //type mismatch fun foo() { - val <!UNUSED_VARIABLE!>f<!> : fun(Any) : Unit = <!TYPE_MISMATCH!>{ () : Unit => }<!> //!!! no error + val <!UNUSED_VARIABLE!>f<!> : (Any) -> Unit = <!TYPE_MISMATCH!>{ () : Unit -> }<!> //!!! no error } class A() { - val f : fun(Any) : Unit = <!TYPE_MISMATCH!>{ () : Unit => }<!> //type mismatch + val f : (Any) -> Unit = <!TYPE_MISMATCH!>{ () : Unit -> }<!> //type mismatch } //more tests -val g : fun() : Unit = <!TYPE_MISMATCH!>{ (): Int => 42 }<!> +val g : () -> Unit = <!TYPE_MISMATCH!>{ (): Int -> 42 }<!> -val h : fun() : Unit = { doSmth() } +val h : () -> Unit = { doSmth() } fun doSmth(): Int = 42 fun doSmth(<!UNUSED_PARAMETER!>a<!>: String) {} -val testIt : fun(Any) : Unit = { +val testIt : (Any) -> Unit = { if (it is String) { doSmth(it) } diff --git a/compiler/testData/diagnostics/tests/regressions/kt353.jet b/compiler/testData/diagnostics/tests/regressions/kt353.jet index bc2a4f6df2f..5194b492db7 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt353.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt353.jet @@ -5,7 +5,7 @@ trait A { } fun foo(a: A) { - val <!UNUSED_VARIABLE!>g<!> : fun() : Unit = { + val <!UNUSED_VARIABLE!>g<!> : () -> Unit = { a.gen() //it works: Unit is derived } @@ -15,16 +15,16 @@ fun foo(a: A) { a.<!TYPE_INFERENCE_FAILED!>gen()<!> // Shouldn't work: no info for inference } - val <!UNUSED_VARIABLE!>b<!> : fun() : Unit = { + val <!UNUSED_VARIABLE!>b<!> : () -> Unit = { if (true) { a.gen() // unit can be inferred } else { - () + #() } } - val <!UNUSED_VARIABLE!>f<!> : fun() : Int = { () : Int => + val <!UNUSED_VARIABLE!>f<!> : () -> Int = { () : Int -> a.gen() //type mismatch, but Int can be derived } diff --git a/compiler/testData/diagnostics/tests/regressions/kt385.109.441.jet b/compiler/testData/diagnostics/tests/regressions/kt385.109.441.jet index 9dcac990807..d87d244f290 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt385.109.441.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt385.109.441.jet @@ -5,29 +5,29 @@ import java.util.* -fun <T> Iterator<T>.foreach(operation: fun(element: T) : Unit) : Unit = while(hasNext) operation(next()) +fun <T> Iterator<T>.foreach(operation: (element: T) -> Unit) : Unit = while(hasNext) operation(next()) -fun <T> Iterator<T>.foreach(operation: fun(index: Int, element: T) : Unit) : Unit { +fun <T> Iterator<T>.foreach(operation: (index: Int, element: T) -> Unit) : Unit { var k = 0 while(hasNext) operation(k++, next()) } -fun <T> Iterable<T>.foreach(operation: fun(element: T) : Unit) : Unit = iterator() foreach operation +fun <T> Iterable<T>.foreach(operation: (element: T) -> Unit) : Unit = iterator() foreach operation -fun <T> Iterable<T>.foreach(operation: fun(index: Int, element: T) : Unit) : Unit = iterator() foreach operation +fun <T> Iterable<T>.foreach(operation: (index: Int, element: T) -> Unit) : Unit = iterator() foreach operation fun box() : String { - return generic_invoker( { () : String => "OK"} ) + return generic_invoker( { () : String -> "OK"} ) } -fun <T> generic_invoker(gen : fun () : T) : T { +fun <T> generic_invoker(gen : () -> T) : T { return gen() } fun println(message : Int) { System.out?.println(message) } fun println(message : Long) { System.out?.println(message) } -inline fun run<T>(body : fun() : T) : T = body() +inline fun run<T>(body : () -> T) : T = body() fun main(args : Array<String>) { diff --git a/compiler/testData/diagnostics/tests/regressions/kt398.jet b/compiler/testData/diagnostics/tests/regressions/kt398.jet index 1babedaf8f4..7607d58dece 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt398.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt398.jet @@ -1,7 +1,7 @@ // KT-398 Internal error when property initializes with function class X<T>() { - val check = { (a : Any) => a is T } + val check = { (a : Any) -> a is T } } fun box() : String { diff --git a/compiler/testData/diagnostics/tests/regressions/kt399.jet b/compiler/testData/diagnostics/tests/regressions/kt399.jet index 3c52df4cc6e..ce92c6e50b4 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt399.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt399.jet @@ -1,7 +1,7 @@ // KT-399 Type argument inference not implemented for CALL_EXPRESSION fun <T> getSameTypeChecker(<!UNUSED_PARAMETER!>obj<!>: T) : Function1<Any,Boolean> { - return { (a : Any) => a is T } + return { (a : Any) -> a is T } } fun box() : String { diff --git a/compiler/testData/diagnostics/tests/regressions/kt402.jet b/compiler/testData/diagnostics/tests/regressions/kt402.jet index 7df59b2aa2f..a1e70b417f2 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt402.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt402.jet @@ -1,8 +1,8 @@ -namespace kt402 +package kt402 -fun getTypeChecker() : fun(Any):Boolean { - <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{ (a : Any) => a is <!UNRESOLVED_REFERENCE!>T<!> }<!> // reports unsupported +fun getTypeChecker() : (Any)->Boolean { + <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{ (a : Any) -> a is <!UNRESOLVED_REFERENCE!>T<!> }<!> // reports unsupported } -fun f() : fun(Any) : Boolean { - return { (a : Any) => a is String } +fun f() : (Any) -> Boolean { + return { (a : Any) -> a is String } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt41.jet b/compiler/testData/diagnostics/tests/regressions/kt41.jet index 84ec9616fae..91e93881f06 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt41.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt41.jet @@ -1,6 +1,6 @@ // KT-41 Make functions with errors in returning statement return ERROR type and not Nothing -namespace kt41 +package kt41 fun aaa() = 6 <!UNRESOLVED_REFERENCE!>foo<!> 1 diff --git a/compiler/testData/diagnostics/tests/regressions/kt411.jet b/compiler/testData/diagnostics/tests/regressions/kt411.jet index 0828b9a4efd..1397f9092f2 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt411.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt411.jet @@ -1,6 +1,6 @@ //kt-411 Wrong type expected when returning from a function literal -namespace kt411 +package kt411 fun f() { invoker( @@ -9,17 +9,17 @@ fun f() { } ) } -fun invoker(<!UNUSED_PARAMETER!>gen<!> : fun() : Int) : Int = 0 +fun invoker(<!UNUSED_PARAMETER!>gen<!> : () -> Int) : Int = 0 //more tests fun t1() { - val <!UNUSED_VARIABLE!>v<!> = @{ () : Int => + val <!UNUSED_VARIABLE!>v<!> = @{ () : Int -> return@ 111 } } fun t2() : String { - val <!UNUSED_VARIABLE!>g<!> : fun(): Int = @{ + val <!UNUSED_VARIABLE!>g<!> : ()-> Int = @{ if (true) { return@ 1 } @@ -41,7 +41,7 @@ fun t3() : String { } ) invoker( - @{ (): Int => + @{ (): Int -> return@ 1 } ) @@ -54,10 +54,10 @@ fun t3() : String { } fun t4() : Int { - val <!UNUSED_VARIABLE!>h<!> : fun (): String = @l{ + val <!UNUSED_VARIABLE!>h<!> : ()-> String = @l{ return@l "a" } - val <!UNUSED_VARIABLE!>g<!> : fun (): String = @{ () : String => + val <!UNUSED_VARIABLE!>g<!> : ()-> String = @{ () : String -> return@ "a" } diff --git a/compiler/testData/diagnostics/tests/regressions/kt439.jet b/compiler/testData/diagnostics/tests/regressions/kt439.jet index 176e3280e18..49fd6e28082 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt439.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt439.jet @@ -1,6 +1,6 @@ // KT-439 Support labeled function literals in call arguments -inline fun run1<T>(body : fun() : T) : T = body() +inline fun run1<T>(body : () -> T) : T = body() fun main1(<!UNUSED_PARAMETER!>args<!> : Array<String>) { run1 @l{ 1 } // should not be an error diff --git a/compiler/testData/diagnostics/tests/regressions/kt442.jet b/compiler/testData/diagnostics/tests/regressions/kt442.jet index 0618918b14a..9b4e1c745d2 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt442.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt442.jet @@ -1,12 +1,12 @@ // KT-442 Type inference fails on with() -fun <T> funny(f : fun() : T) : T = f() +fun <T> funny(f : () -> T) : T = f() fun testFunny() { val <!UNUSED_VARIABLE!>a<!> : Int = funny {1} } -fun <T> funny2(<!UNUSED_PARAMETER!>f<!> : fun(t : T) : T) : T <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!> +fun <T> funny2(<!UNUSED_PARAMETER!>f<!> : (t : T) -> T) : T <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!> fun testFunny2() { val <!UNUSED_VARIABLE!>a<!> : Int = funny2 {it} @@ -16,11 +16,11 @@ fun box() : String { return generic_invoker { it } } -fun <T> generic_invoker(gen : fun (String) : T) : T { +fun <T> generic_invoker(gen : (String) -> T) : T { return gen("") } -fun <T> T.with(f : fun T.()) { +fun <T> T.with(f : T.() -> Unit) { f() } diff --git a/compiler/testData/diagnostics/tests/regressions/kt455.jet b/compiler/testData/diagnostics/tests/regressions/kt455.jet index 0db1c1c4ae9..a30e73c4bff 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt455.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt455.jet @@ -1,6 +1,6 @@ //KT-455 Do not repeat errors in definite assignment checks -namespace kt455 +package kt455 fun foo() { val a: Int diff --git a/compiler/testData/diagnostics/tests/regressions/kt456.jet b/compiler/testData/diagnostics/tests/regressions/kt456.jet index d27eb2d3faa..8d67585ff38 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt456.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt456.jet @@ -1,6 +1,6 @@ //KT-456 No check for obligatory return in getters -namespace kt456 +package kt456 class A() { val i: Int diff --git a/compiler/testData/diagnostics/tests/regressions/kt469.jet b/compiler/testData/diagnostics/tests/regressions/kt469.jet index a9ff4c1d291..ee21f757324 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt469.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt469.jet @@ -1,6 +1,6 @@ // +JDK -namespace kt469 +package kt469 //KT-512 plusAssign() : Unit does not work properly import java.util.* diff --git a/compiler/testData/diagnostics/tests/regressions/kt524.jet b/compiler/testData/diagnostics/tests/regressions/kt524.jet index 9ffcd1f564a..f4da82809a4 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt524.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt524.jet @@ -1,7 +1,7 @@ // KT-524 sure() returns T // +JDK -namespace StringBuilder +package StringBuilder import java.lang.StringBuilder diff --git a/compiler/testData/diagnostics/tests/regressions/kt526UnresolvedReferenceInnerStatic.jet b/compiler/testData/diagnostics/tests/regressions/kt526UnresolvedReferenceInnerStatic.jet index b258404a6f6..65a0bccdbf4 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt526UnresolvedReferenceInnerStatic.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt526UnresolvedReferenceInnerStatic.jet @@ -1,7 +1,7 @@ // http://youtrack.jetbrains.net/issue/KT-526 // KT-526 Unresolved reference for inner static class -namespace demo +package demo class Foo { class object { diff --git a/compiler/testData/diagnostics/tests/regressions/kt549.jet b/compiler/testData/diagnostics/tests/regressions/kt549.jet index 5fc17be122b..2b3f087420f 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt549.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt549.jet @@ -1,9 +1,9 @@ //KT-549 type inference failed // +JDK -namespace demo +package demo - fun filter<T>(list : Array<T>, filter : fun (T) : Boolean) : java.util.List<T> { + fun filter<T>(list : Array<T>, filter : (T) -> Boolean) : java.util.List<T> { val answer = java.util.ArrayList<T>(); for (l in list) { if (filter(l)) answer.add(l) diff --git a/compiler/testData/diagnostics/tests/regressions/kt571.jet b/compiler/testData/diagnostics/tests/regressions/kt571.jet index 2333eb78644..9a6cfce30a6 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt571.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt571.jet @@ -1,3 +1,3 @@ //KT-571 Type inference failed -fun <T, R> let(t : T, body : fun(T) : R) = body(t) +fun <T, R> let(t : T, body : (T) -> R) = body(t) private fun double(d : Int) : Int = let(d * 2) {it / 10 + it * 2 % 10} diff --git a/compiler/testData/diagnostics/tests/regressions/kt575.jet b/compiler/testData/diagnostics/tests/regressions/kt575.jet index aaa84ac3c9f..6f796301ad7 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt575.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt575.jet @@ -1,6 +1,6 @@ // KT-575 Cannot ++ a class object member -namespace kt575 +package kt575 class Creature() { class object { diff --git a/compiler/testData/diagnostics/tests/regressions/kt58.jet b/compiler/testData/diagnostics/tests/regressions/kt58.jet index d6a0e64456f..7b7a7526755 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt58.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt58.jet @@ -1,11 +1,11 @@ //KT-58 Allow finally around definite returns // +JDK -namespace kt58 +package kt58 import java.util.concurrent.locks.Lock -fun lock<T>(lock : Lock, body : fun () : T) : T { +fun lock<T>(lock : Lock, body : () -> T) : T { lock.lock() try { return body() diff --git a/compiler/testData/diagnostics/tests/regressions/kt580.jet b/compiler/testData/diagnostics/tests/regressions/kt580.jet index c2d12ec6e93..8816e416104 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt580.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt580.jet @@ -1,7 +1,7 @@ //KT-580 Type inference failed // +JDK -namespace whats.the.difference +package whats.the.difference import java.util.* diff --git a/compiler/testData/diagnostics/tests/regressions/kt604.jet b/compiler/testData/diagnostics/tests/regressions/kt604.jet index 02f079e6900..de0926b0208 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt604.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt604.jet @@ -11,7 +11,7 @@ trait ChannelPipelineFactory{ fun getPipeline() : ChannelPipeline } -class StandardPipelineFactory(val config: fun ChannelPipeline.():Unit) : ChannelPipelineFactory { +class StandardPipelineFactory(val config: ChannelPipeline.()->Unit) : ChannelPipelineFactory { override fun getPipeline() : ChannelPipeline { val pipeline = DefaultChannelPipeline() pipeline.config () diff --git a/compiler/testData/diagnostics/tests/regressions/kt618.jet b/compiler/testData/diagnostics/tests/regressions/kt618.jet index f70f921730e..2ef9ef9d760 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt618.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt618.jet @@ -1,4 +1,4 @@ -namespace lol +package lol class B() { fun plusAssign(<!UNUSED_PARAMETER!>other<!> : B) : String { diff --git a/compiler/testData/diagnostics/tests/regressions/kt629.jet b/compiler/testData/diagnostics/tests/regressions/kt629.jet index f0c8780ad9a..8dd6bc71d81 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt629.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt629.jet @@ -1,6 +1,6 @@ //KT-629 Assignments are parsed as expressions. -namespace kt629 +package kt629 class A() { var p = "yeah" diff --git a/compiler/testData/diagnostics/tests/regressions/kt688.jet b/compiler/testData/diagnostics/tests/regressions/kt688.jet index 045dddc7d8f..7ff7a78081b 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt688.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt688.jet @@ -6,7 +6,7 @@ open class B() : A() { class C() { - fun a<T>(x: fun(T):T, y: T): T { + fun a<T>(x: (T)->T, y: T): T { return x(x(y)) } diff --git a/compiler/testData/diagnostics/tests/regressions/kt691.jet b/compiler/testData/diagnostics/tests/regressions/kt691.jet index e7194b099c9..649df9d3c90 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt691.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt691.jet @@ -1,2 +1,2 @@ // KT-691 Allow to create nested namespaces with dot delimiter -namespace foo.bar.buz \ No newline at end of file +package foo.bar.buz \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt743.jet b/compiler/testData/diagnostics/tests/regressions/kt743.jet index faecff09851..2988a573a65 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt743.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt743.jet @@ -2,5 +2,5 @@ // +JDK class List<T>(val head: T, val tail: List<T>? = null) -fun <T, Q> List<T>.map(f: fun(T): Q): List<T>? = tail.sure<List<T>>().map(f) +fun <T, Q> List<T>.map(f: (T)-> Q): List<T>? = tail.sure<List<T>>().map(f) fun foo<T>(t : T) : T = foo(t) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt860.jet b/compiler/testData/diagnostics/tests/regressions/kt860.jet index d8acf4fad50..4f01757e730 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt860.jet +++ b/compiler/testData/diagnostics/tests/regressions/kt860.jet @@ -1,7 +1,7 @@ // KT-860 ConcurrentModificationException in frontend // +JDK -namespace std.util +package std.util import java.util.* diff --git a/compiler/testData/diagnostics/tests/scopes/Imports.jet b/compiler/testData/diagnostics/tests/scopes/Imports.jet index 508f623ccf1..8ff30e6834d 100644 --- a/compiler/testData/diagnostics/tests/scopes/Imports.jet +++ b/compiler/testData/diagnostics/tests/scopes/Imports.jet @@ -1,5 +1,5 @@ //FILE:a.kt -namespace a +package a import b.B //class import b.foo //function @@ -14,7 +14,7 @@ fun test(arg: B) { } //FILE:b.kt -namespace b +package b class B() {} diff --git a/compiler/testData/diagnostics/tests/scopes/kt250.617.10.jet b/compiler/testData/diagnostics/tests/scopes/kt250.617.10.jet index 1b0a3c71177..a7c98104ac7 100644 --- a/compiler/testData/diagnostics/tests/scopes/kt250.617.10.jet +++ b/compiler/testData/diagnostics/tests/scopes/kt250.617.10.jet @@ -1,6 +1,6 @@ // +JDK -namespace kt_250_617_10 +package kt_250_617_10 import java.util.ArrayList import java.util.HashMap diff --git a/compiler/testData/diagnostics/tests/shadowing/ShadowPropertyInClosure.jet b/compiler/testData/diagnostics/tests/shadowing/ShadowPropertyInClosure.jet index c785e3f5fc7..00c0d038398 100644 --- a/compiler/testData/diagnostics/tests/shadowing/ShadowPropertyInClosure.jet +++ b/compiler/testData/diagnostics/tests/shadowing/ShadowPropertyInClosure.jet @@ -1,3 +1,3 @@ val i = 17 -val f = { (): Int => var i = 17; i } +val f = { (): Int -> var i = 17; i } diff --git a/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosure.jet b/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosure.jet index d9dd9110893..e448f74f8c9 100644 --- a/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosure.jet +++ b/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosure.jet @@ -1,5 +1,5 @@ fun f(): Int { var i = 17 - { (): Unit => var <!NAME_SHADOWING!>i<!> = 18 } + { (): Unit -> var <!NAME_SHADOWING!>i<!> = 18 } return i } diff --git a/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosureParam.jet b/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosureParam.jet index 6ba5fd4c919..d926e4bca41 100644 --- a/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosureParam.jet +++ b/compiler/testData/diagnostics/tests/shadowing/ShadowVariableInNestedClosureParam.jet @@ -1,5 +1,5 @@ fun ff(): Int { var i = 1 - { (i: Int) => i } + { (i: Int) -> i } return i } diff --git a/compiler/testData/psi/Attributes.jet b/compiler/testData/psi/Attributes.jet index 321691b72dc..2cf3b445414 100644 --- a/compiler/testData/psi/Attributes.jet +++ b/compiler/testData/psi/Attributes.jet @@ -1,4 +1,4 @@ -namespace foo.bar.goo +package foo.bar.goo abstract open diff --git a/compiler/testData/psi/Attributes.txt b/compiler/testData/psi/Attributes.txt index 6cb067b94eb..8119149e1b8 100644 --- a/compiler/testData/psi/Attributes.txt +++ b/compiler/testData/psi/Attributes.txt @@ -1,7 +1,7 @@ JetFile: Attributes.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') diff --git a/compiler/testData/psi/AttributesOnPatterns.jet b/compiler/testData/psi/AttributesOnPatterns.jet index ec9ead0312a..c485e7ca69a 100644 --- a/compiler/testData/psi/AttributesOnPatterns.jet +++ b/compiler/testData/psi/AttributesOnPatterns.jet @@ -1,11 +1,11 @@ fun foo() { when (e) { - is [a] val a => d - is [a] val a is foo => d - is [a] * => d - is [a] 2 => d - is [a] T => d - is [a] T @ () => d + is [a] val a -> d + is [a] val a is foo -> d + is [a] * -> d + is [a] 2 -> d + is [a] T -> d + is [a] T #() -> d } } diff --git a/compiler/testData/psi/AttributesOnPatterns.txt b/compiler/testData/psi/AttributesOnPatterns.txt index 545e0b1f3b1..c2b2d07c73c 100644 --- a/compiler/testData/psi/AttributesOnPatterns.txt +++ b/compiler/testData/psi/AttributesOnPatterns.txt @@ -43,7 +43,7 @@ JetFile: AttributesOnPatterns.jet PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') @@ -77,7 +77,7 @@ JetFile: AttributesOnPatterns.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') @@ -99,7 +99,7 @@ JetFile: AttributesOnPatterns.jet PsiWhiteSpace(' ') PsiElement(MUL)('*') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') @@ -122,7 +122,7 @@ JetFile: AttributesOnPatterns.jet INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('2') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') @@ -147,7 +147,7 @@ JetFile: AttributesOnPatterns.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') @@ -169,14 +169,13 @@ JetFile: AttributesOnPatterns.jet PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') diff --git a/compiler/testData/psi/Attributes_ERR.jet b/compiler/testData/psi/Attributes_ERR.jet index 03e73f7b999..7bc5aaa1e14 100644 --- a/compiler/testData/psi/Attributes_ERR.jet +++ b/compiler/testData/psi/Attributes_ERR.jet @@ -1,4 +1,4 @@ -namespace foo.bar.goo +package foo.bar.goo abstract open diff --git a/compiler/testData/psi/Attributes_ERR.txt b/compiler/testData/psi/Attributes_ERR.txt index 0f8116df665..9a1cb87e2ca 100644 --- a/compiler/testData/psi/Attributes_ERR.txt +++ b/compiler/testData/psi/Attributes_ERR.txt @@ -1,7 +1,7 @@ JetFile: Attributes_ERR.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') diff --git a/compiler/testData/psi/BabySteps.jet b/compiler/testData/psi/BabySteps.jet index a96fa43ff48..cf99c2a5705 100644 --- a/compiler/testData/psi/BabySteps.jet +++ b/compiler/testData/psi/BabySteps.jet @@ -1,4 +1,4 @@ -namespace foo +package foo class Runnable<a,a>(a : doo = 0) : foo(d=0), bar by x, bar { diff --git a/compiler/testData/psi/BabySteps.txt b/compiler/testData/psi/BabySteps.txt index fbdf8deeafb..237827701cd 100644 --- a/compiler/testData/psi/BabySteps.txt +++ b/compiler/testData/psi/BabySteps.txt @@ -1,7 +1,7 @@ JetFile: BabySteps.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/BabySteps_ERR.jet b/compiler/testData/psi/BabySteps_ERR.jet index 97653321e3c..5648633c7f0 100644 --- a/compiler/testData/psi/BabySteps_ERR.jet +++ b/compiler/testData/psi/BabySteps_ERR.jet @@ -1,4 +1,4 @@ -namespace foo +package foo class Runnable<a,a>(a : doo = 0) : foo(d=0), ,bar by x, bar { diff --git a/compiler/testData/psi/BabySteps_ERR.txt b/compiler/testData/psi/BabySteps_ERR.txt index 9f0a5ea788b..4838223fe42 100644 --- a/compiler/testData/psi/BabySteps_ERR.txt +++ b/compiler/testData/psi/BabySteps_ERR.txt @@ -1,7 +1,7 @@ JetFile: BabySteps_ERR.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/CallsInWhen.jet b/compiler/testData/psi/CallsInWhen.jet index 2675ba89523..4cacfb5fff4 100644 --- a/compiler/testData/psi/CallsInWhen.jet +++ b/compiler/testData/psi/CallsInWhen.jet @@ -1,14 +1,14 @@ fun foo() { when (a) { - a.foo => a - a.foo() => a - a.foo<T> => a - a.foo<T>(a) => a - a.foo<T>(a, d) => a - a.{bar} => a - a.{!bar} => a - a.{() => !bar} => a - else => a + a.foo -> a + a.foo() -> a + a.foo<T> -> a + a.foo<T>(a) -> a + a.foo<T>(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 4bde9526e87..d67bce4cd23 100644 --- a/compiler/testData/psi/CallsInWhen.txt +++ b/compiler/testData/psi/CallsInWhen.txt @@ -33,7 +33,7 @@ JetFile: CallsInWhen.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -52,7 +52,7 @@ JetFile: CallsInWhen.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -76,7 +76,7 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('T') PsiElement(GT)('>') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -106,7 +106,7 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -141,7 +141,7 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('d') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -161,7 +161,7 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('bar') PsiElement(RBRACE)('}') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -184,7 +184,7 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('bar') PsiElement(RBRACE)('}') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -203,7 +203,7 @@ JetFile: CallsInWhen.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK PREFIX_EXPRESSION @@ -213,7 +213,7 @@ JetFile: CallsInWhen.jet PsiElement(IDENTIFIER)('bar') PsiElement(RBRACE)('}') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -221,7 +221,7 @@ JetFile: CallsInWhen.jet WHEN_ENTRY PsiElement(else)('else') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') diff --git a/compiler/testData/psi/ExtensionsWithQNReceiver.jet b/compiler/testData/psi/ExtensionsWithQNReceiver.jet new file mode 100644 index 00000000000..78ae76a6a32 --- /dev/null +++ b/compiler/testData/psi/ExtensionsWithQNReceiver.jet @@ -0,0 +1,3 @@ +val java.util.Map<*,*>.size : Int + +fun java.util.Map<*,*>.size() : Int = 1 diff --git a/compiler/testData/psi/ExtensionsWithQNReceiver.txt b/compiler/testData/psi/ExtensionsWithQNReceiver.txt new file mode 100644 index 00000000000..1baa3c557fc --- /dev/null +++ b/compiler/testData/psi/ExtensionsWithQNReceiver.txt @@ -0,0 +1,77 @@ +JetFile: ExtensionsWithQNReceiver.jet + NAMESPACE + NAMESPACE_HEADER + <empty list> + PROPERTY + PsiElement(val)('val') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('util') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Map') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + PsiElement(MUL)('*') + PsiElement(COMMA)(',') + TYPE_PROJECTION + PsiElement(MUL)('*') + PsiElement(GT)('>') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace('\n\n') + FUN + PsiElement(fun)('fun') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('java') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('util') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Map') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + PsiElement(MUL)('*') + PsiElement(COMMA)(',') + TYPE_PROJECTION + PsiElement(MUL)('*') + PsiElement(GT)('>') + PsiElement(DOT)('.') + PsiElement(IDENTIFIER)('size') + VALUE_PARAMETER_LIST + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Int') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + INTEGER_CONSTANT + PsiElement(INTEGER_LITERAL)('1') \ No newline at end of file diff --git a/compiler/testData/psi/FileStart_ERR.jet b/compiler/testData/psi/FileStart_ERR.jet index dafb2f44095..cbfc8a0477c 100644 --- a/compiler/testData/psi/FileStart_ERR.jet +++ b/compiler/testData/psi/FileStart_ERR.jet @@ -1,2 +1,2 @@ -/namespace foo.bar +/package foo.bar import foo \ No newline at end of file diff --git a/compiler/testData/psi/FileStart_ERR.txt b/compiler/testData/psi/FileStart_ERR.txt index 87894ee76dd..1f3f4e6a14a 100644 --- a/compiler/testData/psi/FileStart_ERR.txt +++ b/compiler/testData/psi/FileStart_ERR.txt @@ -6,7 +6,7 @@ JetFile: FileStart_ERR.jet PsiElement(DIV)('/') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') diff --git a/compiler/testData/psi/FunctionLiterals.jet b/compiler/testData/psi/FunctionLiterals.jet index 6fb663e9924..4c27813eefb 100644 --- a/compiler/testData/psi/FunctionLiterals.jet +++ b/compiler/testData/psi/FunctionLiterals.jet @@ -3,28 +3,28 @@ fun foo() { {foo} - {a => a} + {a -> a} - {(a) => a} - {(a : A) => a} - {(a : A) : T => a} - {(a) : T => a} + {(a) -> a} + {(a : A) -> a} + {(a : A) : T -> a} + {(a) : T -> a} - {(a, a) => a} - {(a : A, a : B) => a} - {(a : A, a) : T => a} - {(a, a : B) : T => a} + {(a, a) -> a} + {(a : A, a : B) -> a} + {(a : A, a) : T -> a} + {(a, a : B) : T -> a} - {() => a} - {() => a} - {() : T => a} - {() : T => a} + {() -> a} + {() -> a} + {() : T -> a} + {() : T -> a} - {T.(a) => a} - {T.(a : A) => a} - {T.(a : A) : T => a} - {T.(a) : T => a} + {T.(a) -> a} + {T.(a : A) -> a} + {T.(a : A) : T -> a} + {T.(a) : T -> a} - {x, y => 1} - {[a] x, [b] y, [c] z => 1} + {x, y -> 1} + {[a] x, [b] y, [c] z -> 1} } diff --git a/compiler/testData/psi/FunctionLiterals.txt b/compiler/testData/psi/FunctionLiterals.txt index 7bf48210b76..13fc16a5f1d 100644 --- a/compiler/testData/psi/FunctionLiterals.txt +++ b/compiler/testData/psi/FunctionLiterals.txt @@ -35,7 +35,7 @@ JetFile: FunctionLiterals.jet VALUE_PARAMETER PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -51,7 +51,7 @@ JetFile: FunctionLiterals.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -74,7 +74,7 @@ JetFile: FunctionLiterals.jet PsiElement(IDENTIFIER)('A') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -104,7 +104,7 @@ JetFile: FunctionLiterals.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -127,7 +127,7 @@ JetFile: FunctionLiterals.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -147,7 +147,7 @@ JetFile: FunctionLiterals.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -181,7 +181,7 @@ JetFile: FunctionLiterals.jet PsiElement(IDENTIFIER)('B') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -215,7 +215,7 @@ JetFile: FunctionLiterals.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -249,7 +249,7 @@ JetFile: FunctionLiterals.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -263,7 +263,7 @@ JetFile: FunctionLiterals.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -277,7 +277,7 @@ JetFile: FunctionLiterals.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -298,7 +298,7 @@ JetFile: FunctionLiterals.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -319,7 +319,7 @@ JetFile: FunctionLiterals.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -340,7 +340,7 @@ JetFile: FunctionLiterals.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -368,7 +368,7 @@ JetFile: FunctionLiterals.jet PsiElement(IDENTIFIER)('A') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -403,7 +403,7 @@ JetFile: FunctionLiterals.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -431,7 +431,7 @@ JetFile: FunctionLiterals.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -449,7 +449,7 @@ JetFile: FunctionLiterals.jet VALUE_PARAMETER PsiElement(IDENTIFIER)('y') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK INTEGER_CONSTANT @@ -459,56 +459,41 @@ JetFile: FunctionLiterals.jet FUNCTION_LITERAL_EXPRESSION FUNCTION_LITERAL PsiElement(LBRACE)('{') - VALUE_PARAMETER_LIST - VALUE_PARAMETER - MODIFIER_LIST - ANNOTATION - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACKET)(']') + BLOCK + ANNOTATED_EXPRESSION + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('x') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - VALUE_PARAMETER - MODIFIER_LIST - ANNOTATION - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiElement(RBRACKET)(']') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('x') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('b') + PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('y') - PsiElement(COMMA)(',') - PsiWhiteSpace(' ') - VALUE_PARAMETER - MODIFIER_LIST - ANNOTATION - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('c') - PsiElement(RBRACKET)(']') + PsiElement(COMMA)(',') + PsiWhiteSpace(' ') + PsiElement(LBRACKET)('[') + PsiElement(IDENTIFIER)('c') + PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('z') - PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') - PsiWhiteSpace(' ') - BLOCK - INTEGER_CONSTANT + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') PsiElement(INTEGER_LITERAL)('1') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') PsiElement(RBRACE)('}') - PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') \ No newline at end of file + PsiErrorElement:Expecting '} + <empty list> \ No newline at end of file diff --git a/compiler/testData/psi/FunctionLiterals_ERR.jet b/compiler/testData/psi/FunctionLiterals_ERR.jet index e0fb54a1dc0..d275d6711a6 100644 --- a/compiler/testData/psi/FunctionLiterals_ERR.jet +++ b/compiler/testData/psi/FunctionLiterals_ERR.jet @@ -1,18 +1,18 @@ fun foo() { - { => a} + { -> a} - {(a => a} - {(a : ) => a} - {(a : A) : => a} - {(a) : T => } + {(a -> a} + {(a : ) -> a} + {(a : A) : -> a} + {(a) : T -> } - {(a, ) => a} - {(a : A, , a : B) => a} - {(a : A, , , a) : T => a} + {(a, ) -> a} + {(a : A, , a : B) -> a} + {(a : A, , , a) : T -> a} - {T.t(a) => a} - {T.t -(a : A) => a} + {T.t(a) -> a} + {T.t -(a : A) -> a} - {a : b => f} - {T.a : b => f} + {a : b -> f} + {T.a : b -> f} } \ No newline at end of file diff --git a/compiler/testData/psi/FunctionLiterals_ERR.txt b/compiler/testData/psi/FunctionLiterals_ERR.txt index 36f5a5db19b..922c8670737 100644 --- a/compiler/testData/psi/FunctionLiterals_ERR.txt +++ b/compiler/testData/psi/FunctionLiterals_ERR.txt @@ -17,12 +17,10 @@ JetFile: FunctionLiterals_ERR.jet FUNCTION_LITERAL PsiElement(LBRACE)('{') PsiWhiteSpace(' ') - VALUE_PARAMETER_LIST - VALUE_PARAMETER - PsiErrorElement:Expecting parameter name - <empty list> - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') + VALUE_PARAMETER_LIST + <empty list> BLOCK REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -38,7 +36,7 @@ JetFile: FunctionLiterals_ERR.jet PsiErrorElement:Expecting ') <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -60,7 +58,7 @@ JetFile: FunctionLiterals_ERR.jet <empty list> PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -87,7 +85,7 @@ JetFile: FunctionLiterals_ERR.jet PsiErrorElement:Expecting a type <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -110,7 +108,7 @@ JetFile: FunctionLiterals_ERR.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK <empty list> @@ -129,7 +127,7 @@ JetFile: FunctionLiterals_ERR.jet PsiWhiteSpace(' ') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -166,7 +164,7 @@ JetFile: FunctionLiterals_ERR.jet PsiElement(IDENTIFIER)('B') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -208,7 +206,7 @@ JetFile: FunctionLiterals_ERR.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK REFERENCE_EXPRESSION @@ -218,100 +216,118 @@ JetFile: FunctionLiterals_ERR.jet FUNCTION_LITERAL_EXPRESSION FUNCTION_LITERAL PsiElement(LBRACE)('{') - TYPE_REFERENCE - USER_TYPE + BLOCK + DOT_QUALIFIED_EXPRESSION REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') - PsiElement(DOT)('.') - PsiErrorElement:Expecting '(' - PsiElement(IDENTIFIER)('t') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - VALUE_PARAMETER - PsiElement(IDENTIFIER)('a') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') - PsiWhiteSpace(' ') - BLOCK - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(DOT)('.') - PsiErrorElement:Expecting '(' - PsiElement(IDENTIFIER)('t') + PsiElement(DOT)('.') + CALL_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('t') + VALUE_ARGUMENT_LIST + PsiElement(LPAR)('(') + VALUE_ARGUMENT + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(MINUS)('-') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - VALUE_PARAMETER - PsiElement(IDENTIFIER)('a') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(ARROW)('->') PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('A') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') - PsiWhiteSpace(' ') - BLOCK - REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - VALUE_PARAMETER_LIST - VALUE_PARAMETER - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiErrorElement:To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType => ...} - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('b') - PsiWhiteSpace(' ') - VALUE_PARAMETER - PsiErrorElement:Expecting parameter name - <empty list> - PsiElement(DOUBLE_ARROW)('=>') - PsiWhiteSpace(' ') - BLOCK - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('f') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n ') - FUNCTION_LITERAL_EXPRESSION - FUNCTION_LITERAL - PsiElement(LBRACE)('{') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiElement(DOT)('.') - PsiErrorElement:To specify a receiver type, use the full notation: {ReceiverType.(parameters) [: ReturnType] => ...} - PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - PsiElement(IDENTIFIER)('b') - PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') - PsiWhiteSpace(' ') - BLOCK - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('f') - PsiElement(RBRACE)('}') - PsiWhiteSpace('\n') - PsiElement(RBRACE)('}') \ No newline at end of file + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + BLOCK + BINARY_EXPRESSION + DOT_QUALIFIED_EXPRESSION + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('t') + PsiWhiteSpace(' ') + OPERATION_REFERENCE + PsiElement(MINUS)('-') + PARENTHESIZED + PsiElement(LPAR)('(') + BINARY_WITH_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + OPERATION_REFERENCE + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('A') + PsiElement(RPAR)(')') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + VALUE_PARAMETER_LIST + VALUE_PARAMETER + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + PsiErrorElement:To specify a type of a parameter or a return type, use the full notation: {(parameter : Type) : ReturnType => ...} + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiErrorElement:Expecting parameter name + <empty list> + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + BLOCK + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n ') + FUNCTION_LITERAL_EXPRESSION + FUNCTION_LITERAL + PsiElement(LBRACE)('{') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiElement(DOT)('.') + VALUE_PARAMETER_LIST + PsiErrorElement:Expecting a parameter list in parentheses (...) + PsiElement(IDENTIFIER)('a') + PsiWhiteSpace(' ') + VALUE_PARAMETER + PsiErrorElement:Expecting parameter declaration + <empty list> + PsiElement(COLON)(':') + PsiWhiteSpace(' ') + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiErrorElement:Expecting ') + <empty list> + PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + BLOCK + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiElement(RBRACE)('}') + PsiWhiteSpace('\n') + PsiElement(RBRACE)('}') + PsiErrorElement:Expecting '}' + <empty list> \ No newline at end of file diff --git a/compiler/testData/psi/FunctionTypes.jet b/compiler/testData/psi/FunctionTypes.jet index 4187222c8e0..0e94be440f8 100644 --- a/compiler/testData/psi/FunctionTypes.jet +++ b/compiler/testData/psi/FunctionTypes.jet @@ -1,24 +1,24 @@ -type f = fun ([a] a) : b -type f = fun (a) : b -type f = fun () : [x] b -type f = fun () : () +type f = ([a] a) -> b +type f = (a) -> b +type f = () -> [x] b +type f = () -> #() -type f = fun (a : [a] a) : b -type f = fun (a : a) : b -type f = fun () : b -type f = fun () : () +type f = (a : [a] a) -> b +type f = (a : a) -> b +type f = () -> b +type f = () -> #() -type f = fun (a : [a] a, foo, x : bar) : b -type f = fun (foo, a : a) : b -type f = fun (foo, a : fun (a) : b) : b -type f = fun (foo, a : fun (a) : b) : fun () : () +type f = (a : [a] a, foo, x : bar) -> b +type f = (foo, a : a) -> b +type f = (foo, a : (a) -> b) -> b +type f = (foo, a : (a) -> b) -> () -> #() -type f = fun (ref foo, ref a : fun (ref a) : b) : fun () : () +type f = (ref foo, ref a : (ref a) -> b) -> () -> #() -type f = fun T.() : () -type f = fun T.T.() : () -type f = fun T<A, B>.T<x>.() : () +type f = T.() -> #() +type f = T.T.() -> #() +type f = T<A, B>.T<x>.() -> #() -type f = [a] fun T.() : () -type f = [a] fun T.T.() : () -type f = [a] fun T<A, B>.T<x>.() : () +type f = [a] T.() -> #() +type f = [a] T.T.() -> #() +type f = [a] T<A, B>.T<x>.() -> #() diff --git a/compiler/testData/psi/FunctionTypes.txt b/compiler/testData/psi/FunctionTypes.txt index 47e8aa32ae6..3442c373210 100644 --- a/compiler/testData/psi/FunctionTypes.txt +++ b/compiler/testData/psi/FunctionTypes.txt @@ -10,11 +10,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -35,7 +33,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -50,11 +48,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -64,7 +60,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -79,16 +75,14 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE ANNOTATION @@ -113,19 +107,18 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') @@ -137,11 +130,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -165,7 +156,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -180,11 +171,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -198,7 +187,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -213,16 +202,14 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -237,19 +224,18 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') @@ -261,11 +247,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -307,7 +291,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('bar') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -322,11 +306,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -347,7 +329,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -362,11 +344,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -380,11 +360,9 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -394,7 +372,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -402,7 +380,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -417,11 +395,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -435,11 +411,9 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -449,7 +423,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -457,20 +431,19 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') @@ -482,11 +455,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -506,11 +477,9 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -523,7 +492,7 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -531,20 +500,19 @@ JetFile: FunctionTypes.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') @@ -556,11 +524,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION @@ -570,10 +536,11 @@ JetFile: FunctionTypes.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n') @@ -585,11 +552,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE USER_TYPE @@ -603,10 +568,11 @@ JetFile: FunctionTypes.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n') @@ -618,11 +584,9 @@ JetFile: FunctionTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE USER_TYPE @@ -659,10 +623,11 @@ JetFile: FunctionTypes.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') @@ -676,20 +641,18 @@ JetFile: FunctionTypes.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE - ANNOTATION - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') USER_TYPE REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') @@ -698,10 +661,11 @@ JetFile: FunctionTypes.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n') @@ -715,20 +679,18 @@ JetFile: FunctionTypes.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE - ANNOTATION - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') USER_TYPE USER_TYPE REFERENCE_EXPRESSION @@ -741,10 +703,11 @@ JetFile: FunctionTypes.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n') @@ -758,20 +721,18 @@ JetFile: FunctionTypes.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') TYPE_REFERENCE - ANNOTATION - PsiElement(LBRACKET)('[') - ANNOTATION_ENTRY - CONSTRUCTOR_CALLEE - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('a') - PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE + ANNOTATION + PsiElement(LBRACKET)('[') + ANNOTATION_ENTRY + CONSTRUCTOR_CALLEE + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(RBRACKET)(']') + PsiWhiteSpace(' ') USER_TYPE USER_TYPE REFERENCE_EXPRESSION @@ -807,9 +768,10 @@ JetFile: FunctionTypes.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') \ No newline at end of file diff --git a/compiler/testData/psi/FunctionTypes_ERR.jet b/compiler/testData/psi/FunctionTypes_ERR.jet index 204ee20a422..f948522e84e 100644 --- a/compiler/testData/psi/FunctionTypes_ERR.jet +++ b/compiler/testData/psi/FunctionTypes_ERR.jet @@ -1 +1 @@ -type f = fun (a, ) : b +type f = (a, ) -> b diff --git a/compiler/testData/psi/FunctionTypes_ERR.txt b/compiler/testData/psi/FunctionTypes_ERR.txt index 80d5db63e38..d3201689668 100644 --- a/compiler/testData/psi/FunctionTypes_ERR.txt +++ b/compiler/testData/psi/FunctionTypes_ERR.txt @@ -10,11 +10,9 @@ JetFile: FunctionTypes_ERR.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -28,7 +26,7 @@ JetFile: FunctionTypes_ERR.jet PsiWhiteSpace(' ') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE diff --git a/compiler/testData/psi/Functions.jet b/compiler/testData/psi/Functions.jet index bc7ed706c1d..86bb4dbce06 100644 --- a/compiler/testData/psi/Functions.jet +++ b/compiler/testData/psi/Functions.jet @@ -2,21 +2,21 @@ fun foo() fun [a] foo() fun [a] T.foo() fun [a] T.foo(a : foo) : bar -fun [a()] T.foo<T : fun (a) : b>(a : foo) : bar +fun [a()] T.foo<T : (a) -> b>(a : foo) : bar fun foo(); fun [a] foo(); fun [a] T.foo(); fun [a] T.foo(a : foo) : bar; -fun [a()] T.foo<T : fun (a) : b>(a : foo) : bar; +fun [a()] T.foo<T : (a) -> b>(a : foo) : bar; fun foo() {} fun [a] foo() {} fun [a] T.foo() {} fun [a] T.foo(a : foo) : bar {} -fun [a()] T.foo<T : fun (a) : b>(a : foo) : bar {} +fun [a()] T.foo<T : (a) -> b>(a : foo) : bar {} -fun [a()] T.foo<T : [a] fun (a) : b>(a : foo) : bar {} +fun [a()] T.foo<T : [a] (a) -> b>(a : foo) : bar {} fun A?.foo() : bar? fun A? .foo() : bar? \ No newline at end of file diff --git a/compiler/testData/psi/Functions.txt b/compiler/testData/psi/Functions.txt index 9626affdd1a..03ea683c1af 100644 --- a/compiler/testData/psi/Functions.txt +++ b/compiler/testData/psi/Functions.txt @@ -118,11 +118,9 @@ JetFile: Functions.jet PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -132,7 +130,7 @@ JetFile: Functions.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -279,11 +277,9 @@ JetFile: Functions.jet PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -293,7 +289,7 @@ JetFile: Functions.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -453,11 +449,9 @@ JetFile: Functions.jet PsiElement(IDENTIFIER)('T') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -467,7 +461,7 @@ JetFile: Functions.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -537,10 +531,8 @@ JetFile: Functions.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -550,7 +542,7 @@ JetFile: Functions.jet PsiElement(IDENTIFIER)('a') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE diff --git a/compiler/testData/psi/Imports.jet b/compiler/testData/psi/Imports.jet index 6230669c2ae..c808898ab53 100644 --- a/compiler/testData/psi/Imports.jet +++ b/compiler/testData/psi/Imports.jet @@ -1,6 +1,6 @@ -namespace foo.bar.goo +package foo.bar.goo -import namespace.foo +import package.foo import foo import foo.bar import foo as bar diff --git a/compiler/testData/psi/Imports.txt b/compiler/testData/psi/Imports.txt index b80711ff1a2..ffcd168724f 100644 --- a/compiler/testData/psi/Imports.txt +++ b/compiler/testData/psi/Imports.txt @@ -1,7 +1,7 @@ JetFile: Imports.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -14,7 +14,7 @@ JetFile: Imports.jet IMPORT_DIRECTIVE PsiElement(import)('import') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') diff --git a/compiler/testData/psi/Imports_ERR.jet b/compiler/testData/psi/Imports_ERR.jet index 3d27c2cefdf..32df24ac58b 100644 --- a/compiler/testData/psi/Imports_ERR.jet +++ b/compiler/testData/psi/Imports_ERR.jet @@ -1,8 +1,8 @@ -namespace foo.bar.goo +package foo.bar.goo -import namespace ; -import namespace.* -import namespace. ; +import package ; +import package.* +import package. ; import foo as import foo. diff --git a/compiler/testData/psi/Imports_ERR.txt b/compiler/testData/psi/Imports_ERR.txt index 7e96a0f9b6a..0b8c1d1bc6a 100644 --- a/compiler/testData/psi/Imports_ERR.txt +++ b/compiler/testData/psi/Imports_ERR.txt @@ -1,7 +1,7 @@ JetFile: Imports_ERR.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -14,7 +14,7 @@ JetFile: Imports_ERR.jet IMPORT_DIRECTIVE PsiElement(import)('import') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiErrorElement:Expecting '.' <empty list> PsiWhiteSpace(' ') @@ -26,7 +26,7 @@ JetFile: Imports_ERR.jet IMPORT_DIRECTIVE PsiElement(import)('import') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiErrorElement:Expecting qualified name @@ -37,7 +37,7 @@ JetFile: Imports_ERR.jet IMPORT_DIRECTIVE PsiElement(import)('import') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiElement(DOT)('.') PsiWhiteSpace(' ') REFERENCE_EXPRESSION @@ -94,7 +94,7 @@ JetFile: Imports_ERR.jet PsiElement(DOT)('.') PsiWhiteSpace(' ') REFERENCE_EXPRESSION - PsiErrorElement:Type name expected + PsiErrorElement:Expecting type name PsiElement(as)('as') PsiWhiteSpace(' ') ANNOTATION_ENTRY @@ -124,7 +124,7 @@ JetFile: Imports_ERR.jet PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiErrorElement:Type name expected + PsiErrorElement:Expecting type name PsiElement(MUL)('*') PsiWhiteSpace(' ') PsiErrorElement:Expecting namespace or top level declaration @@ -158,7 +158,7 @@ JetFile: Imports_ERR.jet PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiErrorElement:Type name expected + PsiErrorElement:Expecting type name PsiElement(MUL)('*') PsiWhiteSpace(' ') PsiErrorElement:Expecting namespace or top level declaration diff --git a/compiler/testData/psi/LocalDeclarations.jet b/compiler/testData/psi/LocalDeclarations.jet index abe0308a864..4254634f0e5 100644 --- a/compiler/testData/psi/LocalDeclarations.jet +++ b/compiler/testData/psi/LocalDeclarations.jet @@ -6,6 +6,6 @@ fun foo() { out val foo = 5 [a] var foo = 4 - type f = fun T.() : () + type f = T.() -> #() } diff --git a/compiler/testData/psi/LocalDeclarations.txt b/compiler/testData/psi/LocalDeclarations.txt index d9a4c472683..4c9090fd03a 100644 --- a/compiler/testData/psi/LocalDeclarations.txt +++ b/compiler/testData/psi/LocalDeclarations.txt @@ -109,11 +109,9 @@ JetFile: LocalDeclarations.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION @@ -123,10 +121,11 @@ JetFile: LocalDeclarations.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n\n') diff --git a/compiler/testData/psi/NamespaceBlock.jet b/compiler/testData/psi/NamespaceBlock.jet index 10b13428cd4..cf3ba05fd99 100644 --- a/compiler/testData/psi/NamespaceBlock.jet +++ b/compiler/testData/psi/NamespaceBlock.jet @@ -1,16 +1,16 @@ -namespace foo.bar.goo +package foo.bar.goo import foo as bar -namespace foof { +package foof { import foo.bar.*; class Foo {} - namespace bar { + package bar { class Bar {} - namespace ns { + package ns { class X class Y @@ -21,9 +21,9 @@ namespace foof { class Bar<T> {} -namespace foo {} +package foo {} -namespace bar { +package bar { import sdf } \ No newline at end of file diff --git a/compiler/testData/psi/NamespaceBlock.txt b/compiler/testData/psi/NamespaceBlock.txt index 1d32e0b59c6..33b0d00d72a 100644 --- a/compiler/testData/psi/NamespaceBlock.txt +++ b/compiler/testData/psi/NamespaceBlock.txt @@ -1,7 +1,7 @@ JetFile: NamespaceBlock.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -23,7 +23,7 @@ JetFile: NamespaceBlock.jet PsiWhiteSpace('\n\n') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foof') PsiWhiteSpace(' ') @@ -56,7 +56,7 @@ JetFile: NamespaceBlock.jet PsiWhiteSpace('\n\n ') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') @@ -76,7 +76,7 @@ JetFile: NamespaceBlock.jet PsiWhiteSpace('\n\n ') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('ns') PsiWhiteSpace(' ') @@ -119,7 +119,7 @@ JetFile: NamespaceBlock.jet PsiWhiteSpace('\n\n') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiWhiteSpace(' ') @@ -130,7 +130,7 @@ JetFile: NamespaceBlock.jet PsiWhiteSpace('\n\n') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/NamespaceBlockFirst.jet b/compiler/testData/psi/NamespaceBlockFirst.jet index d3324536a1a..22ec2b0ed6b 100644 --- a/compiler/testData/psi/NamespaceBlockFirst.jet +++ b/compiler/testData/psi/NamespaceBlockFirst.jet @@ -1,4 +1,4 @@ -namespace foobar { +package foobar { val a = 1 val b = foobar.a } diff --git a/compiler/testData/psi/NamespaceBlockFirst.txt b/compiler/testData/psi/NamespaceBlockFirst.txt index daf5656d2ab..fcb33b0afae 100644 --- a/compiler/testData/psi/NamespaceBlockFirst.txt +++ b/compiler/testData/psi/NamespaceBlockFirst.txt @@ -4,7 +4,7 @@ JetFile: NamespaceBlockFirst.jet <empty list> NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foobar') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/NamespaceBlock_ERR.jet b/compiler/testData/psi/NamespaceBlock_ERR.jet index 66bf0b8d58f..a22d5edaa88 100644 --- a/compiler/testData/psi/NamespaceBlock_ERR.jet +++ b/compiler/testData/psi/NamespaceBlock_ERR.jet @@ -1,11 +1,11 @@ -namespace foo.bar.goo +package foo.bar.goo import foo as import foo. import foo.bar. import foo. as bar -namespace foof { +package foof { import foo.bar.* as bar import foo as ; import foo. ; @@ -14,13 +14,13 @@ namespace foof { import foo.bar.* as bar ; import foo.bar.* as ; - namespace foo + package foo class Foo {} - namespace { + package { class Bar {} - namespace ns { + package ns { class X class Y @@ -32,11 +32,11 @@ dsfgd class Bar<T> {} -namespace foo +package foo -namespace {} +package {} -namespace bar { +package bar { import sdf } \ No newline at end of file diff --git a/compiler/testData/psi/NamespaceBlock_ERR.txt b/compiler/testData/psi/NamespaceBlock_ERR.txt index 1675b5bb0bc..8d418eb0f6c 100644 --- a/compiler/testData/psi/NamespaceBlock_ERR.txt +++ b/compiler/testData/psi/NamespaceBlock_ERR.txt @@ -1,7 +1,7 @@ JetFile: NamespaceBlock_ERR.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -61,7 +61,7 @@ JetFile: NamespaceBlock_ERR.jet PsiElement(DOT)('.') PsiWhiteSpace(' ') REFERENCE_EXPRESSION - PsiErrorElement:Type name expected + PsiErrorElement:Expecting type name PsiElement(as)('as') PsiWhiteSpace(' ') ANNOTATION_ENTRY @@ -72,7 +72,7 @@ JetFile: NamespaceBlock_ERR.jet PsiElement(IDENTIFIER)('bar') PsiWhiteSpace('\n\n') NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foof') PsiWhiteSpace(' ') @@ -193,7 +193,7 @@ JetFile: NamespaceBlock_ERR.jet PsiWhiteSpace('\n\n ') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiErrorElement:A namespace block in '{...}' expected @@ -212,7 +212,7 @@ JetFile: NamespaceBlock_ERR.jet PsiWhiteSpace('\n ') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiErrorElement:Expecting namespace name <empty list> PsiWhiteSpace(' ') @@ -232,7 +232,7 @@ JetFile: NamespaceBlock_ERR.jet PsiWhiteSpace('\n\n ') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('ns') PsiWhiteSpace(' ') @@ -283,7 +283,7 @@ JetFile: NamespaceBlock_ERR.jet PsiWhiteSpace('\n\n') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('foo') PsiErrorElement:A namespace block in '{...}' expected @@ -291,7 +291,7 @@ JetFile: NamespaceBlock_ERR.jet PsiWhiteSpace('\n\n') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiErrorElement:Expecting namespace name <empty list> PsiWhiteSpace(' ') @@ -302,7 +302,7 @@ JetFile: NamespaceBlock_ERR.jet PsiWhiteSpace('\n\n') NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('bar') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/NamespaceModifiers.jet b/compiler/testData/psi/NamespaceModifiers.jet index c842220ebe8..de65a560b82 100644 --- a/compiler/testData/psi/NamespaceModifiers.jet +++ b/compiler/testData/psi/NamespaceModifiers.jet @@ -1,9 +1,9 @@ -public [a] namespace name; +public [a] package name; -[a] namespace a { +[a] package a { val foo - private namespace b { + private package b { } } \ No newline at end of file diff --git a/compiler/testData/psi/NamespaceModifiers.txt b/compiler/testData/psi/NamespaceModifiers.txt index 6dc1a3459f4..67db2bc7e0c 100644 --- a/compiler/testData/psi/NamespaceModifiers.txt +++ b/compiler/testData/psi/NamespaceModifiers.txt @@ -14,7 +14,7 @@ JetFile: NamespaceModifiers.jet PsiElement(IDENTIFIER)('a') PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('name') PsiElement(SEMICOLON)(';') @@ -32,7 +32,7 @@ JetFile: NamespaceModifiers.jet PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') @@ -49,7 +49,7 @@ JetFile: NamespaceModifiers.jet PsiElement(private)('private') PsiWhiteSpace(' ') NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('b') PsiWhiteSpace(' ') diff --git a/compiler/testData/psi/NewlinesInParentheses.jet b/compiler/testData/psi/NewlinesInParentheses.jet index 8feebf2ea52..277f48e644a 100644 --- a/compiler/testData/psi/NewlinesInParentheses.jet +++ b/compiler/testData/psi/NewlinesInParentheses.jet @@ -21,17 +21,17 @@ fun foo() { + d] when (e) { - is T @ - () => a + is T + #() -> a in f - () => a + () -> a !is T - @ () => a + #() -> a !in f - () => a + () -> a f - () => a + () -> a } val f = a is T - () + #() } \ No newline at end of file diff --git a/compiler/testData/psi/NewlinesInParentheses.txt b/compiler/testData/psi/NewlinesInParentheses.txt index 95f9c053518..10b4cde8cd4 100644 --- a/compiler/testData/psi/NewlinesInParentheses.txt +++ b/compiler/testData/psi/NewlinesInParentheses.txt @@ -244,14 +244,13 @@ JetFile: NewlinesInParentheses.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace('\n ') + PsiWhiteSpace(' \n ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -269,7 +268,7 @@ JetFile: NewlinesInParentheses.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -281,14 +280,13 @@ JetFile: NewlinesInParentheses.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('T') - PsiWhiteSpace('\n ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace('\n ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -306,7 +304,7 @@ JetFile: NewlinesInParentheses.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -322,7 +320,7 @@ JetFile: NewlinesInParentheses.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') @@ -343,14 +341,13 @@ JetFile: NewlinesInParentheses.jet OPERATION_REFERENCE PsiElement(is)('is') PsiWhiteSpace(' ') - TYPE_PATTERN - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('T') - PsiWhiteSpace('\n ') - TUPLE - PsiElement(LPAR)('(') - PsiElement(RPAR)(')') + DECOMPOSER_PATTERN + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('T') + PsiWhiteSpace('\n ') + DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') + PsiElement(LPAR)('(') + PsiElement(RPAR)(')') PsiWhiteSpace('\n') PsiElement(RBRACE)('}') \ No newline at end of file diff --git a/compiler/testData/psi/Precedence.jet b/compiler/testData/psi/Precedence.jet index 3970cea3476..70a5fcc23cf 100644 --- a/compiler/testData/psi/Precedence.jet +++ b/compiler/testData/psi/Precedence.jet @@ -37,19 +37,19 @@ fun foo() { t : Any? t as Any<T>? t as Any.Any<T>.Any<T> - t as fun () : T + t as () -> T t as? Any<T>? t as? Any.Any<T>.Any<T> - t as? fun () : T + t as? () -> T t : Any * 1 t : Any? * 1 t as Any<T>? * 1 t as Any.Any<T>.Any<T> * 1 - t as fun () : T * 1 + t as () -> T * 1 t as? Any<T>? * 1 t as? Any.Any<T>.Any<T> * 1 - t as? fun () : T * 1 + t as? () -> T * 1 ++t : Any + 1 a.b : Any + 1 diff --git a/compiler/testData/psi/Precedence.txt b/compiler/testData/psi/Precedence.txt index 5ba29479d36..0fee3e39d4e 100644 --- a/compiler/testData/psi/Precedence.txt +++ b/compiler/testData/psi/Precedence.txt @@ -671,15 +671,13 @@ JetFile: Precedence.jet OPERATION_REFERENCE PsiElement(EQ)('=') PsiWhiteSpace(' ') - BINARY_EXPRESSION - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('b') - PsiWhiteSpace(' ') - OPERATION_REFERENCE - PsiElement(ARROW)('->') - PsiWhiteSpace(' ') - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('c') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace(' ') + PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + PsiElement(IDENTIFIER)('c') PsiWhiteSpace('\n ') BINARY_EXPRESSION REFERENCE_EXPRESSION @@ -788,16 +786,14 @@ JetFile: Precedence.jet PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(as)('as') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -868,16 +864,14 @@ JetFile: Precedence.jet PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(AS_SAFE)('as?') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -1003,16 +997,14 @@ JetFile: Precedence.jet PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(as)('as') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -1104,16 +1096,14 @@ JetFile: Precedence.jet PsiWhiteSpace(' ') OPERATION_REFERENCE PsiElement(AS_SAFE)('as?') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE diff --git a/compiler/testData/psi/Properties_ERR.txt b/compiler/testData/psi/Properties_ERR.txt index 7105c2c18b5..8f0b36a5412 100644 --- a/compiler/testData/psi/Properties_ERR.txt +++ b/compiler/testData/psi/Properties_ERR.txt @@ -72,12 +72,15 @@ JetFile: Properties_ERR.jet PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('foo') + PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') + PsiElement(IDENTIFIER)('bar') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('bar') - PsiErrorElement:Property getter or setter expected - PsiElement(DOT)('.') + PsiErrorElement:Expecting property name + <empty list> PsiWhiteSpace('\n') PROPERTY PsiElement(val)('val') @@ -148,16 +151,19 @@ JetFile: Properties_ERR.jet PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('f') + PsiElement(DOT)('.') REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('f') + PsiElement(IDENTIFIER)('d') PsiElement(DOT)('.') - PsiElement(IDENTIFIER)('d') - PsiErrorElement:Property getter or setter expected - PsiElement(DOT)('.') + PsiErrorElement:Expecting property name PsiElement(MINUS)('-') - PsiWhiteSpace(' ') - PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') + PsiElement(EQ)('=') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('f') PsiWhiteSpace('\n\n') PROPERTY diff --git a/compiler/testData/psi/RootNamespace.jet b/compiler/testData/psi/RootNamespace.jet index cc0a53278e2..5dd54de2c52 100644 --- a/compiler/testData/psi/RootNamespace.jet +++ b/compiler/testData/psi/RootNamespace.jet @@ -1,13 +1,13 @@ -namespace foo.bar; +package foo.bar; class X -namespace foo.bar { +package foo.bar { fun foo() { - namespace.foo.bar.X - namespace.foo.bar.X() + package.foo.bar.X + package.foo.bar.X() when (e) { - is namespace.foo.bar.X @ (x) => {} + is package.foo.bar.X #(x) -> {} } } } \ No newline at end of file diff --git a/compiler/testData/psi/RootNamespace.txt b/compiler/testData/psi/RootNamespace.txt index 33f37629a7f..1fd3472ebed 100644 --- a/compiler/testData/psi/RootNamespace.txt +++ b/compiler/testData/psi/RootNamespace.txt @@ -1,7 +1,7 @@ JetFile: RootNamespace.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -18,7 +18,7 @@ JetFile: RootNamespace.jet <empty list> NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -43,7 +43,7 @@ JetFile: RootNamespace.jet DOT_QUALIFIED_EXPRESSION DOT_QUALIFIED_EXPRESSION ROOT_NAMESPACE - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -58,7 +58,7 @@ JetFile: RootNamespace.jet DOT_QUALIFIED_EXPRESSION DOT_QUALIFIED_EXPRESSION ROOT_NAMESPACE - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -92,7 +92,7 @@ JetFile: RootNamespace.jet DOT_QUALIFIED_EXPRESSION DOT_QUALIFIED_EXPRESSION ROOT_NAMESPACE - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -102,10 +102,9 @@ JetFile: RootNamespace.jet PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('X') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -115,7 +114,7 @@ JetFile: RootNamespace.jet PsiElement(IDENTIFIER)('x') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK PsiElement(LBRACE)('{') diff --git a/compiler/testData/psi/ShortAnnotations.jet b/compiler/testData/psi/ShortAnnotations.jet index b05a2c3863c..e6137d0a754 100644 --- a/compiler/testData/psi/ShortAnnotations.jet +++ b/compiler/testData/psi/ShortAnnotations.jet @@ -1,6 +1,6 @@ -foo bar(1) buzz<T>(1) zoo namespace aa +foo bar(1) buzz<T>(1) zoo package aa -foo bar(1) buzz<T>(1) zoo namespace a {} +foo bar(1) buzz<T>(1) zoo package a {} foo bar(1) buzz<T>(1) zoo class A foo bar(1) buzz<T>(1) zoo object B foo bar(1) buzz<T>(1) zoo fun a() {} @@ -24,6 +24,6 @@ class Foo { fun test() { when (foo bar(1) buzz<T>(1) zoo val a = 1) { - 1 => 1 + 1 -> 1 } } \ No newline at end of file diff --git a/compiler/testData/psi/ShortAnnotations.txt b/compiler/testData/psi/ShortAnnotations.txt index cc795b1920f..a559bce1ddd 100644 --- a/compiler/testData/psi/ShortAnnotations.txt +++ b/compiler/testData/psi/ShortAnnotations.txt @@ -50,7 +50,7 @@ JetFile: ShortAnnotations.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('aa') PsiWhiteSpace('\n\n') @@ -105,7 +105,7 @@ JetFile: ShortAnnotations.jet PsiElement(IDENTIFIER)('zoo') PsiWhiteSpace(' ') NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') @@ -1134,7 +1134,7 @@ JetFile: ShortAnnotations.jet INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') diff --git a/compiler/testData/psi/SimpleExpressions.jet b/compiler/testData/psi/SimpleExpressions.jet index a3969d2b230..4e931bb6945 100644 --- a/compiler/testData/psi/SimpleExpressions.jet +++ b/compiler/testData/psi/SimpleExpressions.jet @@ -1,6 +1,6 @@ fun a( - a : foo = (), + a : foo = #(), a : foo = 10, a : foo = 0x10, a : foo = '1', @@ -17,7 +17,7 @@ fun a( a : foo = this, a : foo = super<sdf>, a : foo = (10), - a : foo = (10, "A", 0xf), + a : foo = #(10, "A", 0xf), a : foo = Foo(bar), a : foo = Foo<A>(bar), a : foo = Foo(), diff --git a/compiler/testData/psi/SimpleExpressions.txt b/compiler/testData/psi/SimpleExpressions.txt index 45ce1f23b2f..195e3389052 100644 --- a/compiler/testData/psi/SimpleExpressions.txt +++ b/compiler/testData/psi/SimpleExpressions.txt @@ -22,6 +22,7 @@ JetFile: SimpleExpressions.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') TUPLE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiElement(COMMA)(',') @@ -325,6 +326,7 @@ JetFile: SimpleExpressions.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') TUPLE + PsiElement(HASH)('#') PsiElement(LPAR)('(') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('10') diff --git a/compiler/testData/psi/SimpleModifiers.jet b/compiler/testData/psi/SimpleModifiers.jet index 407ad761e34..ac9d1dbc7b9 100644 --- a/compiler/testData/psi/SimpleModifiers.jet +++ b/compiler/testData/psi/SimpleModifiers.jet @@ -1,4 +1,4 @@ -namespace foo.bar.goo +package foo.bar.goo abstract open diff --git a/compiler/testData/psi/SimpleModifiers.txt b/compiler/testData/psi/SimpleModifiers.txt index 4df3f2f9c98..a4c58c3241e 100644 --- a/compiler/testData/psi/SimpleModifiers.txt +++ b/compiler/testData/psi/SimpleModifiers.txt @@ -1,7 +1,7 @@ JetFile: SimpleModifiers.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') diff --git a/compiler/testData/psi/SoftKeywords.jet b/compiler/testData/psi/SoftKeywords.jet index 829934a583a..b2ebd5d865e 100644 --- a/compiler/testData/psi/SoftKeywords.jet +++ b/compiler/testData/psi/SoftKeywords.jet @@ -1,4 +1,4 @@ -namespace foo.bar.goo +package foo.bar.goo import foo diff --git a/compiler/testData/psi/SoftKeywords.txt b/compiler/testData/psi/SoftKeywords.txt index 01fccd725d8..dcfafc412d1 100644 --- a/compiler/testData/psi/SoftKeywords.txt +++ b/compiler/testData/psi/SoftKeywords.txt @@ -1,7 +1,7 @@ JetFile: SoftKeywords.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') diff --git a/compiler/testData/psi/StringTemplates.jet b/compiler/testData/psi/StringTemplates.jet index 8bdec253be9..70723ad6f38 100644 --- a/compiler/testData/psi/StringTemplates.jet +++ b/compiler/testData/psi/StringTemplates.jet @@ -3,8 +3,8 @@ fun demo() { val a = "" val asd = 1 val bar = 5 - fun map(f : fun () : Any?) : Int = 1 - fun buzz(f : fun () : Any?) : Int = 1 + fun map(f : () -> Any?) : Int = 1 + fun buzz(f : () -> Any?) : Int = 1 val sdf = 1 val foo = 3; "$this must be$as$t" diff --git a/compiler/testData/psi/StringTemplates.txt b/compiler/testData/psi/StringTemplates.txt index 07ea659f400..f7aac5bf538 100644 --- a/compiler/testData/psi/StringTemplates.txt +++ b/compiler/testData/psi/StringTemplates.txt @@ -64,16 +64,14 @@ JetFile: StringTemplates.jet PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE NULLABLE_TYPE @@ -105,16 +103,14 @@ JetFile: StringTemplates.jet PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE NULLABLE_TYPE diff --git a/compiler/testData/psi/TupleTypes.jet b/compiler/testData/psi/TupleTypes.jet index 98047a6d660..930344a9c8f 100644 --- a/compiler/testData/psi/TupleTypes.jet +++ b/compiler/testData/psi/TupleTypes.jet @@ -1,10 +1,10 @@ class F( - a : (), - x : (X), - b : (A, B), - c : (x : Int, y : Int), - a : [x] (), - x : [x]([x] X), - b : [x] ([x] A, [x]B), - c : [x] (x : [x] Int, y : [x] Int) + a : #(), + x : #(X), + b : #(A, B), + c : #(x : Int, y : Int), + a : [x] #(), + x : [x]#([x] X), + b : [x] #([x] A, [x]B), + c : [x] #(x : [x] Int, y : [x] Int) ) \ No newline at end of file diff --git a/compiler/testData/psi/TupleTypes.txt b/compiler/testData/psi/TupleTypes.txt index cb44ded1528..d13da2370ce 100644 --- a/compiler/testData/psi/TupleTypes.txt +++ b/compiler/testData/psi/TupleTypes.txt @@ -18,6 +18,7 @@ JetFile: TupleTypes.jet PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiElement(COMMA)(',') @@ -29,6 +30,7 @@ JetFile: TupleTypes.jet PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE USER_TYPE @@ -44,6 +46,7 @@ JetFile: TupleTypes.jet PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE USER_TYPE @@ -65,6 +68,7 @@ JetFile: TupleTypes.jet PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') LABELED_TUPLE_TYPE_ENTRY PsiElement(IDENTIFIER)('x') @@ -106,6 +110,7 @@ JetFile: TupleTypes.jet PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiElement(COMMA)(',') @@ -126,6 +131,7 @@ JetFile: TupleTypes.jet PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE ANNOTATION @@ -161,6 +167,7 @@ JetFile: TupleTypes.jet PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE ANNOTATION @@ -211,6 +218,7 @@ JetFile: TupleTypes.jet PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') LABELED_TUPLE_TYPE_ENTRY PsiElement(IDENTIFIER)('x') diff --git a/compiler/testData/psi/TupleTypes_ERR.jet b/compiler/testData/psi/TupleTypes_ERR.jet index 75924194f84..c4e70baf21f 100644 --- a/compiler/testData/psi/TupleTypes_ERR.jet +++ b/compiler/testData/psi/TupleTypes_ERR.jet @@ -1,10 +1,10 @@ class F( - a : (), - x : (X), - b : (A, ), - c : (x : , : Int), - a : [x] (), - x : [x]([x X), - b : [x] ([x] A, [x]B), - c : [x] (x : [x] Int, y : [x] Int) + a : #(), + x : #(X), + b : #(A, ), + c : #(x : , : Int), + a : [x] #(), + x : [x]#([x X), + b : [x] #([x] A, [x]B), + c : [x] #(x : [x] Int, y : [x] Int) ) \ No newline at end of file diff --git a/compiler/testData/psi/TupleTypes_ERR.txt b/compiler/testData/psi/TupleTypes_ERR.txt index 5b984020566..3109fe1efef 100644 --- a/compiler/testData/psi/TupleTypes_ERR.txt +++ b/compiler/testData/psi/TupleTypes_ERR.txt @@ -18,6 +18,7 @@ JetFile: TupleTypes_ERR.jet PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiElement(COMMA)(',') @@ -29,6 +30,7 @@ JetFile: TupleTypes_ERR.jet PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE USER_TYPE @@ -44,6 +46,7 @@ JetFile: TupleTypes_ERR.jet PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE USER_TYPE @@ -63,6 +66,7 @@ JetFile: TupleTypes_ERR.jet PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') LABELED_TUPLE_TYPE_ENTRY PsiElement(IDENTIFIER)('x') @@ -101,6 +105,7 @@ JetFile: TupleTypes_ERR.jet PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiElement(COMMA)(',') @@ -121,6 +126,7 @@ JetFile: TupleTypes_ERR.jet PsiElement(IDENTIFIER)('x') PsiElement(RBRACKET)(']') TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE ANNOTATION @@ -160,6 +166,7 @@ JetFile: TupleTypes_ERR.jet PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE ANNOTATION @@ -210,6 +217,7 @@ JetFile: TupleTypes_ERR.jet PsiElement(RBRACKET)(']') PsiWhiteSpace(' ') TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') LABELED_TUPLE_TYPE_ENTRY PsiElement(IDENTIFIER)('x') diff --git a/compiler/testData/psi/TuplesWithLabeledEntries.jet b/compiler/testData/psi/TuplesWithLabeledEntries.jet index 8e1ee98d58a..c03fa82a256 100644 --- a/compiler/testData/psi/TuplesWithLabeledEntries.jet +++ b/compiler/testData/psi/TuplesWithLabeledEntries.jet @@ -1,2 +1,2 @@ -val foo = (a = 3) -val foo = (a = 3, a) \ No newline at end of file +val foo = #(a = 3) +val foo = #(a = 3, a) \ No newline at end of file diff --git a/compiler/testData/psi/TuplesWithLabeledEntries.txt b/compiler/testData/psi/TuplesWithLabeledEntries.txt index bb38c8417a9..0b775f17659 100644 --- a/compiler/testData/psi/TuplesWithLabeledEntries.txt +++ b/compiler/testData/psi/TuplesWithLabeledEntries.txt @@ -10,6 +10,7 @@ JetFile: TuplesWithLabeledEntries.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') TUPLE + PsiElement(HASH)('#') PsiElement(LPAR)('(') LABELED_TUPLE_ENTRY PsiElement(IDENTIFIER)('a') @@ -28,6 +29,7 @@ JetFile: TuplesWithLabeledEntries.jet PsiElement(EQ)('=') PsiWhiteSpace(' ') TUPLE + PsiElement(HASH)('#') PsiElement(LPAR)('(') LABELED_TUPLE_ENTRY PsiElement(IDENTIFIER)('a') diff --git a/compiler/testData/psi/TypeDef.jet b/compiler/testData/psi/TypeDef.jet index 9aab7e0e4a7..12365eae7e7 100644 --- a/compiler/testData/psi/TypeDef.jet +++ b/compiler/testData/psi/TypeDef.jet @@ -1,4 +1,4 @@ -namespace foo.bar.goo +package foo.bar.goo type foo = bar type foo<T> = bar diff --git a/compiler/testData/psi/TypeDef.txt b/compiler/testData/psi/TypeDef.txt index f55ffb3a657..ac161f21cf6 100644 --- a/compiler/testData/psi/TypeDef.txt +++ b/compiler/testData/psi/TypeDef.txt @@ -1,7 +1,7 @@ JetFile: TypeDef.jet NAMESPACE NAMESPACE_HEADER - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') diff --git a/compiler/testData/psi/TypeExpressionAmbiguities_ERR.jet b/compiler/testData/psi/TypeExpressionAmbiguities_ERR.jet index fb993207d65..5050788b08c 100644 --- a/compiler/testData/psi/TypeExpressionAmbiguities_ERR.jet +++ b/compiler/testData/psi/TypeExpressionAmbiguities_ERR.jet @@ -1,7 +1,7 @@ fun foo() { foo<Int?>() fooo<Double?addddd>() - dd<(Int, Int, Int)>(if (true) (1, 1, 1) else (2, 2, 2)) + dd<#(Int, Int, Int)>(if (true) #(1, 1, 1) else #(2, 2, 2)) foo(bar<a, b, c>(d)) foo(bar<a, b+1, c>(d)) foo(bar<a, f(), c>(d)) diff --git a/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt b/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt index b6eea49385d..d54cf771e6a 100644 --- a/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt +++ b/compiler/testData/psi/TypeExpressionAmbiguities_ERR.txt @@ -57,6 +57,7 @@ JetFile: TypeExpressionAmbiguities_ERR.jet TYPE_PROJECTION TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE USER_TYPE @@ -90,6 +91,7 @@ JetFile: TypeExpressionAmbiguities_ERR.jet PsiWhiteSpace(' ') THEN TUPLE + PsiElement(HASH)('#') PsiElement(LPAR)('(') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') @@ -107,6 +109,7 @@ JetFile: TypeExpressionAmbiguities_ERR.jet PsiWhiteSpace(' ') ELSE TUPLE + PsiElement(HASH)('#') PsiElement(LPAR)('(') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('2') diff --git a/compiler/testData/psi/When.jet b/compiler/testData/psi/When.jet index 48f1055329c..2931b890ae5 100644 --- a/compiler/testData/psi/When.jet +++ b/compiler/testData/psi/When.jet @@ -1,7 +1,7 @@ fun foo() { return false - fun a() = {when(x) { is a => b }} + fun a() = {when(x) { is a -> b }} // foo fun b() {} @@ -13,20 +13,20 @@ fun foo() { } when (e) { - is a => foo + is a -> foo } when (e) { - is Tree @ (a, b) => foo - is null => foo - is 1 => foo - is A.b => foo - is 1.0 => foo - is 'c' => foo - is "sadfsa" => foo - is """ddd""" => foo - is * => foo - is val a is Foo => foo - is (val a is Foo, b) => foo + is Tree #(a, b) -> foo + is null -> foo + is 1 -> foo + is A.b -> foo + is 1.0 -> foo + is 'c' -> foo + is "sadfsa" -> foo + is """ddd""" -> foo + is * -> foo + is val a is Foo -> foo + is #(val a is Foo, b) -> foo } when (when(when (e) { @@ -39,45 +39,45 @@ fun foo() { fun foo() { when (val a = e) { - is Tree => c - is Tree @ (null, val r) => c - is a @ (a, b) => c - is a @ (a, b) => c - is a.a @ (a, b) => c - is a.a @ (foo = a, bar = b) => c - is namespace.a.a @ (a, b) => c - is a @ (val a is T, b) => c - is a @ (b, 1) => c - in 1..2 => dsf - !in 2 => sd - !is t => d - is fun (foo) : Bar => fgpp - is (1, val a is Foo, *, Foo, bar) => d - is (Foo, val a in 1..2, *, val _ !is Foo, val bar is foo.bar<a> @ (a)) => d - is (Int, Int) => 2 - is val a : Foo => 2 - else => foo + is Tree -> c + is Tree #(null, val r) -> c + is a #(a, b) -> c + is a #(a, b) -> c + is a.a #(a, b) -> c + is a.a #(foo = a, bar = b) -> c + is package.a.a #(a, b) -> c + is a #(val a is T, b) -> c + is a #(b, 1) -> c + in 1..2 -> dsf + !in 2 -> sd + !is t -> d + is (foo) -> Bar -> fgpp + is #(1, val a is Foo, *, Foo, bar) -> d + is #(Foo, val a in 1..2, *, val _ !is Foo, val bar is foo.bar<a> #(a)) -> d + is #(Int, Int) -> 2 + is val a : Foo -> 2 + else -> foo } } fun foo() { when (val a = e) { is Tree, - is Tree @ (null, val r), - is a @ (a, b) => c + is Tree #(null, val r), + is a #(a, b) -> c 1, foo(), bar, 2 + 3, - is a @ (a, b) => c - is a.a @ (val b, b) => c + is a #(a, b) -> c + is a.a #(val b, b) -> c } } fun whenWithoutCondition(i : Int) { val j = 12 when { - 3 => -1 - i == 3 => -1 - j < i, j == i => -1 - i is Int => 1 - else => 2 + 3 -> -1 + i == 3 -> -1 + j < i, j == i -> -1 + i is Int -> 1 + else -> 2 } } diff --git a/compiler/testData/psi/When.txt b/compiler/testData/psi/When.txt index c78e94c6686..a12c21b2780 100644 --- a/compiler/testData/psi/When.txt +++ b/compiler/testData/psi/When.txt @@ -52,7 +52,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') @@ -119,7 +119,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -143,10 +143,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Tree') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -164,7 +163,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -177,7 +176,7 @@ JetFile: When.jet NULL PsiElement(null)('null') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -190,7 +189,7 @@ JetFile: When.jet INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -209,7 +208,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('b') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -222,7 +221,7 @@ JetFile: When.jet FLOAT_CONSTANT PsiElement(FLOAT_CONSTANT)('1.0') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -235,7 +234,7 @@ JetFile: When.jet CHARACTER_CONSTANT PsiElement(CHARACTER_LITERAL)(''c'') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -251,7 +250,7 @@ JetFile: When.jet PsiElement(REGULAR_STRING_PART)('sadfsa') PsiElement(CLOSING_QUOTE)('"') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -264,7 +263,7 @@ JetFile: When.jet STRING_CONSTANT PsiElement(RAW_STRING_LITERAL)('"""ddd"""') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -276,7 +275,7 @@ JetFile: When.jet WILDCARD_PATTERN PsiElement(MUL)('*') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -300,7 +299,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Foo') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -310,6 +309,7 @@ JetFile: When.jet PsiElement(is)('is') PsiWhiteSpace(' ') TUPLE_PATTERN + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY BINDING_PATTERN @@ -336,7 +336,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -412,7 +412,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Tree') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -424,10 +424,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Tree') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY EXPRESSION_PATTERN @@ -443,7 +442,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('r') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -455,10 +454,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -476,7 +474,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -488,10 +486,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -509,7 +506,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -525,10 +522,9 @@ JetFile: When.jet PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -546,7 +542,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -562,10 +558,9 @@ JetFile: When.jet PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY PsiElement(IDENTIFIER)('foo') @@ -591,7 +586,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -604,17 +599,16 @@ JetFile: When.jet DOT_QUALIFIED_EXPRESSION DOT_QUALIFIED_EXPRESSION ROOT_NAMESPACE - PsiElement(namespace)('namespace') + PsiElement(namespace)('package') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -632,7 +626,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -644,10 +638,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY BINDING_PATTERN @@ -674,7 +667,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -686,10 +679,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -705,7 +697,7 @@ JetFile: When.jet PsiElement(INTEGER_LITERAL)('1') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -723,7 +715,7 @@ JetFile: When.jet INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('2') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('dsf') @@ -736,7 +728,7 @@ JetFile: When.jet INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('2') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('sd') @@ -751,7 +743,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('t') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') @@ -759,29 +751,23 @@ JetFile: When.jet WHEN_ENTRY WHEN_CONDITION_IS_PATTERN PsiElement(is)('is') - PsiWhiteSpace(' ') - TYPE_PATTERN - TYPE_REFERENCE - FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') - VALUE_PARAMETER_LIST - PsiElement(LPAR)('(') - VALUE_PARAMETER - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('foo') - PsiElement(RPAR)(')') - PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') - TYPE_REFERENCE - USER_TYPE - REFERENCE_EXPRESSION - PsiElement(IDENTIFIER)('Bar') + PsiWhiteSpace(' ') + PsiErrorElement:Pattern expected + PsiElement(LPAR)('(') + PsiElement(IDENTIFIER)('foo') + PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('Bar') + PsiWhiteSpace(' ') + WHEN_ENTRY + WHEN_CONDITION_IS_PATTERN + EXPRESSION_PATTERN + PsiErrorElement:Expecting an expression, is-condition or in-condition + <empty list> + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('fgpp') @@ -791,6 +777,7 @@ JetFile: When.jet PsiElement(is)('is') PsiWhiteSpace(' ') TUPLE_PATTERN + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY EXPRESSION_PATTERN @@ -836,7 +823,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('bar') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') @@ -846,6 +833,7 @@ JetFile: When.jet PsiElement(is)('is') PsiWhiteSpace(' ') TUPLE_PATTERN + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -923,10 +911,9 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') PsiElement(GT)('>') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -937,7 +924,7 @@ JetFile: When.jet PsiElement(RPAR)(')') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('d') @@ -947,6 +934,7 @@ JetFile: When.jet PsiElement(is)('is') PsiWhiteSpace(' ') TUPLE_PATTERN + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -964,7 +952,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('Int') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('2') @@ -986,7 +974,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Foo') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('2') @@ -994,7 +982,7 @@ JetFile: When.jet WHEN_ENTRY PsiElement(else)('else') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -1048,10 +1036,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Tree') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY EXPRESSION_PATTERN @@ -1074,10 +1061,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -1095,7 +1081,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -1142,10 +1128,9 @@ JetFile: When.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -1163,7 +1148,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -1179,10 +1164,9 @@ JetFile: When.jet PsiElement(DOT)('.') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('a') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY BINDING_PATTERN @@ -1200,7 +1184,7 @@ JetFile: When.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('c') @@ -1250,7 +1234,7 @@ JetFile: When.jet INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('3') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') PREFIX_EXPRESSION OPERATION_REFERENCE @@ -1271,7 +1255,7 @@ JetFile: When.jet INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('3') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') PREFIX_EXPRESSION OPERATION_REFERENCE @@ -1305,7 +1289,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('i') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') PREFIX_EXPRESSION OPERATION_REFERENCE @@ -1329,7 +1313,7 @@ JetFile: When.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Int') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('1') @@ -1337,7 +1321,7 @@ JetFile: When.jet WHEN_ENTRY PsiElement(else)('else') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') INTEGER_CONSTANT PsiElement(INTEGER_LITERAL)('2') diff --git a/compiler/testData/psi/When_ERR.jet b/compiler/testData/psi/When_ERR.jet index f41b6e1b613..e6c6159056f 100644 --- a/compiler/testData/psi/When_ERR.jet +++ b/compiler/testData/psi/When_ERR.jet @@ -2,25 +2,25 @@ fun foo() { when (e) { } when (e) { - is => foo - !is => foo - in => foo - !in => foo - => foo + is -> foo + !is -> foo + in -> foo + !in -> foo + -> foo else } when (e) { - is => - !is => - in => - !in => - !in => ; - => + is -> + !is -> + in -> + !in -> + !in -> ; + -> else - else => + else -> } when (e) { - is - => foo - is (, , 1, , ) => foo + is - -> foo + is #(, , 1, , ) -> foo } } \ No newline at end of file diff --git a/compiler/testData/psi/When_ERR.txt b/compiler/testData/psi/When_ERR.txt index 08dede49af4..425e8fb6d67 100644 --- a/compiler/testData/psi/When_ERR.txt +++ b/compiler/testData/psi/When_ERR.txt @@ -41,7 +41,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting a type or a decomposer pattern <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -52,7 +52,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting a type or a decomposer pattern <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -64,7 +64,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -76,7 +76,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -86,7 +86,7 @@ JetFile: When_ERR.jet EXPRESSION_PATTERN PsiErrorElement:Expecting an expression, is-condition or in-condition <empty list> - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -114,7 +114,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting a type or a decomposer pattern <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace('\n ') @@ -124,7 +124,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting a type or a decomposer pattern <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace('\n ') @@ -135,7 +135,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace('\n ') @@ -146,7 +146,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace('\n ') @@ -157,7 +157,7 @@ JetFile: When_ERR.jet PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiErrorElement:Expecting an expression <empty list> PsiWhiteSpace(' ') @@ -168,7 +168,7 @@ JetFile: When_ERR.jet EXPRESSION_PATTERN PsiErrorElement:Expecting an expression, is-condition or in-condition <empty list> - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace('\n ') @@ -180,7 +180,7 @@ JetFile: When_ERR.jet WHEN_ENTRY PsiElement(else)('else') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiErrorElement:Expecting an element <empty list> PsiWhiteSpace('\n ') @@ -203,7 +203,7 @@ JetFile: When_ERR.jet PsiErrorElement:Pattern expected PsiElement(MINUS)('-') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') @@ -213,6 +213,7 @@ JetFile: When_ERR.jet PsiElement(is)('is') PsiWhiteSpace(' ') TUPLE_PATTERN + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiErrorElement:Expecting a pattern PsiElement(COMMA)(',') @@ -233,7 +234,7 @@ JetFile: When_ERR.jet PsiWhiteSpace(' ') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('foo') diff --git a/compiler/testData/psi/examples/BinaryTree.jet b/compiler/testData/psi/examples/BinaryTree.jet index 25a5bb1d230..7dc1edcde6e 100644 --- a/compiler/testData/psi/examples/BinaryTree.jet +++ b/compiler/testData/psi/examples/BinaryTree.jet @@ -28,9 +28,9 @@ class BinaryTree<T> : IMutableSet<T> { fun contains(node : TreeNode, item : T) : Boolean { if (node == null) return false when(compare(item, node.value)) { - EQ => true - LS => contains(node.left, item) - GT => contains(node.right, item) + EQ -> true + LS -> contains(node.left, item) + GT -> contains(node.right, item) } } } @@ -51,9 +51,9 @@ class BinaryTree<T> : IMutableSet<T> { return true } when (compare(item, node.value)) { - EQ => false - LS => add(ref node.left, node) - GT => add(ref node.right, node) + EQ -> false + LS -> add(ref node.left, node) + GT -> add(ref node.right, node) } } @@ -64,13 +64,13 @@ class BinaryTree<T> : IMutableSet<T> { return true } when (compare(item, node.value)) { - EQ => return false - LS => + EQ -> return false + LS -> if (node.left == null) { node.left = TreeNode(item, node) return true } else return add(node.left) - GT => + GT -> if (node.right == null) { node.right = TreeNode(item, node) return true @@ -90,19 +90,19 @@ class BinaryTree<T> : IMutableSet<T> { fun find(node : TreeNode) : TreeNode { if (node == null) return null when (compare(item, node.value)) { - EQ => node - LS => find(node.left) - GT => find(node.right) + EQ -> node + LS -> find(node.left) + GT -> find(node.right) } } } private fun remove(node : TreeNode) { when (node) { - is TreeNode @ (null, null) => replace(node, null) - is TreeNode @ (null, right) => replace(node, right) - is TreeNode @ (left, null) => replace(node, left) - is TreeNode @ (left, right) => { + is TreeNode #(null, null) -> replace(node, null) + is TreeNode #(null, right) -> replace(node, right) + is TreeNode #(left, null) -> replace(node, left) + is TreeNode #(left, right) -> { val min = min(node.right) node.value = min.value remove(min) diff --git a/compiler/testData/psi/examples/BinaryTree.txt b/compiler/testData/psi/examples/BinaryTree.txt index af51d25fcf8..358f3eff236 100644 --- a/compiler/testData/psi/examples/BinaryTree.txt +++ b/compiler/testData/psi/examples/BinaryTree.txt @@ -439,7 +439,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('EQ') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BOOLEAN_CONSTANT PsiElement(true)('true') @@ -450,7 +450,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('LS') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -477,7 +477,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('GT') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -714,7 +714,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('EQ') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BOOLEAN_CONSTANT PsiElement(false)('false') @@ -725,7 +725,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('LS') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -754,7 +754,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('GT') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -892,7 +892,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('EQ') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') RETURN PsiElement(return)('return') @@ -906,7 +906,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('LS') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace('\n ') IF PsiElement(if)('if') @@ -992,7 +992,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('GT') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace('\n ') IF PsiElement(if)('if') @@ -1263,7 +1263,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('EQ') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('node') @@ -1274,7 +1274,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('LS') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -1296,7 +1296,7 @@ JetFile: BinaryTree.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('GT') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -1358,10 +1358,9 @@ JetFile: BinaryTree.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('TreeNode') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY EXPRESSION_PATTERN @@ -1375,7 +1374,7 @@ JetFile: BinaryTree.jet PsiElement(null)('null') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -1399,10 +1398,9 @@ JetFile: BinaryTree.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('TreeNode') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY EXPRESSION_PATTERN @@ -1418,7 +1416,7 @@ JetFile: BinaryTree.jet PsiElement(IDENTIFIER)('right') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -1442,10 +1440,9 @@ JetFile: BinaryTree.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('TreeNode') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -1461,7 +1458,7 @@ JetFile: BinaryTree.jet PsiElement(null)('null') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') CALL_EXPRESSION REFERENCE_EXPRESSION @@ -1485,10 +1482,9 @@ JetFile: BinaryTree.jet DECOMPOSER_PATTERN REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('TreeNode') - PsiWhiteSpace(' ') - PsiElement(AT)('@') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') DECOMPOSER_ARGUMENT_LIST + PsiElement(HASH)('#') PsiElement(LPAR)('(') TUPLE_PATTERN_ENTRY TYPE_PATTERN @@ -1506,7 +1502,7 @@ JetFile: BinaryTree.jet PsiElement(IDENTIFIER)('right') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK PsiElement(LBRACE)('{') diff --git a/compiler/testData/psi/examples/Builder.jet b/compiler/testData/psi/examples/Builder.jet index caf51c29d2c..6f7b80c32b8 100644 --- a/compiler/testData/psi/examples/Builder.jet +++ b/compiler/testData/psi/examples/Builder.jet @@ -31,7 +31,7 @@ class AntBuilder { fun classpath(entries : ClassPathEntry/*...*/) { /*...*/ } } - fun library(initializer : fun Library.() : Library) { + fun library(initializer : Library.() -> Library) { val lib = Library() lib.initializer() return lib diff --git a/compiler/testData/psi/examples/Builder.txt b/compiler/testData/psi/examples/Builder.txt index 2be62e21682..249ae918b3f 100644 --- a/compiler/testData/psi/examples/Builder.txt +++ b/compiler/testData/psi/examples/Builder.txt @@ -398,11 +398,9 @@ JetFile: Builder.jet PsiElement(IDENTIFIER)('initializer') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION @@ -412,7 +410,7 @@ JetFile: Builder.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE diff --git a/compiler/testData/psi/examples/FunctionsAndTypes.jet b/compiler/testData/psi/examples/FunctionsAndTypes.jet index 6644dd6b03c..c8d79fed6e8 100644 --- a/compiler/testData/psi/examples/FunctionsAndTypes.jet +++ b/compiler/testData/psi/examples/FunctionsAndTypes.jet @@ -1,34 +1,34 @@ -type f1 = fun (T) : X +type f1 = (T) -> X // type f1 = {(T) => X} -type f2 = fun (T, E) : X +type f2 = (T, E) -> X // type f2 = {(T, E) => X} -type f_tuple = fun ((T, E)) : X +type f_tuple = (#(T, E)) -> X //type f_tuple = {((T, E)) => X} -type hof = fun (X) : fun (T) : Y +type hof = (X) -> (T) -> Y //type hof = { (X) => {(T) => Y} } -type hof2 = fun (fun (X) : Y) : fun (Y) : Z +type hof2 = ( (X) -> Y) -> (Y) -> Z //type hof2 = { {(X) => Y} => {(Y) => Z} } -type Comparison<in T> = fun (a : T, b : T) : Int +type Comparison<in T> = (a : T, b : T) -> Int //type Comparison<in T> = {(a : T, b : T) => Int} -type Equality<in T> = fun (a : T, b : T) : Boolean +type Equality<in T> = (a : T, b : T) -> Boolean //type Equality<in T> = {(a : T, b : T) => Boolean} -type HashFunction<in T> = fun (obj : T) : Int +type HashFunction<in T> = (obj : T) -> Int //type HashFunction<in T> = {(obj : T) => Int} -type Runnable = fun () : () +type Runnable = () -> #() //type Runnable = {() => ()} -type Function1<in T, out R> = fun (input : T) : R +type Function1<in T, out R> = (input : T) -> R //type Function1<in T, out R> = {(input : T) => R} -val f1 = {(t : T) : X => something(t)} +val f1 = {(t : T) : X -> something(t)} fun f1(t : T) : X = something(t) -val f1 = {(t : T) => something(t)} -val f1 = {(T) : X => something(it)} -val f1 = {t => something(t)} +val f1 = {(t : T) -> something(t)} +val f1 = {(T) : X -> something(it)} +val f1 = {t -> something(t)} val f1 = {something(it)} -val f1 : fun (T) : X = {X()} +val f1 : (T) -> X = {X()} diff --git a/compiler/testData/psi/examples/FunctionsAndTypes.txt b/compiler/testData/psi/examples/FunctionsAndTypes.txt index ca829289aac..704881a598e 100644 --- a/compiler/testData/psi/examples/FunctionsAndTypes.txt +++ b/compiler/testData/psi/examples/FunctionsAndTypes.txt @@ -10,11 +10,9 @@ JetFile: FunctionsAndTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -24,7 +22,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -41,11 +39,9 @@ JetFile: FunctionsAndTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -62,7 +58,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('E') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -79,16 +75,15 @@ JetFile: FunctionsAndTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') TYPE_REFERENCE USER_TYPE @@ -103,7 +98,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(RPAR)(')') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -120,11 +115,9 @@ JetFile: FunctionsAndTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -134,12 +127,10 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('X') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -149,7 +140,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -166,18 +157,15 @@ JetFile: FunctionsAndTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') + PsiWhiteSpace(' ') VALUE_PARAMETER TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -187,7 +175,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('X') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -195,12 +183,10 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('Y') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiElement(ARROW)('->') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -210,7 +196,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('Y') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -233,11 +219,9 @@ JetFile: FunctionsAndTypes.jet PsiElement(GT)('>') PsiWhiteSpace(' ') PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -262,7 +246,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -285,11 +269,9 @@ JetFile: FunctionsAndTypes.jet PsiElement(GT)('>') PsiWhiteSpace(' ') PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -314,7 +296,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -337,11 +319,9 @@ JetFile: FunctionsAndTypes.jet PsiElement(GT)('>') PsiWhiteSpace(' ') PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -355,7 +335,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -372,19 +352,18 @@ JetFile: FunctionsAndTypes.jet TYPE_PARAMETER_LIST <empty list> PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE TUPLE_TYPE + PsiElement(HASH)('#') PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace('\n') @@ -411,11 +390,9 @@ JetFile: FunctionsAndTypes.jet PsiElement(GT)('>') PsiWhiteSpace(' ') PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -429,7 +406,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -468,7 +445,7 @@ JetFile: FunctionsAndTypes.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('X') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK CALL_EXPRESSION @@ -541,7 +518,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK CALL_EXPRESSION @@ -578,7 +555,7 @@ JetFile: FunctionsAndTypes.jet REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('X') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK CALL_EXPRESSION @@ -606,7 +583,7 @@ JetFile: FunctionsAndTypes.jet VALUE_PARAMETER PsiElement(IDENTIFIER)('t') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK CALL_EXPRESSION @@ -648,11 +625,9 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('f1') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -662,7 +637,7 @@ JetFile: FunctionsAndTypes.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE diff --git a/compiler/testData/psi/examples/Graph.jet b/compiler/testData/psi/examples/Graph.jet index 7e373b1e9d6..6999b00c715 100644 --- a/compiler/testData/psi/examples/Graph.jet +++ b/compiler/testData/psi/examples/Graph.jet @@ -24,11 +24,11 @@ class Graph<V, E> { fun neighbours(v : Vertex<V>) = edges.filter{it.from == v}.map{it.to} // type is IIterable<Vertex<V>> - fun dfs(handler : fun (V) : Unit) { + fun dfs(handler : (V) -> Unit) { val visited = HashSet<Vertex<V>>() vertices.foreach{dfs(it, visited, handler)} - fun dfs(current : Vertex<V>, visited : ISet<Vertex<V>>, handler : fun (V) : Unit) { + fun dfs(current : Vertex<V>, visited : ISet<Vertex<V>>, handler : (V) -> Unit) { if (!visited.add(current)) return handler(current) @@ -36,7 +36,7 @@ class Graph<V, E> { } } - public fun traverse(pending : IPushPop<Vertex<V>>, visited : ISet<Vertex<V>>, handler : fun (V) : Unit) { + public fun traverse(pending : IPushPop<Vertex<V>>, visited : ISet<Vertex<V>>, handler : (V) -> Unit) { vertices.foreach { if (!visited.add(it)) continue @@ -44,7 +44,7 @@ class Graph<V, E> { while (!pending.isEmpty) { val current = pending.pop() handler(current); - neighbours(current).foreach { n => + neighbours(current).foreach { n -> if (visited.add(n)) { pending.push(n) } diff --git a/compiler/testData/psi/examples/Graph.txt b/compiler/testData/psi/examples/Graph.txt index 2cb4dd908c6..ecd6a20a6c0 100644 --- a/compiler/testData/psi/examples/Graph.txt +++ b/compiler/testData/psi/examples/Graph.txt @@ -469,11 +469,9 @@ JetFile: Graph.jet PsiElement(IDENTIFIER)('handler') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -483,7 +481,7 @@ JetFile: Graph.jet PsiElement(IDENTIFIER)('V') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -612,11 +610,9 @@ JetFile: Graph.jet PsiElement(IDENTIFIER)('handler') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -626,7 +622,7 @@ JetFile: Graph.jet PsiElement(IDENTIFIER)('V') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -784,11 +780,9 @@ JetFile: Graph.jet PsiElement(IDENTIFIER)('handler') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -798,7 +792,7 @@ JetFile: Graph.jet PsiElement(IDENTIFIER)('V') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -935,7 +929,7 @@ JetFile: Graph.jet VALUE_PARAMETER PsiElement(IDENTIFIER)('n') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace('\n ') BLOCK IF diff --git a/compiler/testData/psi/examples/LINQ.jet b/compiler/testData/psi/examples/LINQ.jet index e492a0c22d3..efffad662fd 100644 --- a/compiler/testData/psi/examples/LINQ.jet +++ b/compiler/testData/psi/examples/LINQ.jet @@ -1,3 +1,3 @@ fun foo() { - l filter {it.x} map {it.foo} aggregate {(a, b) => a + b} + l filter {it.x} map {it.foo} aggregate {(a, b) -> a + b} } \ No newline at end of file diff --git a/compiler/testData/psi/examples/LINQ.txt b/compiler/testData/psi/examples/LINQ.txt index 98e0b166b64..c8c78d1a8e9 100644 --- a/compiler/testData/psi/examples/LINQ.txt +++ b/compiler/testData/psi/examples/LINQ.txt @@ -65,7 +65,7 @@ JetFile: LINQ.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') BLOCK BINARY_EXPRESSION diff --git a/compiler/testData/psi/examples/PolymorphicClassObjects.jet b/compiler/testData/psi/examples/PolymorphicClassObjects.jet index fefa5d52ea4..12027ad1994 100644 --- a/compiler/testData/psi/examples/PolymorphicClassObjects.jet +++ b/compiler/testData/psi/examples/PolymorphicClassObjects.jet @@ -16,7 +16,7 @@ class List<T> { } -fun <E, T, R> Map<E, T>.map(f : fun (E) : R) : T<R> where +fun <E, T, R> Map<E, T>.map(f : (E) -> R) : T<R> where T : Iterable<E>, class object T : Buildable<E, T> = { val builder = T.newBuilder() diff --git a/compiler/testData/psi/examples/PolymorphicClassObjects.txt b/compiler/testData/psi/examples/PolymorphicClassObjects.txt index 9a59c5766da..0ba36037cd1 100644 --- a/compiler/testData/psi/examples/PolymorphicClassObjects.txt +++ b/compiler/testData/psi/examples/PolymorphicClassObjects.txt @@ -242,11 +242,9 @@ JetFile: PolymorphicClassObjects.jet PsiElement(IDENTIFIER)('f') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -256,7 +254,7 @@ JetFile: PolymorphicClassObjects.jet PsiElement(IDENTIFIER)('E') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE diff --git a/compiler/testData/psi/examples/With.jet b/compiler/testData/psi/examples/With.jet index 7303da79f0a..c6bf6fa33e2 100644 --- a/compiler/testData/psi/examples/With.jet +++ b/compiler/testData/psi/examples/With.jet @@ -1,4 +1,4 @@ -[inline] fun with<T>(receiver : T, body : fun T.() : Unit) = receiver.body() +[inline] fun with<T>(receiver : T, body : T.() -> Unit) = receiver.body() fun example() { diff --git a/compiler/testData/psi/examples/With.txt b/compiler/testData/psi/examples/With.txt index 468588f148e..fbe340bf2b1 100644 --- a/compiler/testData/psi/examples/With.txt +++ b/compiler/testData/psi/examples/With.txt @@ -39,11 +39,9 @@ JetFile: With.jet PsiElement(IDENTIFIER)('body') PsiWhiteSpace(' ') PsiElement(COLON)(':') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE REFERENCE_EXPRESSION @@ -53,7 +51,7 @@ JetFile: With.jet PsiElement(LPAR)('(') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE diff --git a/compiler/testData/psi/examples/util/Comparison.jet b/compiler/testData/psi/examples/util/Comparison.jet index 00e8bc10327..ad53be8f67c 100644 --- a/compiler/testData/psi/examples/util/Comparison.jet +++ b/compiler/testData/psi/examples/util/Comparison.jet @@ -1,4 +1,4 @@ -type Comparison<in T> = fun (T, T) : Int +type Comparison<in T> = (T, T) -> Int fun naturalOrder<in T : Comparable<T>>(a : T, b : T) : Int = a.compareTo(b) @@ -8,9 +8,9 @@ enum class ComparisonResult { LS; EQ; GR } -type MatchableComparison<in T> = fun (T, T) : ComparisonResult +type MatchableComparison<in T> = (T, T) -> ComparisonResult -fun asMatchableComparison<T>(cmp : Comparison<T>) : MatchableComparison<T> = {(a, b) => +fun asMatchableComparison<T>(cmp : Comparison<T>) : MatchableComparison<T> = {(a, b) -> val res = cmp(a, b) if (res == 0) return ComparisonResult.EQ if (res < 0) return ComparisonResult.LS diff --git a/compiler/testData/psi/examples/util/Comparison.txt b/compiler/testData/psi/examples/util/Comparison.txt index 53e19e4cb0c..346fde02b9c 100644 --- a/compiler/testData/psi/examples/util/Comparison.txt +++ b/compiler/testData/psi/examples/util/Comparison.txt @@ -16,11 +16,9 @@ JetFile: Comparison.jet PsiElement(GT)('>') PsiWhiteSpace(' ') PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -37,7 +35,7 @@ JetFile: Comparison.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -255,11 +253,9 @@ JetFile: Comparison.jet PsiElement(GT)('>') PsiWhiteSpace(' ') PsiElement(EQ)('=') - PsiWhiteSpace(' ') + PsiWhiteSpace(' ') TYPE_REFERENCE FUNCTION_TYPE - PsiElement(fun)('fun') - PsiWhiteSpace(' ') VALUE_PARAMETER_LIST PsiElement(LPAR)('(') VALUE_PARAMETER @@ -276,7 +272,7 @@ JetFile: Comparison.jet PsiElement(IDENTIFIER)('T') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(COLON)(':') + PsiElement(ARROW)('->') PsiWhiteSpace(' ') TYPE_REFERENCE USER_TYPE @@ -343,7 +339,7 @@ JetFile: Comparison.jet PsiElement(IDENTIFIER)('b') PsiElement(RPAR)(')') PsiWhiteSpace(' ') - PsiElement(DOUBLE_ARROW)('=>') + PsiElement(ARROW)('->') PsiWhiteSpace('\n ') BLOCK PROPERTY diff --git a/compiler/testData/psi/greatSyntacticShift/functionLiterals.jet b/compiler/testData/psi/greatSyntacticShift/functionLiterals.jet new file mode 100644 index 00000000000..345d07943ad --- /dev/null +++ b/compiler/testData/psi/greatSyntacticShift/functionLiterals.jet @@ -0,0 +1,43 @@ +class Foo +class Bar + +fun a(vararg a : Any) = a + +fun test() { +a(1 +, {} +, { -> 1} +, {1} +, {x} +, {-> 1} +, {x -> 1} +, {x, y -> 1} +, {(x, y) -> 1} +, {(x, y) : Int -> 1} +, {(x) -> 1} +, {(x) : Int -> 1} +, {(x)} +, {(x).(y)} +, {x.(y)} +, {Int.(x) -> 1} +, {A.B.(x) -> 1} +, {A.B.(x, y) -> 1} +, {Int.(x) : Int -> 1} +, {Int.(x, y) -> 1} +, {Int.(x, y) : Int -> 1} +, {(Int).(x, y) -> 1} +, {(Int).(x, y) : Int -> 1} +, {(Int).(x, y) : (Int) -> Int -> {1}} +, {Int? .(x, y) -> 1} +, {This.(x, y) -> 1} +, {#(A, B).(x, y) -> 1} +, {#(a, b).(y)} +, {#(a, b)} +, {Foo<Bar>.x} +, {Foo<Bar>.(x)} +, {Foo<Bar>.(x) -> x} +, {Foo.Bar.Baz.(x) -> x} +, {Foo<Bar>.(x) : Int -> x} +, {Foo.Bar.Baz.(x) : Int -> x} +) +} diff --git a/compiler/testData/psi/greatSyntacticShift/functionTypes.jet b/compiler/testData/psi/greatSyntacticShift/functionTypes.jet new file mode 100644 index 00000000000..a48befe3580 --- /dev/null +++ b/compiler/testData/psi/greatSyntacticShift/functionTypes.jet @@ -0,0 +1,51 @@ +class A { +} + +package n { + class B +} +abstract class XXX() { + abstract val a : Int + abstract val a1 : namespace.Int + abstract val a2 : n.B + abstract val a3 : (A) + abstract val a31 : (n.B) + abstract val a4 : A? + abstract val a5 : (A)? + abstract val a6 : (A?) + abstract val a7 : (A) -> n.B + abstract val a8 : (A, n.B) -> n.B + +//val a9 : (A, B) +//val a10 : (B)? -> B + + val a11 : ((Int) -> Int)? = null + val a12 : ((Int) -> (Int))? = null + abstract val a13 : Int.(Int) -> Int + abstract val a14 : n.B.(Int) -> Int + abstract val a15 : Int? .(Int) -> Int + abstract val a152 : (Int?).(Int) -> Int + abstract val a151 : Int?.(Int) -> Int + abstract val a16 : (Int) -> (Int) -> Int + abstract val a17 : ((Int) -> Int).(Int) -> Int + abstract val a18 : (Int) -> ((Int) -> Int) + abstract val a19 : ((Int) -> Int) -> Int +} + +abstract class YYY() { + abstract val a7 : (a : A) -> n.B + abstract val a8 : (a : A, b : n.B) -> n.B +//val a9 : (A, B) +//val a10 : (B)? -> B + val a11 : ((a : Int) -> Int)? = null + val a12 : ((a : Int) -> (Int))? = null + abstract val a13 : Int.(a : Int) -> Int + abstract val a14 : n.B.(a : Int) -> Int + abstract val a15 : Int? .(a : Int) -> Int + abstract val a152 : (Int?).(a : Int) -> Int +abstract val a151 : Int?.(a : Int) -> Int + abstract val a16 : (a : Int) -> (a : Int) -> Int + abstract val a17 : ((a : Int) -> Int).(a : Int) -> Int + abstract val a18 : (a : Int) -> ((a : Int) -> Int) + abstract val a19 : (b : (a : Int) -> Int) -> Int +} diff --git a/compiler/testData/readClass/class/Class.kt b/compiler/testData/readClass/class/Class.kt index 957e3e9c54d..a57599e0804 100644 --- a/compiler/testData/readClass/class/Class.kt +++ b/compiler/testData/readClass/class/Class.kt @@ -1,3 +1,3 @@ -namespace test +package test class Ramification diff --git a/compiler/testData/readClass/class/ClassInParam.kt b/compiler/testData/readClass/class/ClassInParam.kt index a1a3ec98d39..330e981b2c2 100644 --- a/compiler/testData/readClass/class/ClassInParam.kt +++ b/compiler/testData/readClass/class/ClassInParam.kt @@ -1,3 +1,3 @@ -namespace test +package test class Wine<in T> diff --git a/compiler/testData/readClass/class/ClassOutParam.kt b/compiler/testData/readClass/class/ClassOutParam.kt index 83195ecae37..f4883e824c2 100644 --- a/compiler/testData/readClass/class/ClassOutParam.kt +++ b/compiler/testData/readClass/class/ClassOutParam.kt @@ -1,3 +1,3 @@ -namespace test +package test class Juice<in T> diff --git a/compiler/testData/readClass/class/ClassParam.kt b/compiler/testData/readClass/class/ClassParam.kt index 7457e5a7ffe..62d58e1eec3 100644 --- a/compiler/testData/readClass/class/ClassParam.kt +++ b/compiler/testData/readClass/class/ClassParam.kt @@ -1,3 +1,3 @@ -namespace test +package test class Beer<T> diff --git a/compiler/testData/readClass/class/ClassParamUpperClassBound.kt b/compiler/testData/readClass/class/ClassParamUpperClassBound.kt index 4867fac53bc..cc5fcf72002 100644 --- a/compiler/testData/readClass/class/ClassParamUpperClassBound.kt +++ b/compiler/testData/readClass/class/ClassParamUpperClassBound.kt @@ -1,3 +1,3 @@ -namespace test +package test class Clock<A : java.lang.Number> diff --git a/compiler/testData/readClass/class/ClassParamUpperClassInterfaceBound.kt b/compiler/testData/readClass/class/ClassParamUpperClassInterfaceBound.kt index 992a24af91b..36145796a37 100644 --- a/compiler/testData/readClass/class/ClassParamUpperClassInterfaceBound.kt +++ b/compiler/testData/readClass/class/ClassParamUpperClassInterfaceBound.kt @@ -1,3 +1,3 @@ -namespace test +package test class Clock<A> where A : java.lang.Number, A : java.lang.CharSequence diff --git a/compiler/testData/readClass/class/ClassParamUpperInterfaceBound.kt b/compiler/testData/readClass/class/ClassParamUpperInterfaceBound.kt index 8f05d69017f..27c8bfdd7cf 100644 --- a/compiler/testData/readClass/class/ClassParamUpperInterfaceBound.kt +++ b/compiler/testData/readClass/class/ClassParamUpperInterfaceBound.kt @@ -1,3 +1,3 @@ -namespace test +package test class Clock<A : java.lang.CharSequence> diff --git a/compiler/testData/readClass/class/ClassParamUpperInterfaceClassBound.kt b/compiler/testData/readClass/class/ClassParamUpperInterfaceClassBound.kt index 8e8170d48c5..67d144ffb45 100644 --- a/compiler/testData/readClass/class/ClassParamUpperInterfaceClassBound.kt +++ b/compiler/testData/readClass/class/ClassParamUpperInterfaceClassBound.kt @@ -1,3 +1,3 @@ -namespace test +package test class Clock<A> where A : java.lang.CharSequence, A : java.lang.Number diff --git a/compiler/testData/readClass/class/Trait.kt b/compiler/testData/readClass/class/Trait.kt index b984afa34b0..100e972734f 100644 --- a/compiler/testData/readClass/class/Trait.kt +++ b/compiler/testData/readClass/class/Trait.kt @@ -1,3 +1,3 @@ -namespace test +package test trait Trtrtr diff --git a/compiler/testData/readClass/fun/ClassFun.kt b/compiler/testData/readClass/fun/ClassFun.kt index 27eb0bc5e37..685e14a9c09 100644 --- a/compiler/testData/readClass/fun/ClassFun.kt +++ b/compiler/testData/readClass/fun/ClassFun.kt @@ -1,4 +1,4 @@ -namespace test +package test class River { fun song() = 1 diff --git a/compiler/testData/readClass/fun/ExtFun.kt b/compiler/testData/readClass/fun/ExtFun.kt index f894ea8a631..342a67ffed7 100644 --- a/compiler/testData/readClass/fun/ExtFun.kt +++ b/compiler/testData/readClass/fun/ExtFun.kt @@ -1,3 +1,3 @@ -namespace test +package test fun Int.shuffle() = 1 diff --git a/compiler/testData/readClass/fun/ExtFunInClass.kt b/compiler/testData/readClass/fun/ExtFunInClass.kt new file mode 100644 index 00000000000..dd27797cc33 --- /dev/null +++ b/compiler/testData/readClass/fun/ExtFunInClass.kt @@ -0,0 +1,5 @@ +package test + +class ExtFunInClass { + fun Int.shuffle() = 1 +} diff --git a/compiler/testData/readClass/fun/FunClassParamNotNull.kt b/compiler/testData/readClass/fun/FunClassParamNotNull.kt index 92e6b8f1fd8..3ead3d4c8be 100644 --- a/compiler/testData/readClass/fun/FunClassParamNotNull.kt +++ b/compiler/testData/readClass/fun/FunClassParamNotNull.kt @@ -1,4 +1,4 @@ -namespace test +package test import java.util.List import java.lang.CharSequence diff --git a/compiler/testData/readClass/fun/FunClassParamNullable.kt b/compiler/testData/readClass/fun/FunClassParamNullable.kt index 8b40b9ff0bc..92c624f3937 100644 --- a/compiler/testData/readClass/fun/FunClassParamNullable.kt +++ b/compiler/testData/readClass/fun/FunClassParamNullable.kt @@ -1,4 +1,4 @@ -namespace test +package test import java.util.List import java.lang.CharSequence diff --git a/compiler/testData/readClass/fun/FunDefaultArg.kt b/compiler/testData/readClass/fun/FunDefaultArg.kt new file mode 100644 index 00000000000..b71f68aacc9 --- /dev/null +++ b/compiler/testData/readClass/fun/FunDefaultArg.kt @@ -0,0 +1,3 @@ +package test + +fun funDefaultArg(p: Int, q: Int = 17, r: Int = 18) = 19 diff --git a/compiler/testData/readClass/fun/FunGenericParam.kt b/compiler/testData/readClass/fun/FunGenericParam.kt index 56db0deab7e..fa89b067e2c 100644 --- a/compiler/testData/readClass/fun/FunGenericParam.kt +++ b/compiler/testData/readClass/fun/FunGenericParam.kt @@ -1,3 +1,3 @@ -namespace test +package test fun <T> f() = 1 diff --git a/compiler/testData/readClass/fun/FunInParam.kt b/compiler/testData/readClass/fun/FunInParam.kt index c12eb63fc3e..1f0d5094f8f 100644 --- a/compiler/testData/readClass/fun/FunInParam.kt +++ b/compiler/testData/readClass/fun/FunInParam.kt @@ -1,3 +1,3 @@ -namespace test +package test fun <in T> f() = 1 diff --git a/compiler/testData/readClass/fun/FunOutParam.kt b/compiler/testData/readClass/fun/FunOutParam.kt index 7198872c6f8..c5f4b318c50 100644 --- a/compiler/testData/readClass/fun/FunOutParam.kt +++ b/compiler/testData/readClass/fun/FunOutParam.kt @@ -1,3 +1,3 @@ -namespace test +package test fun <out T> f() = 1 diff --git a/compiler/testData/readClass/fun/FunParamNotNull.kt b/compiler/testData/readClass/fun/FunParamNotNull.kt index 1673576064f..30f1bfa56e5 100644 --- a/compiler/testData/readClass/fun/FunParamNotNull.kt +++ b/compiler/testData/readClass/fun/FunParamNotNull.kt @@ -1,3 +1,3 @@ -namespace test +package test fun fff(a: java.lang.CharSequence) = 1 diff --git a/compiler/testData/readClass/fun/FunParamNullable.kt b/compiler/testData/readClass/fun/FunParamNullable.kt index af1e70d8115..17f91ae6d69 100644 --- a/compiler/testData/readClass/fun/FunParamNullable.kt +++ b/compiler/testData/readClass/fun/FunParamNullable.kt @@ -1,3 +1,3 @@ -namespace test +package test fun fff(a: java.lang.CharSequence?) = 1 diff --git a/compiler/testData/readClass/fun/FunParamUpperClassBound.kt b/compiler/testData/readClass/fun/FunParamUpperClassBound.kt index 3a4c68fed8f..f1835c676f5 100644 --- a/compiler/testData/readClass/fun/FunParamUpperClassBound.kt +++ b/compiler/testData/readClass/fun/FunParamUpperClassBound.kt @@ -1,3 +1,3 @@ -namespace test +package test fun <A : java.lang.Number> uno() = 1 diff --git a/compiler/testData/readClass/fun/FunParamUpperClassInterfaceBound.kt b/compiler/testData/readClass/fun/FunParamUpperClassInterfaceBound.kt index 678d5a2967a..f4d1f4f63d8 100644 --- a/compiler/testData/readClass/fun/FunParamUpperClassInterfaceBound.kt +++ b/compiler/testData/readClass/fun/FunParamUpperClassInterfaceBound.kt @@ -1,3 +1,3 @@ -namespace test +package test fun <A> tres() where A : java.lang.Number, A : java.lang.CharSequence = 1 diff --git a/compiler/testData/readClass/fun/FunParamUpperInterfaceBound.kt b/compiler/testData/readClass/fun/FunParamUpperInterfaceBound.kt index 00a6e0432cb..fc7b646ee05 100644 --- a/compiler/testData/readClass/fun/FunParamUpperInterfaceBound.kt +++ b/compiler/testData/readClass/fun/FunParamUpperInterfaceBound.kt @@ -1,3 +1,3 @@ -namespace test +package test fun <A : java.lang.CharSequence> dos() = 1 diff --git a/compiler/testData/readClass/fun/FunParamUpperInterfaceClassBound.kt b/compiler/testData/readClass/fun/FunParamUpperInterfaceClassBound.kt index 6effa87aba9..d4d7e97c861 100644 --- a/compiler/testData/readClass/fun/FunParamUpperInterfaceClassBound.kt +++ b/compiler/testData/readClass/fun/FunParamUpperInterfaceClassBound.kt @@ -1,3 +1,3 @@ -namespace test +package test fun <A> cuatro() where A : java.lang.CharSequence, A : java.lang.Number = 1 diff --git a/compiler/testData/readClass/fun/FunVarargCharSequence.kt b/compiler/testData/readClass/fun/FunVarargCharSequence.kt new file mode 100644 index 00000000000..53164ea0f77 --- /dev/null +++ b/compiler/testData/readClass/fun/FunVarargCharSequence.kt @@ -0,0 +1,3 @@ +package test + +fun varargCharSequence(a: Int, vararg b: java.lang.CharSequence) = 1 diff --git a/compiler/testData/readClass/fun/FunVarargInt.kt b/compiler/testData/readClass/fun/FunVarargInt.kt new file mode 100644 index 00000000000..7dcb019a22a --- /dev/null +++ b/compiler/testData/readClass/fun/FunVarargInt.kt @@ -0,0 +1,3 @@ +package test + +fun varargInt(a: Int, vararg b: Int) = 1 diff --git a/compiler/testData/readClass/fun/ModifierAbstract.kt b/compiler/testData/readClass/fun/ModifierAbstract.kt new file mode 100644 index 00000000000..536dcd4af7b --- /dev/null +++ b/compiler/testData/readClass/fun/ModifierAbstract.kt @@ -0,0 +1,5 @@ +package test + +abstract class ModifierAbstract { + abstract fun abs(): Int +} diff --git a/compiler/testData/readClass/fun/ModifierOpen.kt b/compiler/testData/readClass/fun/ModifierOpen.kt new file mode 100644 index 00000000000..0483a76957a --- /dev/null +++ b/compiler/testData/readClass/fun/ModifierOpen.kt @@ -0,0 +1,5 @@ +package test + +open class ModifierOpen { + open fun abs() = 1 +} diff --git a/compiler/testData/readClass/fun/NsFun.kt b/compiler/testData/readClass/fun/NsFun.kt index 6fc14ecc6df..28df28624d5 100644 --- a/compiler/testData/readClass/fun/NsFun.kt +++ b/compiler/testData/readClass/fun/NsFun.kt @@ -1,3 +1,3 @@ -namespace test +package test fun f() = 1 diff --git a/compiler/testData/readClass/fun/ReturnTypeClassParamNotNull.kt b/compiler/testData/readClass/fun/ReturnTypeClassParamNotNull.kt index 94613473c88..e0c7fddcb44 100644 --- a/compiler/testData/readClass/fun/ReturnTypeClassParamNotNull.kt +++ b/compiler/testData/readClass/fun/ReturnTypeClassParamNotNull.kt @@ -1,4 +1,4 @@ -namespace test +package test import java.util.List import java.util.ArrayList diff --git a/compiler/testData/readClass/fun/ReturnTypeClassParamNullable.kt b/compiler/testData/readClass/fun/ReturnTypeClassParamNullable.kt index 4c9bb54a59e..2442e8f56bc 100644 --- a/compiler/testData/readClass/fun/ReturnTypeClassParamNullable.kt +++ b/compiler/testData/readClass/fun/ReturnTypeClassParamNullable.kt @@ -1,4 +1,4 @@ -namespace test +package test import java.util.List import java.util.ArrayList diff --git a/compiler/testData/readClass/fun/ReturnTypeNotNull.kt b/compiler/testData/readClass/fun/ReturnTypeNotNull.kt index fd57fb31d3d..136090e8aeb 100644 --- a/compiler/testData/readClass/fun/ReturnTypeNotNull.kt +++ b/compiler/testData/readClass/fun/ReturnTypeNotNull.kt @@ -1,3 +1,3 @@ -namespace test +package test fun ff(): java.lang.CharSequence = throw Exception() diff --git a/compiler/testData/readClass/fun/ReturnTypeNullable.kt b/compiler/testData/readClass/fun/ReturnTypeNullable.kt index 61d5a242d1d..00d102eb9eb 100644 --- a/compiler/testData/readClass/fun/ReturnTypeNullable.kt +++ b/compiler/testData/readClass/fun/ReturnTypeNullable.kt @@ -1,3 +1,3 @@ -namespace test +package test fun ff(): java.lang.CharSequence? = null diff --git a/compiler/testData/resolve/ClassObjects.jet b/compiler/testData/resolve/ClassObjects.jet index f698650f962..b9fc8ccc233 100644 --- a/compiler/testData/resolve/ClassObjects.jet +++ b/compiler/testData/resolve/ClassObjects.jet @@ -1,4 +1,4 @@ -namespace Jet86 +package Jet86 ~A~class A { class object { diff --git a/compiler/testData/resolve/Classifiers.jet b/compiler/testData/resolve/Classifiers.jet index 8e3a16988fb..bcfd4e6ad8f 100644 --- a/compiler/testData/resolve/Classifiers.jet +++ b/compiler/testData/resolve/Classifiers.jet @@ -1,4 +1,4 @@ -namespace qualified_this { +package qualified_this { ~qtA~class A(val a:Int) { ~qtB~class B() { @@ -8,7 +8,7 @@ namespace qualified_this { ~xx~val Int.xx = `xx`this : Int ~xx()~fun Int.xx() { `xx()`this : Int - val a = {Int.() => `xx()`this`xx()`@xx + this} + val a = {Int.() -> `xx()`this`xx()`@xx + this} } } diff --git a/compiler/testData/resolve/FunctionVariable.jet b/compiler/testData/resolve/FunctionVariable.jet index b7ea7a62f8a..5318d55d65c 100644 --- a/compiler/testData/resolve/FunctionVariable.jet +++ b/compiler/testData/resolve/FunctionVariable.jet @@ -1,3 +1,3 @@ -fun invoker(~gen~gen : fun () : Int) : Int { +fun invoker(~gen~gen : () -> Int) : Int { return `gen`gen() // Says it cannot resolve 'gen' here } diff --git a/compiler/testData/resolve/LocalObjects.jet b/compiler/testData/resolve/LocalObjects.jet index e46a6abb22e..89bdbe03779 100644 --- a/compiler/testData/resolve/LocalObjects.jet +++ b/compiler/testData/resolve/LocalObjects.jet @@ -1,4 +1,4 @@ -namespace localObjects { +package localObjects { object ~A~A { ~x~val x : Int } diff --git a/compiler/testData/resolve/Namespaces.jet b/compiler/testData/resolve/Namespaces.jet index 42a3a88bef1..4b79d7a4596 100644 --- a/compiler/testData/resolve/Namespaces.jet +++ b/compiler/testData/resolve/Namespaces.jet @@ -1,6 +1,6 @@ -namespace root +package root -~a~namespace a { +~a~package a { import java.* ~a.a~val a : util.List<Int>? = null @@ -9,7 +9,7 @@ namespace root } -namespace a { +package a { import java.util.* ~a.b~val b : List<Int>? = null diff --git a/compiler/testData/resolve/NestedObjects.jet b/compiler/testData/resolve/NestedObjects.jet index fa005f5c703..cb45d1f1ecb 100644 --- a/compiler/testData/resolve/NestedObjects.jet +++ b/compiler/testData/resolve/NestedObjects.jet @@ -1,4 +1,4 @@ -~ns~namespace nestedObjects { +~ns~package nestedObjects { object ~A~A { val b = `A.B`B val d = `A`A.`A.B`B.`A.B.A`A diff --git a/compiler/testData/resolve/Objects.jet b/compiler/testData/resolve/Objects.jet index e59a6f1252c..950a4edaa44 100644 --- a/compiler/testData/resolve/Objects.jet +++ b/compiler/testData/resolve/Objects.jet @@ -1,4 +1,4 @@ -namespace toplevelObjectDeclarations { +package toplevelObjectDeclarations { class Foo(y : Int) { ~foo()~open fun foo() : Int = 1 } diff --git a/compiler/testData/resolve/PrimaryConstructors.jet b/compiler/testData/resolve/PrimaryConstructors.jet index ec09171ba32..99b37ac6c76 100644 --- a/compiler/testData/resolve/PrimaryConstructors.jet +++ b/compiler/testData/resolve/PrimaryConstructors.jet @@ -11,7 +11,7 @@ fun test() { a.`f`f()`:std::Int` } -namespace Jet65 { +package Jet65 { class Foo(~bar~var bar : Int, ~barr~barr : Int, ~barrr~val barrr : Int) { { diff --git a/compiler/tests/org/jetbrains/jet/ReadClassDataTest.java b/compiler/tests/org/jetbrains/jet/ReadClassDataTest.java index 04458738032..483903af1de 100644 --- a/compiler/tests/org/jetbrains/jet/ReadClassDataTest.java +++ b/compiler/tests/org/jetbrains/jet/ReadClassDataTest.java @@ -22,6 +22,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingTraceContext; import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver; import org.jetbrains.jet.lang.resolve.java.JavaSemanticServices; +import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver; import org.jetbrains.jet.lang.types.JetType; @@ -106,6 +107,7 @@ public class ReadClassDataTest extends UsefulTestCase { jetCoreEnvironment = JetTestUtils.createEnvironmentWithMockJdk(myTestRootDisposable); jetCoreEnvironment.addToClasspath(tmpdir); + jetCoreEnvironment.addToClasspath(new File("out/production/stdlib")); JetSemanticServices jetSemanticServices = JetSemanticServices.createSemanticServices(jetCoreEnvironment.getProject()); JavaSemanticServices semanticServices = new JavaSemanticServices(jetCoreEnvironment.getProject(), jetSemanticServices, new BindingTraceContext()); @@ -123,6 +125,8 @@ public class ReadClassDataTest extends UsefulTestCase { if (ad instanceof ClassifierDescriptor) { ClassifierDescriptor bd = nsb.getMemberScope().getClassifier(ad.getName()); compareClassifiers((ClassifierDescriptor) ad, bd); + + Assert.assertNull(nsb.getMemberScope().getClassifier(ad.getName() + JvmAbi.TRAIT_IMPL_SUFFIX)); } else if (ad instanceof FunctionDescriptor) { Set<FunctionDescriptor> functions = nsb.getMemberScope().getFunctions(ad.getName()); Assert.assertTrue(functions.size() >= 1); @@ -136,251 +140,290 @@ public class ReadClassDataTest extends UsefulTestCase { } private void compareClassifiers(@NotNull ClassifierDescriptor a, @NotNull ClassifierDescriptor b) { - String as = serializeContent((ClassDescriptor) a); - String bs = serializeContent((ClassDescriptor) b); + StringBuilder sba = new StringBuilder(); + StringBuilder sbb = new StringBuilder(); + + new Serializer(sba).serializeContent((ClassDescriptor) a); + new Serializer(sbb).serializeContent((ClassDescriptor) b); + + String as = sba.toString(); + String bs = sbb.toString(); Assert.assertEquals(as, bs); System.out.println(as); } - private String serializeContent(ClassDescriptor klass) { - - StringBuilder sb = new StringBuilder(); - serialize(klass.getKind(), sb); - sb.append(" "); - - serialize(klass, sb); - - if (!klass.getTypeConstructor().getParameters().isEmpty()) { - sb.append("<"); - serializeCommaSeparated(klass.getTypeConstructor().getParameters(), sb); - sb.append(">"); - } - - // TODO: supers - // TODO: constructors - - sb.append(" {\n"); - - List<TypeProjection> typeArguments = new ArrayList<TypeProjection>(); - for (TypeParameterDescriptor param : klass.getTypeConstructor().getParameters()) { - typeArguments.add(new TypeProjection(Variance.INVARIANT, param.getDefaultType())); - } - - JetScope memberScope = klass.getMemberScope(typeArguments); - for (DeclarationDescriptor member : memberScope.getAllDescriptors()) { - // TODO - if (member.getName().equals("equals") || member.getName().equals("hashCode") - || member.getName().equals("wait") || member.getName().equals("notify") || member.getName().equals("notifyAll") - || member.getName().equals("toString") || member.getName().equals("getClass") - || member.getName().equals("clone") || member.getName().equals("finalize") - || member.getName().equals("getTypeInfo") || member.getName().equals("$setTypeInfo") || member.getName().equals("$typeInfo") - ) - { - continue; - } - sb.append(" "); - serialize(member, sb); - sb.append("\n"); - } - - sb.append("}\n"); - return sb.toString(); - } - - private void serialize(ClassKind kind, StringBuilder sb) { - switch (kind) { - case CLASS: - sb.append("class"); - break; - case TRAIT: - sb.append("trait"); - break; - default: - throw new IllegalStateException(); - } - } - - private void compareFunctions(@NotNull FunctionDescriptor a, @NotNull FunctionDescriptor b) { - String as = serialize(a); - String bs = serialize(b); + StringBuilder sba = new StringBuilder(); + StringBuilder sbb = new StringBuilder(); + new Serializer(sba).serialize(a); + new Serializer(sbb).serialize(b); + String as = sba.toString(); + String bs = sbb.toString(); + Assert.assertEquals(as, bs); System.out.println(as); } - - private static Object invoke(Method method, Object thiz, Object... args) { - try { - return method.invoke(thiz, args); - } catch (Exception e) { - throw new RuntimeException("failed to invoke " + method + ": " + e, e); - } - } - - - private void serialize(FunctionDescriptor fun, StringBuilder sb) { - sb.append("fun "); - if (!fun.getTypeParameters().isEmpty()) { - sb.append("<"); - serializeCommaSeparated(fun.getTypeParameters(), sb); - sb.append(">"); + + + + private static class Serializer { + + protected final StringBuilder sb; + + public Serializer(StringBuilder sb) { + this.sb = sb; } - if (fun.getReceiverParameter().exists()) { - serialize(fun.getReceiverParameter(), sb); - sb.append("."); - } + private String serializeContent(ClassDescriptor klass) { - sb.append(fun.getName()); - sb.append("("); - serializeCommaSeparated(fun.getValueParameters(), sb); - sb.append("): "); - serialize(fun.getReturnType(), sb); - } - - private void serialize(ExtensionReceiver extensionReceiver, StringBuilder sb) { - serialize(extensionReceiver.getType(), sb); - } - - private void serialize(PropertyDescriptor prop, StringBuilder sb) { - if (prop.isVar()) { - sb.append("var "); - } else { - sb.append("val "); - } - sb.append(prop.getName()); - sb.append(": "); - serialize(prop.getOutType(), sb); - } - - private void serialize(ValueParameterDescriptor valueParameter, StringBuilder sb) { - sb.append(valueParameter.getName()); - sb.append(": "); - if (valueParameter.getVarargElementType() != null) { - sb.append("vararg "); - serialize(valueParameter.getVarargElementType()); - } else { - serialize(valueParameter.getOutType(), sb); - } - if (valueParameter.hasDefaultValue()) { - sb.append(" = ?"); - } - } - - private void serialize(Variance variance, StringBuilder sb) { - if (variance == Variance.INVARIANT) { + serialize(klass.getModality()); + sb.append(" "); - } else { - sb.append(variance); - sb.append(' '); - } - } - - private void serialize(JetType type, StringBuilder sb) { - serialize(type.getConstructor().getDeclarationDescriptor(), sb); - if (!type.getArguments().isEmpty()) { - sb.append("<"); - boolean first = true; - for (TypeProjection proj : type.getArguments()) { - serialize(proj.getProjectionKind(), sb); - serialize(proj.getType(), sb); - if (!first) { - sb.append(", "); + serialize(klass.getKind()); + sb.append(" "); + + serialize(klass); + + if (!klass.getTypeConstructor().getParameters().isEmpty()) { + sb.append("<"); + serializeCommaSeparated(klass.getTypeConstructor().getParameters()); + sb.append(">"); + } + + // TODO: supers + // TODO: constructors + + sb.append(" {\n"); + + List<TypeProjection> typeArguments = new ArrayList<TypeProjection>(); + for (TypeParameterDescriptor param : klass.getTypeConstructor().getParameters()) { + typeArguments.add(new TypeProjection(Variance.INVARIANT, param.getDefaultType())); + } + + JetScope memberScope = klass.getMemberScope(typeArguments); + for (DeclarationDescriptor member : memberScope.getAllDescriptors()) { + // TODO + if (member.getName().equals("equals") || member.getName().equals("hashCode") + || member.getName().equals("wait") || member.getName().equals("notify") || member.getName().equals("notifyAll") + || member.getName().equals("toString") || member.getName().equals("getClass") + || member.getName().equals("clone") || member.getName().equals("finalize") + || member.getName().equals("getTypeInfo") || member.getName().equals("$setTypeInfo") || member.getName().equals("$typeInfo") + ) + { + continue; } + sb.append(" "); + new Serializer(sb).serialize(member); + sb.append("\n"); + } + + sb.append("}\n"); + return sb.toString(); + } + + public void serialize(ClassKind kind) { + switch (kind) { + case CLASS: + sb.append("class"); + break; + case TRAIT: + sb.append("trait"); + break; + default: + throw new IllegalStateException(); + } + } + + + private static Object invoke(Method method, Object thiz, Object... args) { + try { + return method.invoke(thiz, args); + } catch (Exception e) { + throw new RuntimeException("failed to invoke " + method + ": " + e, e); + } + } + + + public void serialize(FunctionDescriptor fun) { + serialize(fun.getModality()); + sb.append(" "); + + sb.append("fun "); + if (!fun.getTypeParameters().isEmpty()) { + sb.append("<"); + serializeCommaSeparated(fun.getTypeParameters()); + sb.append(">"); + } + + if (fun.getReceiverParameter().exists()) { + serialize(fun.getReceiverParameter()); + sb.append("."); + } + + sb.append(fun.getName()); + sb.append("("); + new ValueParameterSerializer(sb).serializeCommaSeparated(fun.getValueParameters()); + sb.append("): "); + serialize(fun.getReturnType()); + } + + public void serialize(ExtensionReceiver extensionReceiver) { + serialize(extensionReceiver.getType()); + } + + public void serialize(PropertyDescriptor prop) { + if (prop.isVar()) { + sb.append("var "); + } else { + sb.append("val "); + } + sb.append(prop.getName()); + sb.append(": "); + serialize(prop.getOutType()); + } + + public void serialize(ValueParameterDescriptor valueParameter) { + if (valueParameter.getVarargElementType() != null) { + sb.append("vararg "); + } + sb.append(valueParameter.getName()); + sb.append(": "); + if (valueParameter.getVarargElementType() != null) { + serialize(valueParameter.getVarargElementType()); + } else { + serialize(valueParameter.getOutType()); + } + if (valueParameter.hasDefaultValue()) { + sb.append(" = ?"); + } + } + + public void serialize(Variance variance) { + if (variance == Variance.INVARIANT) { + + } else { + sb.append(variance); + sb.append(' '); + } + } + + public void serialize(Modality modality) { + sb.append(modality.name().toLowerCase()); + } + + public void serialize(JetType type) { + serialize(type.getConstructor().getDeclarationDescriptor()); + if (!type.getArguments().isEmpty()) { + sb.append("<"); + boolean first = true; + for (TypeProjection proj : type.getArguments()) { + serialize(proj.getProjectionKind()); + serialize(proj.getType()); + if (!first) { + sb.append(", "); + } + first = false; + } + sb.append(">"); + } + } + + public void serializeCommaSeparated(List<?> list) { + serializeSeparated(list, ", "); + } + + public void serializeSeparated(List<?> list, String sep) { + boolean first = true; + for (Object o : list) { + if (!first) { + sb.append(sep); + } + serialize(o); first = false; } - sb.append(">"); } - } - - private String serialize(Object o) { - StringBuilder sb = new StringBuilder(); - serialize(o, sb); - return sb.toString(); - } - - private void serializeCommaSeparated(List<?> list, StringBuilder sb) { - serializeSeparated(list, sb, ", "); - } - private void serializeSeparated(List<?> list, StringBuilder sb, String sep) { - boolean first = true; - for (Object o : list) { - if (!first) { - sb.append(sep); + private Method getMethodToSerialize(Object o) { + // TODO: cache + for (Method method : this.getClass().getMethods()) { + if (!method.getName().equals("serialize")) { + continue; + } + if (method.getParameterTypes().length != 1) { + continue; + } + if (method.getParameterTypes()[0].equals(Object.class)) { + continue; + } + if (method.getParameterTypes()[0].isInstance(o)) { + method.setAccessible(true); + return method; + } } - serialize(o, sb); - first = false; + throw new IllegalStateException("don't know how to serialize " + o + " (of " + o.getClass() + ")"); } - } - private Method getMethodToSerialize(Object o) { - // TODO: cache - for (Method method : ReadClassDataTest.class.getDeclaredMethods()) { - if (!method.getName().equals("serialize")) { - continue; - } - if (method.getParameterTypes().length != 2) { - continue; - } - if (!method.getParameterTypes()[1].equals(StringBuilder.class)) { - continue; - } - if (method.getParameterTypes()[0].equals(Object.class)) { - continue; - } - if (method.getParameterTypes()[0].isInstance(o)) { - method.setAccessible(true); - return method; - } + public void serialize(Object o) { + Method method = getMethodToSerialize(o); + invoke(method, this, o); } - throw new IllegalStateException("don't know how to serialize " + o + " (of " + o.getClass() + ")"); - } - - private void serialize(Object o, StringBuilder sb) { - Method method = getMethodToSerialize(o); - invoke(method, this, o, sb); - } - - private void serialize(String s, StringBuilder sb) { - sb.append(s); - } - private void serialize(ModuleDescriptor module, StringBuilder sb) { - // nop - } - - private void serialize(ClassDescriptor clazz, StringBuilder sb) { - serialize(clazz.getContainingDeclaration(), sb); - sb.append("."); - sb.append(clazz.getName()); - } - - private void serialize(NamespaceDescriptor ns, StringBuilder sb) { - if (ns.getContainingDeclaration() == null) { - // root ns - return; + public void serialize(String s) { + sb.append(s); } - serialize(ns.getContainingDeclaration(), sb); - sb.append("."); - sb.append(ns.getName()); - } - private void serialize(TypeParameterDescriptor param, StringBuilder sb) { - serialize(param.getVariance(), sb); - sb.append(param.getName()); - if (!param.getUpperBounds().isEmpty()) { - sb.append(" : "); - List<String> list = new ArrayList<String>(); - for (JetType upper : param.getUpperBounds()) { - list.add(serialize(upper)); - } - Collections.sort(list); - serializeSeparated(list, sb, " & "); // TODO: use where + public void serialize(ModuleDescriptor module) { + // nop + } + + public void serialize(ClassDescriptor clazz) { + serialize(clazz.getContainingDeclaration()); + sb.append("."); + sb.append(clazz.getName()); + } + + public void serialize(NamespaceDescriptor ns) { + if (ns.getContainingDeclaration() == null) { + // root ns + return; + } + serialize(ns.getContainingDeclaration()); + sb.append("."); + sb.append(ns.getName()); + } + + public void serialize(TypeParameterDescriptor param) { + serialize(param.getVariance()); + sb.append(param.getName()); + if (!param.getUpperBounds().isEmpty()) { + sb.append(" : "); + List<String> list = new ArrayList<String>(); + for (JetType upper : param.getUpperBounds()) { + StringBuilder sb = new StringBuilder(); + new Serializer(sb).serialize(upper); + list.add(sb.toString()); + } + Collections.sort(list); + serializeSeparated(list, " & "); // TODO: use where + } + // TODO: lower bounds + } + + } + + private static class ValueParameterSerializer extends Serializer { + + public ValueParameterSerializer(StringBuilder sb) { + super(sb); + } + + @Override + public void serialize(TypeParameterDescriptor param) { + sb.append(param.getName()); } - // TODO: lower bounds } diff --git a/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java b/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java index f9e7eba1c9b..ceb54b29936 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java +++ b/compiler/tests/org/jetbrains/jet/checkers/CheckerTestUtilTest.java @@ -54,7 +54,7 @@ public class CheckerTestUtilTest extends JetLiteFixture { } public void testBoth() throws Exception { - doTest(new TheTest("Unexpected TYPE_MISMATCH at 56 to 57", "Missing UNRESOLVED_REFERENCE at 166 to 168") { + doTest(new TheTest("Unexpected TYPE_MISMATCH at 56 to 57", "Missing UNRESOLVED_REFERENCE at 164 to 166") { @Override protected void makeTestData(List<Diagnostic> diagnostics, List<CheckerTestUtil.DiagnosedRange> diagnosedRanges) { diagnosedRanges.remove(1); @@ -64,7 +64,7 @@ public class CheckerTestUtilTest extends JetLiteFixture { } public void testMissingInTheMiddle() throws Exception { - doTest(new TheTest("Unexpected NONE_APPLICABLE at 122 to 123", "Missing TYPE_MISMATCH at 161 to 169") { + doTest(new TheTest("Unexpected NONE_APPLICABLE at 120 to 121", "Missing TYPE_MISMATCH at 159 to 167") { @Override protected void makeTestData(List<Diagnostic> diagnostics, List<CheckerTestUtil.DiagnosedRange> diagnosedRanges) { diagnosedRanges.remove(4); diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.java index 9cabe8bdd66..61116f1dfa9 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTest.java @@ -10,7 +10,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.JetLiteFixture; import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.lang.Configuration; -import org.jetbrains.jet.lang.JetSemanticServices; import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory; import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils; import org.jetbrains.jet.lang.psi.JetDeclaration; diff --git a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java index 9312dadc793..89b4e450d8a 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ClassGenTest.java @@ -235,4 +235,8 @@ public class ClassGenTest extends CodegenTestCase { public void testKt707 () throws Exception { blackBoxFile("regressions/kt707.jet"); } + + public void testKt857 () throws Exception { +// blackBoxFile("regressions/kt857.jet"); + } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java b/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java index 2869aa145b4..36e3fe909f0 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/ControlStructuresTest.java @@ -236,6 +236,11 @@ public class ControlStructuresTest extends CodegenTestCase { // System.out.println(generateToText()); } + public void testKt870() throws Exception { + blackBoxFile("regressions/kt870.jet"); +// System.out.println(generateToText()); + } + public void testQuicksort() throws Exception { blackBoxFile("controlStructures/quicksort.jet"); // System.out.println(generateToText()); diff --git a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java index 295781b1837..968a5647f20 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/NamespaceGenTest.java @@ -485,7 +485,7 @@ public class NamespaceGenTest extends CodegenTestCase { } public void testTupleLiteral() throws Exception { - loadText("fun foo() = (1, \"foo\")"); + loadText("fun foo() = #(1, \"foo\")"); // System.out.println(generateToText()); final Method main = generateFunction("foo"); Tuple2 tuple2 = (Tuple2) main.invoke(null); @@ -494,7 +494,7 @@ public class NamespaceGenTest extends CodegenTestCase { } public void testParametrizedTupleLiteral() throws Exception { - loadText("fun <E,D> E.foo(extra: java.util.List<D>) = (1, \"foo\", this, extra)"); + loadText("fun <E,D> E.foo(extra: java.util.List<D>) = #(1, \"foo\", this, extra)"); // 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)); diff --git a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java index a3fd95c3ab3..4643204921f 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/PatternMatchingTest.java @@ -74,19 +74,19 @@ public class PatternMatchingTest extends CodegenTestCase { } public void testWildcardPattern() throws Exception { - loadText("fun foo(x: String) = when(x) { is * => \"something\" }"); + loadText("fun foo(x: String) = when(x) { is * -> \"something\" }"); Method foo = generateFunction(); assertEquals("something", foo.invoke(null, "")); } public void testNoReturnType() throws Exception { - loadText("fun foo(x: String) = when(x) { is * => \"x\" }"); + loadText("fun foo(x: String) = when(x) { is * -> \"x\" }"); Method foo = generateFunction(); assertEquals("x", foo.invoke(null, "")); } public void testTuplePattern() throws Exception { - loadText("fun foo(x: (Any, Any)) = when(x) { is (1,2) => \"one,two\"; else => \"something\" }"); + loadText("fun foo(x: #(Any, Any)) = when(x) { is #(1,2) -> \"one,two\"; else -> \"something\" }"); Method foo = generateFunction(); final Object result; try { @@ -118,14 +118,14 @@ public class PatternMatchingTest extends CodegenTestCase { } public void testNames() throws Exception { - loadText("fun foo(x: (Any, Any)) = when(x) { is (val a is String, *) => a; else => \"something\" }"); + loadText("fun foo(x: #(Any, Any)) = when(x) { is #(val a is String, *) -> a; else -> \"something\" }"); Method foo = generateFunction(); assertEquals("JetBrains", foo.invoke(null, new Tuple2<String, String>(null, "JetBrains", "s.r.o."))); assertEquals("something", foo.invoke(null, new Tuple2<Integer, Integer>(null, 1, 2))); } public void testMultipleConditions() throws Exception { - loadText("fun foo(x: Any) = when(x) { is 0, 1 => \"bit\"; else => \"something\" }"); + loadText("fun foo(x: Any) = when(x) { is 0, 1 -> \"bit\"; else -> \"something\" }"); Method foo = generateFunction(); assertEquals("bit", foo.invoke(null, 0)); assertEquals("bit", foo.invoke(null, 1)); diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index f50d208ffe0..c5e91c0969d 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -78,15 +78,15 @@ public class JetTypeCheckerTest extends JetLiteFixture { assertType("\"d\"", library.getStringType()); assertType("\"\"\"d\"\"\"", library.getStringType()); - assertType("()", JetStandardClasses.getUnitType()); + assertType("#()", JetStandardClasses.getUnitType()); assertType("null", JetStandardClasses.getNullableNothingType()); } public void testTupleConstants() throws Exception { - assertType("()", JetStandardClasses.getUnitType()); + assertType("#()", JetStandardClasses.getUnitType()); - assertType("(1, 'a')", JetStandardClasses.getTupleType(library.getIntType(), library.getCharType())); + assertType("#(1, 'a')", JetStandardClasses.getTupleType(library.getIntType(), library.getCharType())); } public void testTypeInfo() throws Exception { @@ -117,11 +117,11 @@ public class JetTypeCheckerTest extends JetLiteFixture { } public void testWhen() throws Exception { - assertType("when (1) { is 1 => 2; } ", "Int"); - assertType("when (1) { is 1 => 2; is 1 => '2'} ", "Any"); - assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => null} ", "Any?"); - assertType("when (1) { is 1 => 2; is 1 => '2'; else => null} ", "Any?"); - assertType("when (1) { is 1 => 2; is 1 => '2'; is 1 => when(2) {is 1 => null}} ", "Any?"); + assertType("when (1) { is 1 -> 2; } ", "Int"); + assertType("when (1) { is 1 -> 2; is 1 -> '2'} ", "Any"); + assertType("when (1) { is 1 -> 2; is 1 -> '2'; is 1 -> null} ", "Any?"); + assertType("when (1) { is 1 -> 2; is 1 -> '2'; else -> null} ", "Any?"); + assertType("when (1) { is 1 -> 2; is 1 -> '2'; is 1 -> when(2) {is 1 -> null}} ", "Any?"); } public void testTry() throws Exception { @@ -213,38 +213,38 @@ public class JetTypeCheckerTest extends JetLiteFixture { } public void testTuples() throws Exception { - assertSubtype("Unit", "()"); - assertSubtype("()", "Unit"); - assertSubtype("()", "()"); + assertSubtype("Unit", "#()"); + assertSubtype("#()", "Unit"); + assertSubtype("#()", "#()"); - assertSubtype("(Boolean)", "(Boolean)"); - assertSubtype("(Byte)", "(Byte)"); - assertSubtype("(Char)", "(Char)"); - assertSubtype("(Short)", "(Short)"); - assertSubtype("(Int)", "(Int)"); - assertSubtype("(Long)", "(Long)"); - assertSubtype("(Float)", "(Float)"); - assertSubtype("(Double)", "(Double)"); - assertSubtype("(Unit)", "(Unit)"); - assertSubtype("(Unit, Unit)", "(Unit, Unit)"); + assertSubtype("#(Boolean)", "#(Boolean)"); + assertSubtype("#(Byte)", "#(Byte)"); + assertSubtype("#(Char)", "#(Char)"); + assertSubtype("#(Short)", "#(Short)"); + assertSubtype("#(Int)", "#(Int)"); + assertSubtype("#(Long)", "#(Long)"); + assertSubtype("#(Float)", "#(Float)"); + assertSubtype("#(Double)", "#(Double)"); + assertSubtype("#(Unit)", "#(Unit)"); + assertSubtype("#(Unit, Unit)", "#(Unit, Unit)"); - assertSubtype("(Boolean)", "(Boolean)"); - assertSubtype("(Byte)", "(Byte)"); - assertSubtype("(Char)", "(Char)"); - assertSubtype("(Short)", "(Short)"); - assertSubtype("(Int)", "(Int)"); - assertSubtype("(Long)", "(Long)"); - assertSubtype("(Float)", "(Float)"); - assertSubtype("(Double)", "(Double)"); - assertSubtype("(Unit)", "(Unit)"); - assertSubtype("(Unit, Unit)", "(Unit, Unit)"); + assertSubtype("#(Boolean)", "#(Boolean)"); + assertSubtype("#(Byte)", "#(Byte)"); + assertSubtype("#(Char)", "#(Char)"); + assertSubtype("#(Short)", "#(Short)"); + assertSubtype("#(Int)", "#(Int)"); + assertSubtype("#(Long)", "#(Long)"); + assertSubtype("#(Float)", "#(Float)"); + assertSubtype("#(Double)", "#(Double)"); + assertSubtype("#(Unit)", "#(Unit)"); + assertSubtype("#(Unit, Unit)", "#(Unit, Unit)"); - assertNotSubtype("(Unit)", "(Int)"); + assertNotSubtype("#(Unit)", "#(Int)"); - assertSubtype("(Unit)", "(Any)"); - assertSubtype("(Unit, Unit)", "(Any, Any)"); - assertSubtype("(Unit, Unit)", "(Any, Unit)"); - assertSubtype("(Unit, Unit)", "(Unit, Any)"); + assertSubtype("#(Unit)", "#(Any)"); + assertSubtype("#(Unit, Unit)", "#(Any, Any)"); + assertSubtype("#(Unit, Unit)", "#(Any, Unit)"); + assertSubtype("#(Unit, Unit)", "#(Unit, Any)"); } public void testProjections() throws Exception { @@ -326,38 +326,38 @@ public class JetTypeCheckerTest extends JetLiteFixture { } public void testLoops() throws Exception { - assertType("{ while (1) {1} }", "fun(): Unit"); - assertType("{ do {1} while(1) }", "fun(): Unit"); - assertType("{ for (i in 1) {1} }", "fun(): Unit"); + assertType("{ while (1) {1} }", "() -> Unit"); + assertType("{ do {1} while(1) }", "() -> Unit"); + assertType("{ for (i in 1) {1} }", "() -> Unit"); } public void testFunctionLiterals() throws Exception { - assertType("{() => }", "fun () : Unit"); - assertType("{() : Int => }", "fun () : Int"); - assertType("{() => 1}", "fun () : Int"); + assertType("{() -> }", "() -> Unit"); + assertType("{() : Int -> }", "() -> Int"); + assertType("{() -> 1}", "() -> Int"); - assertType("{(a : Int) => 1}", "fun (a : Int) : Int"); - assertType("{(a : Int, b : String) => 1}", "fun (a : Int, b : String) : Int"); + assertType("{(a : Int) -> 1}", "(a : Int) -> Int"); + assertType("{(a : Int, b : String) -> 1}", "(a : Int, b : String) -> Int"); - assertType("{(a : Int) => 1}", "fun (Int) : Int"); - assertType("{(a : Int, b : String) => 1}", "fun (Int, String) : Int"); + assertType("{(a : Int) -> 1}", "(Int) -> Int"); + assertType("{(a : Int, b : String) -> 1}", "(Int, String) -> Int"); - assertType("{Any.() => 1}", "fun Any.() : Int"); + assertType("{Any.() -> 1}", "Any.() -> Int"); - assertType("{Any.(a : Int) => 1}", "fun Any.(a : Int) : Int"); - assertType("{Any.(a : Int, b : String) => 1}", "fun Any.(a : Int, b : String) : Int"); + assertType("{Any.(a : Int) -> 1}", "Any.(a : Int) -> Int"); + assertType("{Any.(a : Int, b : String) -> 1}", "Any.(a : Int, b : String) -> Int"); - assertType("{Any.(a : Int) => 1}", "fun Any.(Int) : Int"); - assertType("{Any.(a : Int, b : String) => 1}", "fun Any.(Int, String) : Int"); + assertType("{Any.(a : Int) -> 1}", "Any.(Int) -> Int"); + assertType("{Any.(a : Int, b : String) -> 1}", "Any.(Int, String) -> Int"); - assertType("{Any.(a : Int, b : String) => b}", "fun Any.(Int, String) : String"); + assertType("{Any.(a : Int, b : String) -> b}", "Any.(Int, String) -> String"); } public void testBlocks() throws Exception { assertType("if (1) {val a = 1; a} else {null}", "Int?"); - assertType("if (1) {() => val a = 1; a} else {() => null}", "Function0<Int?>"); - assertType("if (1) {() => val a = 1; a; var b : Boolean; b} else null", "Function0<Boolean>?"); - assertType("if (1) {() => val a = 1; a; var b = a; b} else null", "Function0<Int>?"); + assertType("if (1) {() -> val a = 1; a} else {() -> null}", "Function0<Int?>"); + assertType("if (1) {() -> val a = 1; a; var b : Boolean; b} else null", "Function0<Boolean>?"); + assertType("if (1) {() -> val a = 1; a; var b = a; b} else null", "Function0<Int>?"); } public void testNew() throws Exception { @@ -376,7 +376,7 @@ public class JetTypeCheckerTest extends JetLiteFixture { public void testOverloads() throws Exception { assertType("Functions<String>().f()", "Unit"); assertType("Functions<String>().f(1)", "Int"); - assertType("Functions<Double>().f((1, 1))", "Double"); + assertType("Functions<Double>().f(#(1, 1))", "Double"); assertType("Functions<Double>().f(1.0)", "Any"); assertType("Functions<Byte>().f<String>(\"\")", "Byte"); @@ -577,7 +577,7 @@ public class JetTypeCheckerTest extends JetLiteFixture { "fun f() : Unit {} " + "fun f(a : Int) : Int {} " + "fun f(a : T) : Any {} " + - "fun f(a : (Int, Int)) : T {} " + + "fun f(a : #(Int, Int)) : T {} " + "fun f<E>(a : E) : T {} " + "}", "class WithPredicate() { " + diff --git a/docs/Devclub_Kotlin.key b/docs/Devclub_Kotlin.key new file mode 100644 index 00000000000..7bd77f7dbe7 Binary files /dev/null and b/docs/Devclub_Kotlin.key differ diff --git a/examples/src/Bottles.kt b/examples/src/Bottles.kt index ceab79be506..ca621424f79 100644 --- a/examples/src/Bottles.kt +++ b/examples/src/Bottles.kt @@ -1,4 +1,4 @@ -namespace bottles; +package bottles; fun main(args: Array<String>) { var bottles: Int = 99; diff --git a/examples/src/Generics.jet b/examples/src/Generics.jet index 3801dfac301..537bb96c5a8 100644 --- a/examples/src/Generics.jet +++ b/examples/src/Generics.jet @@ -1,4 +1,4 @@ -namespace generics; +package generics; import java.util.* diff --git a/examples/src/HelloNames.kt b/examples/src/HelloNames.kt index a7525288a4d..923609192a4 100644 --- a/examples/src/HelloNames.kt +++ b/examples/src/HelloNames.kt @@ -1,4 +1,4 @@ -namespace HelloNames +package HelloNames fun main(args : Array<String>) { var names = "" diff --git a/examples/src/HelloNamesFaster.kt b/examples/src/HelloNamesFaster.kt index 44a2afa8577..ee69a623086 100644 --- a/examples/src/HelloNamesFaster.kt +++ b/examples/src/HelloNamesFaster.kt @@ -1,4 +1,4 @@ -namespace HelloNamesFaster +package HelloNamesFaster fun main(args : Array<String>) { var names = StringBuilder() diff --git a/examples/src/HelloNamesRealistic.kt b/examples/src/HelloNamesRealistic.kt index a144a5e1db5..e3c74d82f8a 100644 --- a/examples/src/HelloNamesRealistic.kt +++ b/examples/src/HelloNamesRealistic.kt @@ -1,4 +1,4 @@ -namespace HelloNamesRealistic +package HelloNamesRealistic fun main(args : Array<String>) { val names = args.join(", ") diff --git a/examples/src/JavaInterop.jet b/examples/src/JavaInterop.jet index 311d2c1233b..6c5bafc2293 100644 --- a/examples/src/JavaInterop.jet +++ b/examples/src/JavaInterop.jet @@ -1,4 +1,4 @@ -namespace JavaInterop +package JavaInterop import java.util.* diff --git a/examples/src/NullSafety.jet b/examples/src/NullSafety.jet index bd8460811d4..c795d1804da 100644 --- a/examples/src/NullSafety.jet +++ b/examples/src/NullSafety.jet @@ -1,4 +1,4 @@ -namespace NullSafety +package NullSafety fun <T : Any> T?.npe() : T = if (this == null) diff --git a/examples/src/benchmarks/FList.kt b/examples/src/benchmarks/FList.kt index 17179b006bb..08978dae5d6 100644 --- a/examples/src/benchmarks/FList.kt +++ b/examples/src/benchmarks/FList.kt @@ -1,4 +1,4 @@ -namespace flist +package flist abstract class FList<T> { abstract val head : T @@ -30,8 +30,8 @@ class StandardFList<T> (override val head: T, override val tail: FList<T>) : FLi fun <T> FList<T>.plus2(element: T): FList<T> = when(this) { - is EmptyFList<*> => OneElementFList<T>(element) - else => StandardFList<T>(element, this) + is EmptyFList<*> -> OneElementFList<T>(element) + else -> StandardFList<T>(element, this) } fun <T> FList<T>.plus3(element: T) : FList<T> = diff --git a/examples/src/benchmarks/LockPerf.kt b/examples/src/benchmarks/LockPerf.kt index 2937c59dfd1..9c68697bf01 100644 --- a/examples/src/benchmarks/LockPerf.kt +++ b/examples/src/benchmarks/LockPerf.kt @@ -1,4 +1,4 @@ -namespace lockperformance +package lockperformance import std.io.* import std.util.* @@ -8,7 +8,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.CountDownLatch; import java.util.concurrent.locks.ReentrantLock; -fun <T> Int.latch(op: fun CountDownLatch.() : T) : T { +fun <T> Int.latch(op: CountDownLatch.() -> T) : T { val cdl = CountDownLatch(this) val res = cdl.op() cdl.await() diff --git a/examples/src/benchmarks/Quicksort.kt b/examples/src/benchmarks/Quicksort.kt index 2d98fe82335..ccbe6359048 100644 --- a/examples/src/benchmarks/Quicksort.kt +++ b/examples/src/benchmarks/Quicksort.kt @@ -1,4 +1,4 @@ -namespace quicksort +package quicksort fun IntArray.swap(i:Int, j:Int) { val temp = this[i] diff --git a/examples/src/benchmarks/SpectralNorm.kt b/examples/src/benchmarks/SpectralNorm.kt index 930302bba87..37c046b47f3 100644 --- a/examples/src/benchmarks/SpectralNorm.kt +++ b/examples/src/benchmarks/SpectralNorm.kt @@ -1,4 +1,4 @@ -namespace spectralnorm +package spectralnorm import java.text.DecimalFormat; import java.text.NumberFormat; diff --git a/examples/src/benchmarks/ThreadRing.kt b/examples/src/benchmarks/ThreadRing.kt index 17547adefdd..6f8c61ad56e 100644 --- a/examples/src/benchmarks/ThreadRing.kt +++ b/examples/src/benchmarks/ThreadRing.kt @@ -1,4 +1,4 @@ -namespace threadring +package threadring import java.util.concurrent.*; import java.util.concurrent.atomic.*; diff --git a/examples/src/collections/IIterable.kt b/examples/src/collections/IIterable.kt index ae5dbdc0a51..69071c4bfb4 100644 --- a/examples/src/collections/IIterable.kt +++ b/examples/src/collections/IIterable.kt @@ -1,4 +1,4 @@ -namespace jet.collections.iterable +package jet.collections.iterable import jet.collections.iterator.IIterator diff --git a/examples/src/collections/ISet.kt b/examples/src/collections/ISet.kt index 8b3b375fa32..ac0d00956ec 100644 --- a/examples/src/collections/ISet.kt +++ b/examples/src/collections/ISet.kt @@ -1,4 +1,4 @@ -namespace jet.collections.set +package jet.collections.set import jet.collections.sized.ISized import jet.collections.iterable.IIterable diff --git a/examples/src/collections/ISized.kt b/examples/src/collections/ISized.kt index 80f6fdd6a05..9a69e299b24 100644 --- a/examples/src/collections/ISized.kt +++ b/examples/src/collections/ISized.kt @@ -1,4 +1,4 @@ -namespace jet.collections.sized +package jet.collections.sized trait ISized { val size : Int diff --git a/examples/src/collections/Iterator.kt b/examples/src/collections/Iterator.kt index 0e8bfac5277..286ed2225fa 100644 --- a/examples/src/collections/Iterator.kt +++ b/examples/src/collections/Iterator.kt @@ -1,4 +1,4 @@ -namespace jet.collections +package jet.collections import java.util.NoSuchElementException diff --git a/examples/src/netty/netty.kt b/examples/src/netty/netty.kt index 4068072d7ec..643a9801e1a 100644 --- a/examples/src/netty/netty.kt +++ b/examples/src/netty/netty.kt @@ -16,7 +16,7 @@ import org.jboss.netty.handler.codec.http.HttpResponseStatus.* import netty.* import jlstring.* -namespace jlstring { +package jlstring { fun String.replace(c: Char, by: Char) : String = (this as java.lang.String).replace(c, by) as String fun String.contains(s: String) : Boolean = (this as java.lang.String).contains(s as java.lang.CharSequence) @@ -24,7 +24,7 @@ namespace jlstring { fun java.lang.String.plus(s: Any?) : String = (this as String) + s.toString() } -namespace netty { +package netty { fun ChannelPipeline.with(op: fun ChannelPipeline.() ) : ChannelPipeline { this.op() return this diff --git a/grammar/src/expressions.grm b/grammar/src/expressions.grm index 28f3de35070..2491b7120fa 100644 --- a/grammar/src/expressions.grm +++ b/grammar/src/expressions.grm @@ -6,7 +6,7 @@ bq. See [Expressions] h3. Precedence ||*Precedence*||Title||Symbols|| -|Highest|Postfix|{{\+\+}}, {{\-\-}}, {{#}}, {{.}}, {{?.}}, {{?}}| +|Highest|Postfix|{{\+\+}}, {{\-\-}}, {{.}}, {{?.}}, {{?}}| | |Prefix|{{-}}, {{\+}}, {{\+\+}}, {{\-\-}}, {{!}}, [{{@label}}|#LabelName], {{@}}, {{@@}} | | |Type RHS|{{:}}, {{as}}, {{as?}} | | |Multiplicative|{{*}}, {{/}}, {{%}} | @@ -19,7 +19,6 @@ h3. Precedence | |Equality|{{==}}, {{\!==}}| | |Conjunction|{{&&}}| | |Disjunction|{{\|\|}}| -| |Arrow|{{\->}}| |Lowest|Assignment|{{=}}, {{+=}}, {{-=}}, {{*=}}, {{/=}}, {{%=}}| h3. Rules @@ -41,17 +40,12 @@ Decreasing precedence: equalityOperation "&&" "||" - "->" assignmentOperator */ expression - : arrowTupleExpression (assignmentOperator arrowTupleExpression)? - ; - -arrowTupleExpression - : disjunction ("->" disjunction)* + : disjunction (assignmentOperator disjunction)* ; disjunction @@ -109,7 +103,7 @@ postfixUnaryExpression // !!! When you add here, remember to update the FIRST set in the parser atomicExpression - : "(" expression ")" // see tupleLiteral + : "(" expression ")" : literalConstant : functionLiteral : tupleLiteral @@ -230,7 +224,7 @@ callSuffix ; memberAccessOperation - : "." : "?." : "#" : "?" + : "." : "?." : "?" ; typeArguments @@ -249,17 +243,15 @@ jump // yield ? ; -// Ambiguity when after a SimpleName (infix call). In this case (e) is treated as an expression in parentheses -// to put a tuple, write write ((e)) tupleLiteral - : "(" (((SimpleName "=")? expression){","})? ")" + : "#" "(" (((SimpleName "=")? expression){","})? ")" ; // one can use "it" as a parameter name functionLiteral : "{" statements "}" - : "{" (modifiers SimpleName){","} "=>" statements "}" - : "{" (type ".")? "(" (modifiers SimpleName (":" type)?){","} ")" (":" type)? "=>" statements "}" + : "{" (modifiers SimpleName){","} "->" statements "}" + : "{" (type ".")? "(" (modifiers SimpleName (":" type)?){","} ")" (":" type)? "->" statements "}" ; statements diff --git a/grammar/src/types.grm b/grammar/src/types.grm index b92457e67ce..d198da53afb 100644 --- a/grammar/src/types.grm +++ b/grammar/src/types.grm @@ -7,11 +7,11 @@ bq. See [Types] /* Foo<Bar<X>, T, Object> // user type -{(A, Object) : Foo} // function type -{ () : Foo} // function with no arguments -(A, B, C) // tuple type -(a : A, b : B) // tuple type with named entries -() // 0-ary tuple type (Unit) +(A, Object) -> Foo // function type +() -> Foo // function with no arguments +#(A, B, C) // tuple type +#(a : A, b : B) // tuple type with named entries +#() // 0-ary tuple type (Unit) */ @@ -20,6 +20,7 @@ type // IF YOU CHANGE THIS, please, update TYPE_FIRST in JetParsing typeDescriptor + : "(" typeDescriptor ")" : selfType : functionType : userType @@ -47,12 +48,12 @@ optionalProjection ; functionType - : "fun" (type ".")? "(" (parameter | modifiers /*lazy out ref*/ type){","} ")" (":" type)? // Unit by default + : (type ".")? "(" (parameter | modifiers /*lazy out ref*/ type){","} ")" "->" type? ; tupleType - : "(" type{","}? ")" - : "(" parameter{","} ")" // tuple with named entries, the names do not affect assignment compatibility + : "#" "(" type{","}? ")" + : "#" "(" parameter{","} ")" // tuple with named entries, the names do not affect assignment compatibility ; //////////////////////////////////////// \ No newline at end of file diff --git a/grammar/src/when.grm b/grammar/src/when.grm index 864f1602161..ca814d499a2 100644 --- a/grammar/src/when.grm +++ b/grammar/src/when.grm @@ -36,7 +36,7 @@ pattern decomposerPattern : type // TODO : typeArguments will be consumed by the expression - : elvisExpression typeArguments? "@" tuplePattern + : elvisExpression typeArguments? tuplePattern ; constantPattern diff --git a/idea/src/org/jetbrains/jet/plugin/internal/codewindow/BytecodeToolwindow.java b/idea/src/org/jetbrains/jet/plugin/internal/codewindow/BytecodeToolwindow.java index 31992d30e86..b61555fb38b 100644 --- a/idea/src/org/jetbrains/jet/plugin/internal/codewindow/BytecodeToolwindow.java +++ b/idea/src/org/jetbrains/jet/plugin/internal/codewindow/BytecodeToolwindow.java @@ -27,6 +27,8 @@ import org.jetbrains.jet.codegen.ClassFileFactory; import org.jetbrains.jet.codegen.GenerationState; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.plugin.compiler.WholeProjectAnalyzerFacade; import javax.swing.*; import java.awt.*; @@ -178,8 +180,9 @@ public class BytecodeToolwindow extends JPanel { protected String generateToText(JetFile file) { GenerationState state = new GenerationState(myProject, ClassBuilderFactory.TEXT); try { - AnalyzingUtils.checkForSyntacticErrors(file); - state.compile(file); + BindingContext binding = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file); + AnalyzingUtils.throwExceptionOnErrors(binding); + state.compileCorrectNamespaces(binding, Collections.singletonList(file.getRootNamespace())); } catch (Exception e) { StringWriter out = new StringWriter(1024); e.printStackTrace(new PrintWriter(out)); diff --git a/idea/src/org/jetbrains/jet/plugin/java/JavaElementFinder.java b/idea/src/org/jetbrains/jet/plugin/java/JavaElementFinder.java index adf84a87b4c..5f11c388404 100644 --- a/idea/src/org/jetbrains/jet/plugin/java/JavaElementFinder.java +++ b/idea/src/org/jetbrains/jet/plugin/java/JavaElementFinder.java @@ -9,27 +9,50 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.ProjectRootManager; import com.intellij.openapi.util.text.StringUtil; -import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.vfs.*; import com.intellij.psi.*; import com.intellij.psi.impl.file.PsiPackageImpl; import com.intellij.psi.search.GlobalSearchScope; import com.intellij.util.SmartList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.codegen.JetTypeMapper; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.plugin.JetFileType; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; public class JavaElementFinder extends PsiElementFinder { private final Project project; private final PsiManager psiManager; + private WeakHashMap<GlobalSearchScope, List<JetFile>> jetFiles = new WeakHashMap<GlobalSearchScope, List<JetFile>>(); + public JavaElementFinder(Project project) { this.project = project; psiManager = PsiManager.getInstance(project); + + // Monitoring for files instead of collecting them each time + VirtualFileManager.getInstance().addVirtualFileListener(new VirtualFileAdapter() { + @Override + public void fileCreated(VirtualFileEvent event) { + invalidateJetFilesCache(); + } + + @Override + public void fileDeleted(VirtualFileEvent event) { + invalidateJetFilesCache(); + } + + @Override + public void fileMoved(VirtualFileMoveEvent event) { + invalidateJetFilesCache(); + } + + @Override + public void fileCopied(VirtualFileCopyEvent event) { + invalidateJetFilesCache(); + } + }); } @Override @@ -45,20 +68,17 @@ public class JavaElementFinder extends PsiElementFinder { if (qualifiedName.startsWith("java.")) return PsiClass.EMPTY_ARRAY; List<PsiClass> answer = new SmartList<PsiClass>(); - final List<JetFile> filesInScope = collectProjectFiles(project, scope); + final List<JetFile> filesInScope = collectProjectJetFiles(project, scope); for (JetFile file : filesInScope) { JetNamespace rootNamespace = file.getRootNamespace(); final String packageName = JetPsiUtil.getFQName(rootNamespace); if (packageName != null && qualifiedName.startsWith(packageName)) { if (qualifiedName.equals(fqn(packageName, "namespace"))) { - answer.add(new JetLightClass(psiManager, file, "namespace")); + answer.add(new JetLightClass(psiManager, file, qualifiedName)); } - - for (JetDeclaration declaration : rootNamespace.getDeclarations()) { - if (declaration instanceof JetClassOrObject) { - if (qualifiedName.equals(fqn(packageName, declaration.getName()))) { - answer.add(new JetLightClass(psiManager, file, declaration.getName())); - } + else { + for (JetDeclaration declaration : rootNamespace.getDeclarations()) { + scanClasses(answer, declaration, qualifiedName, packageName, file); } } } @@ -66,18 +86,48 @@ public class JavaElementFinder extends PsiElementFinder { return answer.toArray(new PsiClass[answer.size()]); } + private void scanClasses(List<PsiClass> answer, JetDeclaration declaration, String qualifiedName, String containerFqn, JetFile file) { + if (declaration instanceof JetClassOrObject) { + String localName = getLocalName(declaration); + if (localName != null) { + String fqn = fqn(containerFqn, localName); + if (qualifiedName.equals(fqn)) { + answer.add(new JetLightClass(psiManager, file, qualifiedName)); + } + else { + for (JetDeclaration child : ((JetClassOrObject) declaration).getDeclarations()) { + scanClasses(answer, child, qualifiedName, fqn, file); + } + } + } + } + else if (declaration instanceof JetClassObject) { + scanClasses(answer, ((JetClassObject) declaration).getObjectDeclaration(), qualifiedName, containerFqn, file); + } + } + + private static String getLocalName(JetDeclaration declaration) { + String given = declaration.getName(); + if (given != null) return given; + + if (declaration instanceof JetObjectDeclaration) { + return JetTypeMapper.getLocalNameForObject((JetObjectDeclaration) declaration); + } + return null; + } + @Override public Set<String> getClassNames(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { Set<String> answer = new HashSet<String>(); String packageFQN = psiPackage.getQualifiedName(); - for (JetFile psiFile : collectProjectFiles(project, GlobalSearchScope.allScope(project))) { + for (JetFile psiFile : collectProjectJetFiles(project, GlobalSearchScope.allScope(project))) { final JetNamespace rootNamespace = psiFile.getRootNamespace(); if (packageFQN.equals(JetPsiUtil.getFQName(rootNamespace))) { answer.add("namespace"); for (JetDeclaration declaration : rootNamespace.getDeclarations()) { if (declaration instanceof JetClassOrObject) { - answer.add(declaration.getName()); + answer.add(getLocalName(declaration)); } } } @@ -93,7 +143,7 @@ public class JavaElementFinder extends PsiElementFinder { @Override public PsiPackage findPackage(@NotNull String qualifiedName) { - final List<JetFile> psiFiles = collectProjectFiles(project, GlobalSearchScope.allScope(project)); + final List<JetFile> psiFiles = collectProjectJetFiles(project, GlobalSearchScope.allScope(project)); for (JetFile psiFile : psiFiles) { if (qualifiedName.equals(JetPsiUtil.getFQName(psiFile.getRootNamespace()))) { @@ -108,15 +158,15 @@ public class JavaElementFinder extends PsiElementFinder { @Override public PsiClass[] getClasses(@NotNull PsiPackage psiPackage, @NotNull GlobalSearchScope scope) { List<PsiClass> answer = new SmartList<PsiClass>(); - final List<JetFile> filesInScope = collectProjectFiles(project, scope); + final List<JetFile> filesInScope = collectProjectJetFiles(project, scope); String packageFQN = psiPackage.getQualifiedName(); for (JetFile file : filesInScope) { final JetNamespace rootNamespace = file.getRootNamespace(); if (packageFQN.equals(JetPsiUtil.getFQName(rootNamespace))) { - answer.add(new JetLightClass(psiManager, file, "namespace")); + answer.add(new JetLightClass(psiManager, file, fqn(packageFQN, "namespace"))); for (JetDeclaration declaration : rootNamespace.getDeclarations()) { if (declaration instanceof JetClassOrObject) { - answer.add(new JetLightClass(psiManager, file, declaration.getName())); + answer.add(new JetLightClass(psiManager, file, fqn(packageFQN, getLocalName(declaration)))); } } } @@ -125,31 +175,40 @@ public class JavaElementFinder extends PsiElementFinder { return answer.toArray(new PsiClass[answer.size()]); } + private synchronized void invalidateJetFilesCache() { + jetFiles.clear(); + } - private static List<JetFile> collectProjectFiles(final Project project, @NotNull final GlobalSearchScope scope) { - final List<JetFile> answer = new ArrayList<JetFile>(); + private synchronized List<JetFile> collectProjectJetFiles(final Project project, @NotNull final GlobalSearchScope scope) { + List<JetFile> cachedFiles = jetFiles.get(scope); + + if (cachedFiles == null) { + final List<JetFile> answer = new ArrayList<JetFile>(); + final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); - final FileTypeManager fileTypeManager = FileTypeManager.getInstance(); - final PsiManager psiManager = PsiManager.getInstance(project); + VirtualFile[] contentRoots = ProjectRootManager.getInstance(project).getContentRoots(); - VirtualFile[] contentRoots = ProjectRootManager.getInstance(project).getContentRoots(); - CompilerPathsEx.visitFiles(contentRoots, new CompilerPathsEx.FileVisitor() { - @Override - protected void acceptFile(VirtualFile file, String fileRoot, String filePath) { - final FileType fileType = fileTypeManager.getFileTypeByFile(file); - if (fileType != JetFileType.INSTANCE) return; + CompilerPathsEx.visitFiles(contentRoots, new CompilerPathsEx.FileVisitor() { + @Override + protected void acceptFile(VirtualFile file, String fileRoot, String filePath) { + final FileType fileType = fileTypeManager.getFileTypeByFile(file); + if (fileType != JetFileType.INSTANCE) return; - if (scope.accept(file)) { - final PsiFile psiFile = psiManager.findFile(file); - if (psiFile instanceof JetFile) { - answer.add((JetFile) psiFile); + if (scope.accept(file)) { + final PsiFile psiFile = psiManager.findFile(file); + if (psiFile instanceof JetFile) { + answer.add((JetFile) psiFile); + } } } - } - }); + }); - return answer; + cachedFiles = answer; + jetFiles.put(scope, answer); + } + + return cachedFiles; } } diff --git a/idea/src/org/jetbrains/jet/plugin/java/JetLightClass.java b/idea/src/org/jetbrains/jet/plugin/java/JetLightClass.java index 3d992837782..d1178fa335c 100644 --- a/idea/src/org/jetbrains/jet/plugin/java/JetLightClass.java +++ b/idea/src/org/jetbrains/jet/plugin/java/JetLightClass.java @@ -5,6 +5,7 @@ package org.jetbrains.jet.plugin.java; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.Key; import com.intellij.psi.*; import com.intellij.psi.impl.PsiManagerImpl; @@ -40,40 +41,49 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa private final static Key<CachedValue<PsiJavaFileStub>> JAVA_API_STUB = Key.create("JAVA_API_STUB"); private final JetFile file; - private final String className; + private final String qualifiedName; private PsiClass delegate; - public JetLightClass(PsiManager manager, JetFile file, String className) { + public JetLightClass(PsiManager manager, JetFile file, String qualifiedName) { super(manager, JetLanguage.INSTANCE); this.file = file; - this.className = className; + this.qualifiedName = qualifiedName; } @Override public String getName() { - return className; + int idx = qualifiedName.lastIndexOf('.'); + return idx > 0 ? qualifiedName.substring(idx + 1) : qualifiedName; } @Override public PsiElement copy() { - return new JetLightClass(getManager(), file, className); + return new JetLightClass(getManager(), file, qualifiedName); + } + + @Override + public PsiFile getContainingFile() { + return file; } @Override public PsiClass getDelegate() { if (delegate == null) { - delegate = findClass(className, getStub()); + delegate = findClass(qualifiedName, getStub()); + if (delegate == null) { + delegate = findClass(qualifiedName, getStub()); + } } return delegate; } - private static PsiClass findClass(String name, StubElement<?> stub) { - if (stub instanceof PsiClassStub && name.equals(((PsiClassStub) stub).getName())) { + private static PsiClass findClass(String fqn, StubElement<?> stub) { + if (stub instanceof PsiClassStub && Comparing.equal(fqn, ((PsiClassStub) stub).getQualifiedName())) { return (PsiClass) stub.getPsi(); } for (StubElement child : stub.getChildrenStubs()) { - PsiClass answer = findClass(name, child); + PsiClass answer = findClass(fqn, child); if (answer != null) return answer; } @@ -82,8 +92,7 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa @Override public String getQualifiedName() { - String fqName = JetPsiUtil.getFQName(file.getRootNamespace()); - return fqName.length() == 0 ? className : fqName + "." + className; + return qualifiedName; } private PsiJavaFileStub getStub() { @@ -163,4 +172,8 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa return answer; } + @Override + public boolean isEquivalentTo(PsiElement another) { + return another instanceof PsiClass && Comparing.equal(((PsiClass) another).getQualifiedName(), getQualifiedName()); + } } diff --git a/idea/src/org/jetbrains/jet/plugin/references/JetSimpleNameReference.java b/idea/src/org/jetbrains/jet/plugin/references/JetSimpleNameReference.java index bb955817b2c..a0a42cfeee2 100644 --- a/idea/src/org/jetbrains/jet/plugin/references/JetSimpleNameReference.java +++ b/idea/src/org/jetbrains/jet/plugin/references/JetSimpleNameReference.java @@ -1,9 +1,6 @@ package org.jetbrains.jet.plugin.references; -import com.google.common.base.Predicate; -import com.google.common.collect.Collections2; import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupElementBuilder; import com.intellij.openapi.util.Iconable; @@ -13,29 +10,17 @@ import com.intellij.psi.PsiElement; import com.intellij.util.Function; import com.intellij.util.IncorrectOperationException; import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.compiler.TipsManager; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorUtils; -import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintResolutionListener; -import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem; -import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl; -import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemSolution; -import org.jetbrains.jet.lang.resolve.scopes.JetScope; -import org.jetbrains.jet.lang.resolve.scopes.JetScopeUtils; -import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver; -import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; import org.jetbrains.jet.lang.types.JetType; -import org.jetbrains.jet.lang.types.NamespaceType; -import org.jetbrains.jet.lang.types.Variance; import org.jetbrains.jet.plugin.compiler.WholeProjectAnalyzerFacade; import org.jetbrains.jet.plugin.completion.handlers.JetFunctionInsertHandler; import org.jetbrains.jet.resolve.DescriptorRenderer; import java.util.List; -import java.util.Set; - -import static org.jetbrains.jet.lang.resolve.calls.inference.ConstraintType.RECEIVER; /** * @author yole @@ -70,33 +55,10 @@ class JetSimpleNameReference extends JetPsiReference { @NotNull @Override public Object[] getVariants() { - PsiElement parent = myExpression.getParent(); - if (parent instanceof JetQualifiedExpression) { - JetQualifiedExpression qualifiedExpression = (JetQualifiedExpression) parent; - JetExpression receiverExpression = qualifiedExpression.getReceiverExpression(); - JetFile file = (JetFile) myExpression.getContainingFile(); - BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file); + BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile( + (JetFile) myExpression.getContainingFile()); - final JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, receiverExpression); - final JetScope resolutionScope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, receiverExpression); - - if (expressionType != null && resolutionScope != null) { - return collectLookupElements(bindingContext, - includeExternalCallableExtensions(expressionType.getMemberScope().getAllDescriptors(), - resolutionScope, new ExpressionReceiver(receiverExpression, expressionType))); - } - } - else { - JetFile file = (JetFile) myExpression.getContainingFile(); - BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file); - JetScope resolutionScope = bindingContext.get(BindingContext.RESOLUTION_SCOPE, myExpression); - if (resolutionScope != null) { - return collectLookupElements(bindingContext, - excludeNotCallableExtensions(resolutionScope.getAllDescriptors(), resolutionScope)); - } - } - - return EMPTY_ARRAY; + return collectLookupElements(bindingContext, TipsManager.getReferenceVariants(myExpression, bindingContext)); } @Override @@ -105,46 +67,7 @@ class JetSimpleNameReference extends JetPsiReference { return myExpression.getReferencedNameElement().replace(element); } - private Iterable<DeclarationDescriptor> excludeNotCallableExtensions( - @NotNull Iterable<DeclarationDescriptor> descriptors, @NotNull final JetScope scope - ) { - final Set<DeclarationDescriptor> descriptorsSet = Sets.newHashSet(descriptors); - - descriptorsSet.removeAll( - Collections2.filter(JetScopeUtils.getAllExtensions(scope), new Predicate<CallableDescriptor>() { - @Override - public boolean apply(CallableDescriptor callableDescriptor) { - return !checkReceiverResolution(scope.getImplicitReceiver(), callableDescriptor); - } - })); - - return descriptorsSet; - } - - private Iterable<DeclarationDescriptor> includeExternalCallableExtensions( - @NotNull Iterable<DeclarationDescriptor> descriptors, - @NotNull final JetScope externalScope, - @NotNull final ReceiverDescriptor receiverDescriptor - ) { - // It's impossible to add extension function for namespace - if (receiverDescriptor.getType() instanceof NamespaceType) { - return descriptors; - } - - Set<DeclarationDescriptor> descriptorsSet = Sets.newHashSet(descriptors); - - descriptorsSet.addAll(Collections2.filter(JetScopeUtils.getAllExtensions(externalScope), - new Predicate<CallableDescriptor>() { - @Override - public boolean apply(CallableDescriptor callableDescriptor) { - return checkReceiverResolution(receiverDescriptor, callableDescriptor); - } - })); - - return descriptorsSet; - } - - private Object[] collectLookupElements(BindingContext bindingContext, Iterable<DeclarationDescriptor> descriptors) { + private static Object[] collectLookupElements(BindingContext bindingContext, Iterable<DeclarationDescriptor> descriptors) { List<LookupElement> result = Lists.newArrayList(); for (final DeclarationDescriptor descriptor : descriptors) { @@ -198,29 +121,4 @@ class JetSimpleNameReference extends JetPsiReference { } return result.toArray(); } - - /* - * Checks if receiver declaration could be resolved to call expected receiver. - */ - private static boolean checkReceiverResolution ( - @NotNull ReceiverDescriptor expectedReceiver, - @NotNull CallableDescriptor receiverArgument - ) { - ConstraintSystem constraintSystem = new ConstraintSystemImpl(ConstraintResolutionListener.DO_NOTHING); - for (TypeParameterDescriptor typeParameterDescriptor : receiverArgument.getTypeParameters()) { - constraintSystem.registerTypeVariable(typeParameterDescriptor, Variance.INVARIANT); - } - - ReceiverDescriptor receiverParameter = receiverArgument.getReceiverParameter(); - if (expectedReceiver.exists() && receiverParameter.exists()) { - constraintSystem.addSubtypingConstraint(RECEIVER.assertSubtyping(expectedReceiver.getType(), receiverParameter.getType())); - } - else if (expectedReceiver.exists() || receiverParameter.exists()) { - // Only one of receivers exist - return false; - } - - ConstraintSystemSolution solution = constraintSystem.solve(); - return solution.getStatus().isSuccessful(); - } } diff --git a/idea/testData/checker/Abstract.jet b/idea/testData/checker/Abstract.jet index b9ad43da2c2..e61c23954ce 100644 --- a/idea/testData/checker/Abstract.jet +++ b/idea/testData/checker/Abstract.jet @@ -1,4 +1,4 @@ -namespace abstract +package abstract class MyClass() { //properties @@ -118,7 +118,7 @@ enum class MyEnum() { abstract enum class MyAbstractEnum() {} -namespace MyNamespace { +package MyNamespace { //properties val <error>a</error>: Int val a1: Int = 1 diff --git a/idea/testData/checker/Bounds.jet b/idea/testData/checker/Bounds.jet index 8434607edf8..0ead1d76bba 100644 --- a/idea/testData/checker/Bounds.jet +++ b/idea/testData/checker/Bounds.jet @@ -1,4 +1,4 @@ -namespace boundsWithSubstitutors { +package boundsWithSubstitutors { open class A<T> class B<X : A<X>>() @@ -18,9 +18,9 @@ namespace boundsWithSubstitutors { open class A {} open class B<T : A>() - abstract class C<T : B<<error>Int</error>>, X : fun (B<<error>Char</error>>) : (B<<error>Any</error>>, B<A>)>() : B<<error>Any</error>>() { // 2 errors + abstract class C<T : B<<error>Int</error>>, X : (B<<error>Char</error>>) -> #(B<<error>Any</error>>, B<A>)>() : B<<error>Any</error>>() { // 2 errors val a = B<<error>Char</error>>() // error - abstract val x : fun (B<<error>Char</error>>) : B<<error>Any</error>> + abstract val x : (B<<error>Char</error>>) -> B<<error>Any</error>> } diff --git a/idea/testData/checker/Builders.jet b/idea/testData/checker/Builders.jet index 1d26cbbc8b2..9913cd91bff 100644 --- a/idea/testData/checker/Builders.jet +++ b/idea/testData/checker/Builders.jet @@ -1,6 +1,6 @@ import java.util.* -namespace html { +package html { abstract class Factory<T> { abstract fun create() : T @@ -14,7 +14,7 @@ namespace html { val children = ArrayList<Element>() val attributes = HashMap<String, String>() - protected fun initTag<T : Element>(init : fun T.() : Unit) : T + protected fun initTag<T : Element>(init : T.() -> Unit) : T where class object T : Factory<T>{ val tag = T.create() tag.init() @@ -34,9 +34,9 @@ namespace html { override fun create() = HTML() } - fun head(init : fun Head.() : Unit) = initTag<Head>(init) + fun head(init : Head.() -> Unit) = initTag<Head>(init) - fun body(init : fun Body.() : Unit) = initTag<Body>(init) + fun body(init : Body.() -> Unit) = initTag<Body>(init) } class Head() : TagWithText("head") { @@ -44,7 +44,7 @@ namespace html { override fun create() = Head() } - fun title(init : fun Title.() : Unit) = initTag<Title>(init) + fun title(init : Title.() -> Unit) = initTag<Title>(init) } class Title() : TagWithText("title") @@ -57,10 +57,10 @@ namespace html { override fun create() = Body() } - fun b(init : fun B.() : Unit) = initTag<B>(init) - fun p(init : fun P.() : Unit) = initTag<P>(init) - fun h1(init : fun H1.() : Unit) = initTag<H1>(init) - fun a(href : String, init : fun A.() : Unit) { + fun b(init : B.() -> Unit) = initTag<B>(init) + fun p(init : P.() -> Unit) = initTag<P>(init) + fun h1(init : H1.() -> Unit) = initTag<H1>(init) + fun a(href : String, init : A.() -> Unit) { val a = initTag<A>(init) a.href = href } @@ -77,7 +77,7 @@ namespace html { fun Map<String, String>.set(key : String, value : String) = this.put(key, value) - fun html(init : fun HTML.() : Unit) : HTML { + fun html(init : HTML.() -> Unit) : HTML { val html = HTML() html.init() return html @@ -85,7 +85,7 @@ namespace html { } -namespace foo { +package foo { import html.* diff --git a/idea/testData/checker/Casts.jet b/idea/testData/checker/Casts.jet index 385b1338535..fbd29ea06b3 100644 --- a/idea/testData/checker/Casts.jet +++ b/idea/testData/checker/Casts.jet @@ -12,5 +12,5 @@ fun test() : Unit { y <warning>as?</warning> Int : Int? x <warning>as?</warning> Int? : Int? y <warning>as?</warning> Int? : Int? - () + #() } \ No newline at end of file diff --git a/idea/testData/checker/ClassObjects.jet b/idea/testData/checker/ClassObjects.jet index 9df55d64496..08858238508 100644 --- a/idea/testData/checker/ClassObjects.jet +++ b/idea/testData/checker/ClassObjects.jet @@ -1,4 +1,4 @@ -namespace Jet86 +package Jet86 class A { class object { diff --git a/idea/testData/checker/ExtensionFunctions.jet b/idea/testData/checker/ExtensionFunctions.jet index 4076cdfff62..f08a885ce26 100644 --- a/idea/testData/checker/ExtensionFunctions.jet +++ b/idea/testData/checker/ExtensionFunctions.jet @@ -1,5 +1,5 @@ fun Int?.optint() : Unit {} -val Int?.optval : Unit = () +val Int?.optval : Unit = #() fun <T, E> T.foo(<warning>x</warning> : E, y : A) : T { y.plus(1) @@ -37,7 +37,7 @@ val <T> T.<error>foo</error> : T fun Int.foo() = this -namespace null_safety { +package null_safety { fun parse(<warning>cmd</warning>: String): Command? { return null } class Command() { diff --git a/idea/testData/checker/FunctionReturnTypes.jet b/idea/testData/checker/FunctionReturnTypes.jet index 4b123df6245..85ee309f851 100644 --- a/idea/testData/checker/FunctionReturnTypes.jet +++ b/idea/testData/checker/FunctionReturnTypes.jet @@ -4,7 +4,7 @@ fun unitEmptyInfer() {} fun unitEmpty() : Unit {} fun unitEmptyReturn() : Unit {return} fun unitIntReturn() : Unit {return <error>1</error>} -fun unitUnitReturn() : Unit {return ()} +fun unitUnitReturn() : Unit {return #()} fun test1() : Any = { <error>return</error> } fun test2() : Any = @a {return@a 1} fun test3() : Any { <error>return</error> } @@ -16,13 +16,13 @@ fun bbb() { fun foo(<warning>expr</warning>: StringBuilder): Int { val c = 'a' when(c) { - 0.chr => throw Exception("zero") - else => throw Exception("nonzero" + c) + 0.chr -> throw Exception("zero") + else -> throw Exception("nonzero" + c) } } -fun unitShort() : Unit = () +fun unitShort() : Unit = #() fun unitShortConv() : Unit = <error>1</error> fun unitShortNull() : Unit = <error>null</error> @@ -39,7 +39,7 @@ fun intFunctionLiteral(): Int = <error>{ 10 }</error> fun blockReturnUnitMismatch() : Int {<error>return</error>} fun blockReturnValueTypeMismatch() : Int {return <error>3.4</error>} fun blockReturnValueTypeMatch() : Int {return 1} -fun blockReturnValueTypeMismatchUnit() : Int {return <error>()</error>} +fun blockReturnValueTypeMismatchUnit() : Int {return <error>#()</error>} fun blockAndAndMismatch() : Int { <error>true && false</error> diff --git a/idea/testData/checker/GenericArgumentConsistency.jet b/idea/testData/checker/GenericArgumentConsistency.jet index 658b84dc9d4..aeee1d7ce3a 100644 --- a/idea/testData/checker/GenericArgumentConsistency.jet +++ b/idea/testData/checker/GenericArgumentConsistency.jet @@ -13,28 +13,28 @@ trait BB1 : BA1<Int> {} trait BB2 : <error>BA1<Any>, BB1</error> {} -namespace x { +package x { trait AA1<out T> {} trait AB1 : AA1<Int> {} trait AB3 : AA1<Comparable<Int>> {} trait AB2 : AA1<Number>, AB1, AB3 {} } -namespace x2 { +package x2 { trait AA1<out T> {} trait AB1 : AA1<Any> {} trait AB3 : AA1<Comparable<Int>> {} trait AB2 : <error>AA1<Number>, AB1, AB3</error> {} } -namespace x3 { +package x3 { trait AA1<in T> {} trait AB1 : AA1<Any> {} trait AB3 : AA1<Comparable<Int>> {} trait AB2 : AA1<Number>, AB1, AB3 {} } -namespace sx2 { +package sx2 { trait AA1<in T> {} trait AB1 : AA1<Int> {} trait AB3 : AA1<Comparable<Int>> {} diff --git a/idea/testData/checker/MultipleBounds.jet b/idea/testData/checker/MultipleBounds.jet index 2ecb95b9e6e..60b5c69561e 100644 --- a/idea/testData/checker/MultipleBounds.jet +++ b/idea/testData/checker/MultipleBounds.jet @@ -1,4 +1,4 @@ -namespace Jet87 +package Jet87 open class A() { fun foo() : Int = 1 diff --git a/idea/testData/checker/NamespaceAsExpression.jet b/idea/testData/checker/NamespaceAsExpression.jet index 73d53d57808..8c232a087b4 100644 --- a/idea/testData/checker/NamespaceAsExpression.jet +++ b/idea/testData/checker/NamespaceAsExpression.jet @@ -1,8 +1,8 @@ -namespace root +package root -namespace a { +package a { } val x = <error>a</error> -val y2 = <error>namespace</error> +val y2 = <error>package</error> diff --git a/idea/testData/checker/NamespaceQualified.jet b/idea/testData/checker/NamespaceQualified.jet index 7b63689a4f8..6930e945e8d 100644 --- a/idea/testData/checker/NamespaceQualified.jet +++ b/idea/testData/checker/NamespaceQualified.jet @@ -1,6 +1,6 @@ -namespace foobar +package foobar -namespace a { +package a { import java.* val a : util.List<Int>? = null @@ -12,7 +12,7 @@ abstract class Foo<T>() { abstract val x : T<Int> } -namespace a { +package a { import java.util.* val b : List<Int>? = a diff --git a/idea/testData/checker/Nullability.jet b/idea/testData/checker/Nullability.jet index 8479b364cd8..8f2eaa9e6c7 100644 --- a/idea/testData/checker/Nullability.jet +++ b/idea/testData/checker/Nullability.jet @@ -38,28 +38,28 @@ fun test() { out.println(); } - if (out == null || out.println(0) == ()) { + if (out == null || out.println(0) == #()) { out?.println(1) } else { out.println(2) } - if (out != null && out.println() == ()) { + if (out != null && out.println() == #()) { out.println(); } else { out?.println(); } - if (out == null || out != null && out.println() == ()) { + if (out == null || out != null && out.println() == #()) { out?.println(); } else { out.println(); } - if (1 == 2 || out != null && out.println(1) == ()) { + if (1 == 2 || out != null && out.println(1) == #()) { out?.println(2); } else { @@ -94,28 +94,28 @@ fun test() { out.println(); } - if (out == null || out.println(0) == ()) { + if (out == null || out.println(0) == #()) { out?.println(1) } else { out.println(2) } - if (out != null && out.println() == ()) { + if (out != null && out.println() == #()) { out.println(); } else { out?.println(); } - if (out == null || out != null && out.println() == ()) { + if (out == null || out != null && out.println() == #()) { out?.println(); } else { out.println(); } - if (1 == 2 || out != null && out.println(1) == ()) { + if (1 == 2 || out != null && out.println(1) == #()) { out?.println(2); } else { diff --git a/idea/testData/checker/Objects.jet b/idea/testData/checker/Objects.jet index a619e1c22d6..9e03a5cc535 100644 --- a/idea/testData/checker/Objects.jet +++ b/idea/testData/checker/Objects.jet @@ -1,4 +1,4 @@ -namespace toplevelObjectDeclarations { +package toplevelObjectDeclarations { open class Foo(y : Int) { open fun foo() : Int = 1 } @@ -28,7 +28,7 @@ namespace toplevelObjectDeclarations { val z = y.foo() } -namespace nestedObejcts { +package nestedObejcts { object A { val b = B val d = A.B.A @@ -58,7 +58,7 @@ namespace nestedObejcts { val e = B.<error>A</error>.B } -namespace localObjects { +package localObjects { object A { val x : Int = 0 } diff --git a/idea/testData/checker/Override.jet b/idea/testData/checker/Override.jet index 0ba1406e651..0255c1ca816 100644 --- a/idea/testData/checker/Override.jet +++ b/idea/testData/checker/Override.jet @@ -1,6 +1,6 @@ -namespace override +package override -namespace normal { +package normal { trait MyTrait { fun foo() } @@ -37,7 +37,7 @@ namespace normal { } } -namespace generics { +package generics { trait MyTrait<T> { fun foo(t: T) : T } diff --git a/idea/testData/checker/QualifiedExpressions.jet b/idea/testData/checker/QualifiedExpressions.jet index 351e15e0e4e..73a2c4c677e 100644 --- a/idea/testData/checker/QualifiedExpressions.jet +++ b/idea/testData/checker/QualifiedExpressions.jet @@ -1,4 +1,4 @@ -namespace qualified_expressions +package qualified_expressions fun test(s: String?) { val <warning>a</warning>: Int = <error>s?.length</error> diff --git a/idea/testData/checker/QualifiedThis.jet b/idea/testData/checker/QualifiedThis.jet index c0825aa37c1..dd5e5f9979e 100644 --- a/idea/testData/checker/QualifiedThis.jet +++ b/idea/testData/checker/QualifiedThis.jet @@ -21,7 +21,7 @@ fun foo1() : Unit { this<error>@a</error> } -namespace closures { +package closures { class A(val a:Int) { class B() { @@ -31,10 +31,10 @@ namespace closures { val Int.xx = this : Int fun Char.xx() : Any { this : Char - val <warning>a</warning> = {Double.() => this : Double + this@xx : Char} - val <warning>b</warning> = @a{Double.() => this@a : Double + this@xx : Char} - val <warning>c</warning> = @a{() => <error>this@a</error> + this@xx : Char} - return (@a{Double.() => this@a : Double + this@xx : Char}) + val <warning>a</warning> = {Double.() -> this : Double + this@xx : Char} + val <warning>b</warning> = @a{Double.() -> this@a : Double + this@xx : Char} + val <warning>c</warning> = @a{() -> <error>this@a</error> + this@xx : Char} + return (@a{Double.() -> this@a : Double + this@xx : Char}) } } } diff --git a/idea/testData/checker/RecursiveTypeInference.jet b/idea/testData/checker/RecursiveTypeInference.jet index d1e8b6f6c62..cbbc837604e 100644 --- a/idea/testData/checker/RecursiveTypeInference.jet +++ b/idea/testData/checker/RecursiveTypeInference.jet @@ -1,16 +1,16 @@ -namespace a { +package a { val foo = bar() fun bar() = <error descr="[TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM] Type checking has run into a recursive problem">foo</error> } -namespace b { +package b { fun foo() = bar() fun bar() = <error descr="[TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM] Type checking has run into a recursive problem">foo()</error> } -namespace c { +package c { fun bazz() = bar() fun foo() = <error descr="[TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM] Type checking has run into a recursive problem">bazz()</error> @@ -18,21 +18,21 @@ namespace c { fun bar() = foo() } -namespace ok { +package ok { - namespace a { + package a { val foo = bar() fun bar() : Int = foo } - namespace b { + package b { fun foo() : Int = bar() fun bar() = foo() } - namespace c { + package c { fun bazz() = bar() fun foo() : Int = bazz() diff --git a/idea/testData/checker/Redeclarations.jet b/idea/testData/checker/Redeclarations.jet index 6998ada29eb..b5fbb68145e 100644 --- a/idea/testData/checker/Redeclarations.jet +++ b/idea/testData/checker/Redeclarations.jet @@ -1,11 +1,11 @@ -namespace redeclarations { +package redeclarations { object <error>A</error> { val x : Int = 0 val A = 1 } - namespace <error>A</error> { + package <error>A</error> { class A {} } diff --git a/idea/testData/checker/ResolveToJava.jet b/idea/testData/checker/ResolveToJava.jet index 6dfda6ac032..34585040f7f 100644 --- a/idea/testData/checker/ResolveToJava.jet +++ b/idea/testData/checker/ResolveToJava.jet @@ -47,6 +47,6 @@ fun test(<warning>l</warning> : java.util.List<Int>) { } -namespace xxx { +package xxx { import java.lang.Class; } diff --git a/idea/testData/checker/StringTemplates.jet b/idea/testData/checker/StringTemplates.jet index 9c00360b365..ab2b794ceb6 100644 --- a/idea/testData/checker/StringTemplates.jet +++ b/idea/testData/checker/StringTemplates.jet @@ -3,8 +3,8 @@ fun demo() { val a = "" val asd = 1 val bar = 5 - fun map(f : fun () : Any?) : Int = 1 - fun buzz(f : fun () : Any?) : Int = 1 + fun map(f : () -> Any?) : Int = 1 + fun buzz(f : () -> Any?) : Int = 1 val sdf = 1 val foo = 3; "$abc" diff --git a/idea/testData/checker/Unresolved.jet b/idea/testData/checker/Unresolved.jet index a4b85b6b54a..b9407e489c4 100644 --- a/idea/testData/checker/Unresolved.jet +++ b/idea/testData/checker/Unresolved.jet @@ -1,8 +1,8 @@ -namespace unresolved +package unresolved fun testGenericArgumentsCount() { - val <warning>p1</warning>: Tuple2<error><Int></error> = (2, 2) - val <warning>p2</warning>: <error>Tuple2</error> = (2, 2) + val <warning>p1</warning>: Tuple2<error><Int></error> = #(2, 2) + val <warning>p2</warning>: <error>Tuple2</error> = #(2, 2) } fun testUnresolved() { @@ -16,8 +16,8 @@ fun testUnresolved() { s.<error>foo</error>() when(<error>a</error>) { - is Int => <error>a</error> - is String => <error>a</error> + is Int -> <error>a</error> + is String -> <error>a</error> } //TODO diff --git a/idea/testData/checker/Variance.jet b/idea/testData/checker/Variance.jet index 756214a3145..42f2903a26c 100644 --- a/idea/testData/checker/Variance.jet +++ b/idea/testData/checker/Variance.jet @@ -1,4 +1,4 @@ -namespace variance +package variance abstract class Consumer<in T> {} diff --git a/idea/testData/checker/When.jet b/idea/testData/checker/When.jet index c9e799dd41d..2362c95f494 100644 --- a/idea/testData/checker/When.jet +++ b/idea/testData/checker/When.jet @@ -4,25 +4,25 @@ fun foo() : Int { val s = "" val x = 1 when (x) { - is * => 1 - is <error>String</error> => 1 - !is Int => 1 - is Any? => 1 - <error>s</error> => 1 - 1 => 1 - 1 + <error>a</error> => 1 - in 1..<error>a</error> => 1 - !in 1..<error>a</error> => 1 - // Commented for KT-621 .<!error>a</!error> => 1 - // Commented for KT-621 .equals(1).<!error>a</!error> => 1 - // Commented for KT-621 <!warning>?.</!warning>equals(1) => 1 - else => 1 + is * -> 1 + is <error>String</error> -> 1 + !is Int -> 1 + is Any? -> 1 + <error>s</error> -> 1 + 1 -> 1 + 1 + <error>a</error> -> 1 + in 1..<error>a</error> -> 1 + !in 1..<error>a</error> -> 1 + // Commented for KT-621 .<!error>a</!error> -> 1 + // Commented for KT-621 .equals(1).<!error>a</!error> -> 1 + // Commented for KT-621 <!warning>?.</!warning>equals(1) -> 1 + else -> 1 } // Commented for KT-621 // return when (<!warning>x</!warning>?:null) { - // <!error>.</!error>foo() => 1 - // ?.equals(1).equals(2) => 1 + // <!error>.</!error>foo() -> 1 + // ?.equals(1).equals(2) -> 1 // } return 0 } @@ -34,33 +34,33 @@ fun test() { val s = ""; when (x) { - <error>s</error> => 1 - is <error>""</error> => 1 - x => 1 - is 1 => 1 - is <error>(1, 1)</error> => 1 + <error>s</error> -> 1 + is <error>""</error> -> 1 + x -> 1 + is 1 -> 1 + is <error>#(1, 1)</error> -> 1 } - val z = (1, 1) + val z = #(1, 1) when (z) { - is (*, *) => 1 - is (*, 1) => 1 - is (1, 1) => 1 - is (1, <error>"1"</error>) => 1 - is <error>(1, "1", *)</error> => 1 - is boo @ (1, <error>"a"</error>, *) => 1 - is boo @ <error>(1, *)</error> => 1 + is #(*, *) -> 1 + is #(*, 1) -> 1 + is #(1, 1) -> 1 + is #(1, <error>"1"</error>) -> 1 + is <error>#(1, "1", *)</error> -> 1 + is boo #(1, <error>"a"</error>, *) -> 1 + is boo <error>#(1, *)</error> -> 1 } when (z) { - <error>else => 1</error> - (1, 1) => 2 + <error>else -> 1</error> + #(1, 1) -> 2 } when (z) { - else => 1 + else -> 1 } } -val (Int, Int).boo : (Int, Int, Int) = (1, 1, 1) +val #(Int, Int).boo : #(Int, Int, Int) = #(1, 1, 1) diff --git a/idea/testData/checker/infos/Autocasts.jet b/idea/testData/checker/infos/Autocasts.jet index a5b716d9c05..fa45c29c3ad 100644 --- a/idea/testData/checker/infos/Autocasts.jet +++ b/idea/testData/checker/infos/Autocasts.jet @@ -19,7 +19,7 @@ fun f9(a : A?) { a?.<error descr="Unresolved reference: bar">bar</error>() a?.foo() } - if (!(a is B) || <info descr="Automatically cast to B">a</info>.bar() == ()) { + if (!(a is B) || <info descr="Automatically cast to B">a</info>.bar() == #()) { a?.<error descr="Unresolved reference: bar">bar</error>() } if (!(a is B)) { @@ -52,24 +52,24 @@ fun f101(a : A?) { fun f11(a : A?) { when (a) { - is B => <info descr="Automatically cast to B">a</info>.bar() - is A => <info descr="Automatically cast to A">a</info>.foo() - is Any => <info descr="Automatically cast to A">a</info>.foo() - is Any? => a.<error descr="Unresolved reference: bar">bar</error>() - else => a?.foo() + is B -> <info descr="Automatically cast to B">a</info>.bar() + is A -> <info descr="Automatically cast to A">a</info>.foo() + is Any -> <info descr="Automatically cast to A">a</info>.foo() + is Any? -> a.<error descr="Unresolved reference: bar">bar</error>() + else -> a?.foo() } } fun f12(a : A?) { when (a) { - is B => <info descr="Automatically cast to B">a</info>.bar() - is A => <info descr="Automatically cast to A">a</info>.foo() - is Any => <info descr="Automatically cast to A">a</info>.foo(); - is Any? => a.<error descr="Unresolved reference: bar">bar</error>() - is val c : <error descr="[TYPE_MISMATCH_IN_BINDING_PATTERN] B must be a supertype of A?. Use is to match against B">B</error> => c.foo() - is val c is C => <info descr="Automatically cast to C">c</info>.bar() - is val c is C => <info descr="Automatically cast to C">a</info>.bar() - else => a?.foo() + is B -> <info descr="Automatically cast to B">a</info>.bar() + is A -> <info descr="Automatically cast to A">a</info>.foo() + is Any -> <info descr="Automatically cast to A">a</info>.foo(); + is Any? -> a.<error descr="Unresolved reference: bar">bar</error>() + is val c : <error descr="[TYPE_MISMATCH_IN_BINDING_PATTERN] B must be a supertype of A?. Use is to match against B">B</error> -> c.foo() + is val c is C -> <info descr="Automatically cast to C">c</info>.bar() + is val c is C -> <info descr="Automatically cast to C">a</info>.bar() + else -> a?.foo() } if (a is val b) { @@ -104,7 +104,7 @@ fun f13(a : A?) { } a?.foo() - if (a is val c is B && <info descr="Automatically cast to A">a</info>.foo() == () && <info descr="Automatically cast to B">c</info>.bar() == ()) { + if (a is val c is B && <info descr="Automatically cast to A">a</info>.foo() == #() && <info descr="Automatically cast to B">c</info>.bar() == #()) { <info descr="Automatically cast to A">c</info>.foo() <info descr="Automatically cast to B">c</info>.bar() } @@ -152,18 +152,18 @@ fun getStringLength(obj : Any) : Char? { fun toInt(i: Int?): Int = if (i != null) <info descr="Automatically cast to Int">i</info> else 0 fun illegalWhenBody(a: Any): Int = when(a) { - is Int => <info descr="Automatically cast to Int">a</info> - is String => <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error> + is Int -> <info descr="Automatically cast to Int">a</info> + is String -> <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error> } fun illegalWhenBlock(a: Any): Int { when(a) { - is Int => return <info descr="Automatically cast to Int">a</info> - is String => return <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error> + is Int -> return <info descr="Automatically cast to Int">a</info> + is String -> return <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error> } } fun declarations(a: Any?) { if (a is String) { - val <warning>p4</warning>: (Int, String) = (2, <info descr="Automatically cast to String">a</info>) + val <warning>p4</warning>: #(Int, String) = #(2, <info descr="Automatically cast to String">a</info>) } if (a is String?) { if (a != null) { @@ -184,21 +184,21 @@ fun vars(a: Any?) { } fun tuples(a: Any?) { if (a != null) { - val <warning>s</warning>: (Any, String) = (<info descr="Automatically cast to Any">a</info>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>) + val <warning>s</warning>: #(Any, String) = #(<info descr="Automatically cast to Any">a</info>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>) } if (a is String) { - val <warning>s</warning>: (Any, String) = (<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>) + val <warning>s</warning>: #(Any, String) = #(<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>) } - fun illegalTupleReturnType(): (Any, String) = (<error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Any was expected">a</error>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>) + fun illegalTupleReturnType(): #(Any, String) = #(<error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Any was expected">a</error>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>) if (a is String) { - fun legalTupleReturnType(): (Any, String) = (<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>) + fun legalTupleReturnType(): #(Any, String) = #(<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>) } val <warning>illegalFunctionLiteral</warning>: Function0<Int> = <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Function0<Any?> but Function0<Int> was expected">{ <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> }</error> - val <warning>illegalReturnValueInFunctionLiteral</warning>: Function0<Int> = { (): Int => <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> } + val <warning>illegalReturnValueInFunctionLiteral</warning>: Function0<Int> = { (): Int -> <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> } if (a is Int) { val <warning>legalFunctionLiteral</warning>: Function0<Int> = { <info descr="Automatically cast to Int">a</info> } - val <warning>alsoLegalFunctionLiteral</warning>: Function0<Int> = { (): Int => <info descr="Automatically cast to Int">a</info> } + val <warning>alsoLegalFunctionLiteral</warning>: Function0<Int> = { (): Int -> <info descr="Automatically cast to Int">a</info> } } } fun returnFunctionLiteralBlock(a: Any?): Function0<Int> { @@ -206,12 +206,12 @@ fun returnFunctionLiteralBlock(a: Any?): Function0<Int> { else return { 1 } } fun returnFunctionLiteral(a: Any?): Function0<Int> = - if (a is Int) { (): Int => <info descr="Automatically cast to Int">a</info> } - else { () => 1 } + if (a is Int) { (): Int -> <info descr="Automatically cast to Int">a</info> } + else { () -> 1 } -fun illegalTupleReturnType(a: Any): (Any, String) = (a, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but String was expected">a</error>) +fun illegalTupleReturnType(a: Any): #(Any, String) = #(a, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but String was expected">a</error>) -fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => <info descr="Automatically cast to String">a</info>; else => "something" } +fun declarationInsidePattern(x: #(Any, Any)): String = when(x) { is #(val a is String, *) -> <info descr="Automatically cast to String">a</info>; else -> "something" } fun mergeAutocasts(a: Any?) { if (a is String || a is Int) { @@ -222,7 +222,7 @@ fun mergeAutocasts(a: Any?) { a.<error descr="Unresolved reference: compareTo">compareTo</error>("") } when (a) { - is String, is Any => a.<error descr="Unresolved reference: compareTo">compareTo</error>("") + is String, is Any -> a.<error descr="Unresolved reference: compareTo">compareTo</error>("") } if (a is String && a is Any) { val <warning>i</warning>: Int = <info descr="Automatically cast to String">a</info>.compareTo("") diff --git a/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.jet b/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.jet index 813be88472a..af4fa396431 100644 --- a/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.jet +++ b/idea/testData/checker/regression/AmbiguityOnLazyTypeComputation.jet @@ -1,7 +1,7 @@ // One of the two passes is making a scope and turning vals into functions // See KT-76 -namespace x +package x val b : Foo = Foo() val a1 = b.compareTo(2) diff --git a/idea/testData/checker/regression/CoercionToUnit.jet b/idea/testData/checker/regression/CoercionToUnit.jet index f02143657f7..976db07f352 100644 --- a/idea/testData/checker/regression/CoercionToUnit.jet +++ b/idea/testData/checker/regression/CoercionToUnit.jet @@ -2,7 +2,7 @@ fun foo(<warning>u</warning> : Unit) : Int = 1 fun test() : Int { foo(<error>1</error>) - val <warning>a</warning> : fun() : Unit = { + val <warning>a</warning> : () -> Unit = { foo(<error>1</error>) } return 1 diff --git a/idea/testData/checker/regression/Jet121.jet b/idea/testData/checker/regression/Jet121.jet index fc29dfe5293..4dda2b95c51 100644 --- a/idea/testData/checker/regression/Jet121.jet +++ b/idea/testData/checker/regression/Jet121.jet @@ -1,6 +1,6 @@ -namespace jet121 { +package jet121 { fun box() : String { - val answer = apply("OK") { String.() : Int => + val answer = apply("OK") { String.() : Int -> get(0) length } @@ -8,7 +8,7 @@ namespace jet121 { return if (answer == 2) "OK" else "FAIL" } - fun apply(arg:String, f : fun String.() : Int) : Int { + fun apply(arg:String, f : String.() -> Int) : Int { return arg.f() } } \ No newline at end of file diff --git a/idea/testData/checker/regression/Jet124.jet b/idea/testData/checker/regression/Jet124.jet index 317b1438f41..5e8088b3e08 100644 --- a/idea/testData/checker/regression/Jet124.jet +++ b/idea/testData/checker/regression/Jet124.jet @@ -1,8 +1,8 @@ -fun foo1() : fun (Int) : Int = { (x: Int) => x } +fun foo1() : (Int) -> Int = { (x: Int) -> x } fun foo() { - val h : fun (Int) : Int = foo1(); + val h : (Int) -> Int = foo1(); h(1) - val m : fun (Int) : Int = {(a : Int) => 1}//foo1() + val m : (Int) -> Int = {(a : Int) -> 1}//foo1() m(1) } \ No newline at end of file diff --git a/idea/testData/checker/regression/Jet169.jet b/idea/testData/checker/regression/Jet169.jet index 0ba52f8e3cb..35ace683078 100644 --- a/idea/testData/checker/regression/Jet169.jet +++ b/idea/testData/checker/regression/Jet169.jet @@ -1,8 +1,8 @@ fun set(<warning>key</warning> : String, <warning>value</warning> : String) { val a : String? = "" when (a) { - "" => a<error>.</error>get(0) - is String, is Any => a.compareTo("") - else => a.toString() + "" -> a<error>.</error>get(0) + is String, is Any -> a.compareTo("") + else -> a.toString() } } diff --git a/idea/testData/completion/basic/ExtendQualifiedClassName.kt b/idea/testData/completion/basic/ExtendQualifiedClassName.kt index da13ff4b8c0..64ef3e7b843 100644 --- a/idea/testData/completion/basic/ExtendQualifiedClassName.kt +++ b/idea/testData/completion/basic/ExtendQualifiedClassName.kt @@ -1,4 +1,4 @@ -namespace Test.SubTest.AnotherTest +package Test.SubTest.AnotherTest open class TestClass { } diff --git a/idea/testData/completion/basic/FromImports.kt b/idea/testData/completion/basic/FromImports.kt index 893b30bbadb..440ab53b49c 100644 --- a/idea/testData/completion/basic/FromImports.kt +++ b/idea/testData/completion/basic/FromImports.kt @@ -1,4 +1,4 @@ -namespace Tests +package Tests import java.util.* diff --git a/idea/testData/completion/basic/JavaPackage.kt b/idea/testData/completion/basic/JavaPackage.kt index 59e1767100b..d18da32f63e 100644 --- a/idea/testData/completion/basic/JavaPackage.kt +++ b/idea/testData/completion/basic/JavaPackage.kt @@ -1,4 +1,4 @@ -namespace Tests +package Tests class A : java.<caret> diff --git a/idea/testData/completion/basic/OverloadFunctions.kt b/idea/testData/completion/basic/OverloadFunctions.kt index 757a0c0f8ce..df91ec7b5f9 100644 --- a/idea/testData/completion/basic/OverloadFunctions.kt +++ b/idea/testData/completion/basic/OverloadFunctions.kt @@ -1,4 +1,4 @@ -namespace Test.MyTest +package Test.MyTest class A { class object { diff --git a/idea/testData/completion/basic/SubpackageInFun.kt b/idea/testData/completion/basic/SubpackageInFun.kt index 52a9b1022e7..e7a281c7a73 100644 --- a/idea/testData/completion/basic/SubpackageInFun.kt +++ b/idea/testData/completion/basic/SubpackageInFun.kt @@ -1,4 +1,4 @@ -namespace Test.MyTest +package Test.MyTest fun test() { Test.<caret> diff --git a/idea/testData/completion/basic/extensions/ExtensionInExtendedClass.kt b/idea/testData/completion/basic/extensions/ExtensionInExtendedClass.kt index d4f4b62aa8a..60b9e51fa75 100644 --- a/idea/testData/completion/basic/extensions/ExtensionInExtendedClass.kt +++ b/idea/testData/completion/basic/extensions/ExtensionInExtendedClass.kt @@ -1,4 +1,4 @@ -namespace Test +package Test class Some() { fun methodName() { diff --git a/idea/testData/completion/handlers/SingleBrackets.kt b/idea/testData/completion/handlers/SingleBrackets.kt index 1593bc01db3..488fc2488a4 100644 --- a/idea/testData/completion/handlers/SingleBrackets.kt +++ b/idea/testData/completion/handlers/SingleBrackets.kt @@ -1,4 +1,4 @@ -namespace Test.MyTest +package Test.MyTest class A { class object { diff --git a/idea/testData/completion/handlers/SingleBrackets.kt.after b/idea/testData/completion/handlers/SingleBrackets.kt.after index 94e927574b8..e27f5c9b103 100644 --- a/idea/testData/completion/handlers/SingleBrackets.kt.after +++ b/idea/testData/completion/handlers/SingleBrackets.kt.after @@ -1,4 +1,4 @@ -namespace Test.MyTest +package Test.MyTest class A { class object { diff --git a/idea/testData/javaFacade/classObject.kt b/idea/testData/javaFacade/classObject.kt new file mode 100644 index 00000000000..3f78d7c9c89 --- /dev/null +++ b/idea/testData/javaFacade/classObject.kt @@ -0,0 +1,7 @@ +package foo + +class TheClass() { + class object { + val out = System.out + } +} \ No newline at end of file diff --git a/idea/testData/javaFacade/innerClass.kt b/idea/testData/javaFacade/innerClass.kt new file mode 100644 index 00000000000..45afe31a5b9 --- /dev/null +++ b/idea/testData/javaFacade/innerClass.kt @@ -0,0 +1,9 @@ +package foo + +class Outer() { + class Inner() { + fun innerFun() { + + } + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/abstract/afterNonMemberFunctionNoBody.kt b/idea/testData/quickfix/abstract/afterNonMemberFunctionNoBody.kt index ebbf78c7564..f54348ace84 100644 --- a/idea/testData/quickfix/abstract/afterNonMemberFunctionNoBody.kt +++ b/idea/testData/quickfix/abstract/afterNonMemberFunctionNoBody.kt @@ -1,5 +1,5 @@ // "Add function body" "true" -namespace a { +package a { fun <caret>foo() { } } \ No newline at end of file diff --git a/idea/testData/quickfix/abstract/beforeNonMemberFunctionNoBody.kt b/idea/testData/quickfix/abstract/beforeNonMemberFunctionNoBody.kt index 01680ddc843..666e6d6069f 100644 --- a/idea/testData/quickfix/abstract/beforeNonMemberFunctionNoBody.kt +++ b/idea/testData/quickfix/abstract/beforeNonMemberFunctionNoBody.kt @@ -1,4 +1,4 @@ // "Add function body" "true" -namespace a { +package a { fun <caret>foo() } \ No newline at end of file diff --git a/idea/testData/quickfix/addPrimaryConstructor/afterAddPrimaryConstructor1.kt b/idea/testData/quickfix/addPrimaryConstructor/afterAddPrimaryConstructor1.kt index bf7a9a22a5d..bd2c6df77c2 100644 --- a/idea/testData/quickfix/addPrimaryConstructor/afterAddPrimaryConstructor1.kt +++ b/idea/testData/quickfix/addPrimaryConstructor/afterAddPrimaryConstructor1.kt @@ -1,5 +1,5 @@ // "Add primary constructor to A" "true" -namespace a +package a class A() { var i : Int = <caret>1 diff --git a/idea/testData/quickfix/addPrimaryConstructor/afterAddPrimaryConstructor2.kt b/idea/testData/quickfix/addPrimaryConstructor/afterAddPrimaryConstructor2.kt index 71ddc338e46..1f1b7863e7f 100644 --- a/idea/testData/quickfix/addPrimaryConstructor/afterAddPrimaryConstructor2.kt +++ b/idea/testData/quickfix/addPrimaryConstructor/afterAddPrimaryConstructor2.kt @@ -1,5 +1,5 @@ // "Add primary constructor to A" "true" -namespace a +package a class A<caret>() { var i : Int = 1 diff --git a/idea/testData/quickfix/addPrimaryConstructor/beforeAddPrimaryConstructor1.kt b/idea/testData/quickfix/addPrimaryConstructor/beforeAddPrimaryConstructor1.kt index 8d4c44c292f..752701ac4a7 100644 --- a/idea/testData/quickfix/addPrimaryConstructor/beforeAddPrimaryConstructor1.kt +++ b/idea/testData/quickfix/addPrimaryConstructor/beforeAddPrimaryConstructor1.kt @@ -1,5 +1,5 @@ // "Add primary constructor to A" "true" -namespace a +package a class A { var i : Int = <caret>1 diff --git a/idea/testData/quickfix/addPrimaryConstructor/beforeAddPrimaryConstructor2.kt b/idea/testData/quickfix/addPrimaryConstructor/beforeAddPrimaryConstructor2.kt index dd6ce1b5889..09b0f0ca9c0 100644 --- a/idea/testData/quickfix/addPrimaryConstructor/beforeAddPrimaryConstructor2.kt +++ b/idea/testData/quickfix/addPrimaryConstructor/beforeAddPrimaryConstructor2.kt @@ -1,5 +1,5 @@ // "Add primary constructor to A" "true" -namespace a +package a class A<caret> { var i : Int = 1 diff --git a/idea/testData/quickfix/autoImports/afterImportSingleFile.kt b/idea/testData/quickfix/autoImports/afterImportSingleFile.kt index ad4e241e1f3..56c6f85e48a 100644 --- a/idea/testData/quickfix/autoImports/afterImportSingleFile.kt +++ b/idea/testData/quickfix/autoImports/afterImportSingleFile.kt @@ -1,5 +1,5 @@ // "Import Class" "true" -namespace a +package a import a.b.M @@ -7,6 +7,6 @@ fun test() { val v = M } -namespace b { +package b { class M() { } } \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/beforeImportSingleFile.kt b/idea/testData/quickfix/autoImports/beforeImportSingleFile.kt index 06fcebf9b9a..8f5fba3bc80 100644 --- a/idea/testData/quickfix/autoImports/beforeImportSingleFile.kt +++ b/idea/testData/quickfix/autoImports/beforeImportSingleFile.kt @@ -1,10 +1,10 @@ // "Import Class" "true" -namespace a +package a fun test() { val v = <caret>M } -namespace b { +package b { class M() { } } \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/beforeKotlinImport.Data.Sample.kt b/idea/testData/quickfix/autoImports/beforeKotlinImport.Data.Sample.kt index 24ab2e94d15..bcc3f916063 100644 --- a/idea/testData/quickfix/autoImports/beforeKotlinImport.Data.Sample.kt +++ b/idea/testData/quickfix/autoImports/beforeKotlinImport.Data.Sample.kt @@ -1,3 +1,3 @@ -namespace TestData +package TestData class TestSample() {} \ No newline at end of file diff --git a/idea/testData/quickfix/classImport/afterHasThisImport.kt b/idea/testData/quickfix/classImport/afterHasThisImport.kt index 097dd252598..0a46e672869 100644 --- a/idea/testData/quickfix/classImport/afterHasThisImport.kt +++ b/idea/testData/quickfix/classImport/afterHasThisImport.kt @@ -1,9 +1,9 @@ // "Remove initializer from property" "true" -namespace a +package a import java.util.Collections -namespace b { +package b { import java.util.List diff --git a/idea/testData/quickfix/classImport/afterNoImportJavaLang.kt b/idea/testData/quickfix/classImport/afterNoImportJavaLang.kt index 1ffb2769998..c730bfb7a63 100644 --- a/idea/testData/quickfix/classImport/afterNoImportJavaLang.kt +++ b/idea/testData/quickfix/classImport/afterNoImportJavaLang.kt @@ -1,5 +1,5 @@ // "Remove initializer from property" "true" -namespace a +package a class M { trait A { diff --git a/idea/testData/quickfix/classImport/afterNoImportJetStandard.kt b/idea/testData/quickfix/classImport/afterNoImportJetStandard.kt index dc3f621c67e..042f74ac7cb 100644 --- a/idea/testData/quickfix/classImport/afterNoImportJetStandard.kt +++ b/idea/testData/quickfix/classImport/afterNoImportJetStandard.kt @@ -1,5 +1,5 @@ // "Remove initializer from property" "true" -namespace a +package a class M { trait A { diff --git a/idea/testData/quickfix/classImport/afterToImport1.kt b/idea/testData/quickfix/classImport/afterToImport1.kt index 60d9ffb0c1b..36072dbb45c 100644 --- a/idea/testData/quickfix/classImport/afterToImport1.kt +++ b/idea/testData/quickfix/classImport/afterToImport1.kt @@ -1,5 +1,5 @@ // "Remove initializer from property" "true" -namespace a +package a import java.util.Collections import java.util.List diff --git a/idea/testData/quickfix/classImport/afterToImport2.kt b/idea/testData/quickfix/classImport/afterToImport2.kt index 60556ccd964..dd84c5795bd 100644 --- a/idea/testData/quickfix/classImport/afterToImport2.kt +++ b/idea/testData/quickfix/classImport/afterToImport2.kt @@ -1,9 +1,9 @@ // "Remove initializer from property" "true" -namespace a +package a import java.util.Collections -namespace b { +package b { import java.util.List diff --git a/idea/testData/quickfix/classImport/beforeHasThisImport.kt b/idea/testData/quickfix/classImport/beforeHasThisImport.kt index bfcc05e9b9c..284c4ad6202 100644 --- a/idea/testData/quickfix/classImport/beforeHasThisImport.kt +++ b/idea/testData/quickfix/classImport/beforeHasThisImport.kt @@ -1,9 +1,9 @@ // "Remove initializer from property" "true" -namespace a +package a import java.util.Collections -namespace b { +package b { import java.util.List diff --git a/idea/testData/quickfix/classImport/beforeNoImportJavaLang.kt b/idea/testData/quickfix/classImport/beforeNoImportJavaLang.kt index d81efa4eaa8..f38d36e5450 100644 --- a/idea/testData/quickfix/classImport/beforeNoImportJavaLang.kt +++ b/idea/testData/quickfix/classImport/beforeNoImportJavaLang.kt @@ -1,5 +1,5 @@ // "Remove initializer from property" "true" -namespace a +package a class M { trait A { diff --git a/idea/testData/quickfix/classImport/beforeNoImportJetStandard.kt b/idea/testData/quickfix/classImport/beforeNoImportJetStandard.kt index 320776e668a..95e1c419fb4 100644 --- a/idea/testData/quickfix/classImport/beforeNoImportJetStandard.kt +++ b/idea/testData/quickfix/classImport/beforeNoImportJetStandard.kt @@ -1,5 +1,5 @@ // "Remove initializer from property" "true" -namespace a +package a class M { trait A { diff --git a/idea/testData/quickfix/classImport/beforeToImport1.kt b/idea/testData/quickfix/classImport/beforeToImport1.kt index 075adebf27d..22c36963441 100644 --- a/idea/testData/quickfix/classImport/beforeToImport1.kt +++ b/idea/testData/quickfix/classImport/beforeToImport1.kt @@ -1,5 +1,5 @@ // "Remove initializer from property" "true" -namespace a +package a import java.util.Collections diff --git a/idea/testData/quickfix/classImport/beforeToImport2.kt b/idea/testData/quickfix/classImport/beforeToImport2.kt index c99cd4ebe4d..c22f5e31656 100644 --- a/idea/testData/quickfix/classImport/beforeToImport2.kt +++ b/idea/testData/quickfix/classImport/beforeToImport2.kt @@ -1,9 +1,9 @@ // "Remove initializer from property" "true" -namespace a +package a import java.util.Collections -namespace b { +package b { class M { trait A { diff --git a/idea/testData/quickfix/typeAddition/afterProtectedFunWithoutReturnType.kt b/idea/testData/quickfix/typeAddition/afterProtectedFunWithoutReturnType.kt index 21bb2b8a61b..70453ac2e71 100644 --- a/idea/testData/quickfix/typeAddition/afterProtectedFunWithoutReturnType.kt +++ b/idea/testData/quickfix/typeAddition/afterProtectedFunWithoutReturnType.kt @@ -1,5 +1,5 @@ // "Add return type declaration" "true" -namespace a +package a class A() { protected fun <caret>foo() : Int = 1 diff --git a/idea/testData/quickfix/typeAddition/afterPublicFunWithoutReturnType.kt b/idea/testData/quickfix/typeAddition/afterPublicFunWithoutReturnType.kt index d6915a73b54..5b1e3062cb5 100644 --- a/idea/testData/quickfix/typeAddition/afterPublicFunWithoutReturnType.kt +++ b/idea/testData/quickfix/typeAddition/afterPublicFunWithoutReturnType.kt @@ -1,5 +1,5 @@ // "Add return type declaration" "true" -namespace a +package a class A() { public fun <caret>foo() : String = "a" diff --git a/idea/testData/quickfix/typeAddition/afterPublicValWithoutReturnType.kt b/idea/testData/quickfix/typeAddition/afterPublicValWithoutReturnType.kt index ff8817efeff..9f661482552 100644 --- a/idea/testData/quickfix/typeAddition/afterPublicValWithoutReturnType.kt +++ b/idea/testData/quickfix/typeAddition/afterPublicValWithoutReturnType.kt @@ -1,5 +1,5 @@ // "Add return type declaration" "true" -namespace a +package a import java.util.List diff --git a/idea/testData/quickfix/typeAddition/beforeInternalProtectedFunWithoutReturnType.kt b/idea/testData/quickfix/typeAddition/beforeInternalProtectedFunWithoutReturnType.kt index 00fb6506546..9269030be65 100644 --- a/idea/testData/quickfix/typeAddition/beforeInternalProtectedFunWithoutReturnType.kt +++ b/idea/testData/quickfix/typeAddition/beforeInternalProtectedFunWithoutReturnType.kt @@ -1,5 +1,5 @@ // "Add return type declaration" "false" -namespace a +package a class A() { internal protected fun <caret>foo() = 1 diff --git a/idea/testData/quickfix/typeAddition/beforeProtectedFunWithoutReturnType.kt b/idea/testData/quickfix/typeAddition/beforeProtectedFunWithoutReturnType.kt index 5f8cb2d9cf1..6502ee78846 100644 --- a/idea/testData/quickfix/typeAddition/beforeProtectedFunWithoutReturnType.kt +++ b/idea/testData/quickfix/typeAddition/beforeProtectedFunWithoutReturnType.kt @@ -1,5 +1,5 @@ // "Add return type declaration" "true" -namespace a +package a class A() { protected fun <caret>foo() = 1 diff --git a/idea/testData/quickfix/typeAddition/beforePublicFunWithoutBody.kt b/idea/testData/quickfix/typeAddition/beforePublicFunWithoutBody.kt index c031a9e7577..7d0a2a28d85 100644 --- a/idea/testData/quickfix/typeAddition/beforePublicFunWithoutBody.kt +++ b/idea/testData/quickfix/typeAddition/beforePublicFunWithoutBody.kt @@ -1,5 +1,5 @@ // "Add return type declaration" "false" -namespace a +package a class A() { public fun <caret>foo() diff --git a/idea/testData/quickfix/typeAddition/beforePublicFunWithoutReturnType.kt b/idea/testData/quickfix/typeAddition/beforePublicFunWithoutReturnType.kt index ad53bc3e9fd..1c0f34f03ab 100644 --- a/idea/testData/quickfix/typeAddition/beforePublicFunWithoutReturnType.kt +++ b/idea/testData/quickfix/typeAddition/beforePublicFunWithoutReturnType.kt @@ -1,5 +1,5 @@ // "Add return type declaration" "true" -namespace a +package a class A() { public fun <caret>foo() = "a" diff --git a/idea/testData/quickfix/typeAddition/beforePublicValWithoutReturnType.kt b/idea/testData/quickfix/typeAddition/beforePublicValWithoutReturnType.kt index a162305a91c..5fb773845c1 100644 --- a/idea/testData/quickfix/typeAddition/beforePublicValWithoutReturnType.kt +++ b/idea/testData/quickfix/typeAddition/beforePublicValWithoutReturnType.kt @@ -1,4 +1,4 @@ // "Add return type declaration" "true" -namespace a +package a public val <caret>l = java.util.Collections.emptyList<Int>() \ No newline at end of file diff --git a/idea/tests/org/jetbrains/jet/plugin/javaFacade/JetJavaFacadeTest.java b/idea/tests/org/jetbrains/jet/plugin/javaFacade/JetJavaFacadeTest.java new file mode 100644 index 00000000000..0c343d561d3 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/javaFacade/JetJavaFacadeTest.java @@ -0,0 +1,61 @@ +package org.jetbrains.jet.plugin.javaFacade; + +import com.intellij.psi.*; +import com.intellij.psi.search.GlobalSearchScope; +import com.intellij.testFramework.LightProjectDescriptor; +import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.plugin.JetLightProjectDescriptor; +import org.jetbrains.jet.plugin.PluginTestCaseBase; + +/** + * @author max + */ +public class JetJavaFacadeTest extends LightCodeInsightFixtureTestCase { + @NotNull + @Override + protected LightProjectDescriptor getProjectDescriptor() { + return JetLightProjectDescriptor.INSTANCE; + } + + @Override + public void setUp() throws Exception { + super.setUp(); + myFixture.setTestDataPath(PluginTestCaseBase.getTestDataPathBase() + "/javaFacade"); + } + + public void testInnerClass() throws Exception { + myFixture.configureByFile(getTestName(true) + ".kt"); + + JavaPsiFacade facade = myFixture.getJavaFacade(); + PsiClass mirrorClass = facade.findClass("foo.Outer.Inner", GlobalSearchScope.allScope(getProject())); + + assertNotNull(mirrorClass); + PsiMethod[] fun = mirrorClass.findMethodsByName("innerFun", false); + + assertEquals(fun[0].getReturnType(), PsiType.VOID); + } + + public void testClassObject() throws Exception { + myFixture.configureByFile(getTestName(true) + ".kt"); + + JavaPsiFacade facade = myFixture.getJavaFacade(); + PsiClass theClass = facade.findClass("foo.TheClass", GlobalSearchScope.allScope(getProject())); + + assertNotNull(theClass); + + PsiField classobj = theClass.findFieldByName("$classobj", false); + assertTrue(classobj != null && classobj.hasModifierProperty(PsiModifier.STATIC)); + + PsiType type = classobj.getType(); + assertTrue(type instanceof PsiClassType); + + assertEquals("foo.TheClass.ClassObject$", type.getCanonicalText()); + + PsiClass classObjectClass = ((PsiClassType) type).resolve(); + assertTrue(classObjectClass != null && classObjectClass.hasModifierProperty(PsiModifier.STATIC)); + PsiMethod[] methods = classObjectClass.findMethodsByName("getOut", false); + + assertEquals("java.io.PrintStream", methods[0].getReturnType().getCanonicalText()); + } +} diff --git a/shift/shift.iml b/shift/shift.iml new file mode 100644 index 00000000000..d4552b3374b --- /dev/null +++ b/shift/shift.iml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" /> + </content> + <orderEntry type="jdk" jdkName="IDEA 10.x" jdkType="IDEA JDK" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="frontend" /> + <orderEntry type="module" module-name="backend" /> + <orderEntry type="module" module-name="compiler-tests" /> + </component> +</module> + diff --git a/shift/src/org/jetbrains/jet/shift/NamespaceToPackage.java b/shift/src/org/jetbrains/jet/shift/NamespaceToPackage.java new file mode 100644 index 00000000000..a8cb46e5e83 --- /dev/null +++ b/shift/src/org/jetbrains/jet/shift/NamespaceToPackage.java @@ -0,0 +1,103 @@ +package org.jetbrains.jet.shift; + +import com.intellij.lang.ASTNode; +import com.intellij.openapi.Disposable; +import com.intellij.openapi.application.ApplicationManager; +import com.intellij.openapi.progress.impl.ProgressManagerImpl; +import com.intellij.pom.PomModel; +import com.intellij.pom.core.impl.PomModelImpl; +import org.jetbrains.jet.JetCoreEnvironment; +import org.jetbrains.jet.compiler.CompileEnvironment; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.jet.lang.psi.JetNamespace; +import org.jetbrains.jet.lang.psi.JetPsiFactory; +import org.jetbrains.jet.lang.psi.JetTreeVisitor; +import org.picocontainer.*; + +import javax.swing.*; +import java.lang.reflect.InvocationTargetException; + +import static org.jetbrains.jet.lexer.JetTokens.NAMESPACE_KEYWORD; + +/** + * @author abreslav + */ +public class NamespaceToPackage { + + public static void main(String[] args) throws InvocationTargetException, InterruptedException { + System.setProperty("java.awt.headless", "true"); + Disposable rootDisposable = new Disposable() { + @Override + public void dispose() { + } + }; + final JetCoreEnvironment environment = new JetCoreEnvironment(rootDisposable); + + MutablePicoContainer picoContainer = environment.getApplication().getPicoContainer(); + picoContainer.registerComponent(new ComponentAdapter() { + @Override + public Object getComponentKey() { + return "com.intellij.openapi.progress.ProgressManager"; + } + + @Override + public Class getComponentImplementation() { + return ProgressManagerImpl.class; + } + + @Override + public Object getComponentInstance(PicoContainer picoContainer) throws PicoInitializationException, PicoIntrospectionException { + return new ProgressManagerImpl(environment.getApplication()); + } + + @Override + public void verify(PicoContainer picoContainer) throws PicoIntrospectionException { + + } + + @Override + public void accept(PicoVisitor picoVisitor) { + + } + }); + + CompileEnvironment compileEnvironment = new CompileEnvironment(); + + compileEnvironment.setJavaRuntime(CompileEnvironment.findRtJar(true)); + if (!compileEnvironment.initializeKotlinRuntime()) { + System.out.println("foo"); + } +// environment.getApplication().registerService(ProgressManager.class, new ProgressManagerImpl(environment.getApplication())); + environment.getApplication().registerService(PomModel.class, new PomModelImpl(environment.getProject())); +// environment.getApplication().registerService(Project.class, environment.getProject()); + + final JetFile file = JetPsiFactory.createFile(environment.getProject(), "namespace foo\nclass A"); + final ASTNode packageKeyword = JetPsiFactory.createFile(environment.getProject(), "package foo").getRootNamespace().getHeader().getNode().findChildByType(NAMESPACE_KEYWORD); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + ApplicationManager.getApplication().runWriteAction(new Runnable() { + @Override + public void run() { + convert(file, packageKeyword); + } + }); + } + }); + + } + + private static void convert(JetFile file, final ASTNode packageKeyword) { + file.getRootNamespace().accept(new JetTreeVisitor<Void>() { + @Override + public Void visitNamespace(JetNamespace namespace, Void data) { + ASTNode namespaceNode = namespace.getHeader().getNode(); + ASTNode token = namespaceNode.findChildByType(NAMESPACE_KEYWORD); + namespaceNode.replaceChild(token, packageKeyword); + return super.visitNamespace(namespace, data); + } + }, null); + System.out.println("file = " + file.getText()); + } +} diff --git a/shift/tests/org/jetbrains/jet/shift/Shifter.java b/shift/tests/org/jetbrains/jet/shift/Shifter.java new file mode 100644 index 00000000000..d4bec90243d --- /dev/null +++ b/shift/tests/org/jetbrains/jet/shift/Shifter.java @@ -0,0 +1,157 @@ +package org.jetbrains.jet.shift; + +///** +// * @author abreslav +// */ +//public class Shifter extends LightDaemonAnalyzerTestCase { +// private String name; +// public static final Pattern FILE_PATTERN = Pattern.compile("//\\s*FILE:\\s*(.*)$", Pattern.MULTILINE); +// +// public Shifter(@NonNls String dataPath, String name) { +// super(dataPath); +// this.name = name; +// } +// +// @Override +// public String getName() { +// return "test" + name; +// } +// +// +//// private class TestFile { +//// private final List<CheckerTestUtil.DiagnosedRange> diagnosedRanges = Lists.newArrayList(); +//// private final String expectedText; +//// private final String clearText; +//// private final JetFile jetFile; +//// +//// public TestFile(String fileName, String textWithMarkers) { +//// expectedText = textWithMarkers; +//// clearText = CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges); +//// jetFile = createCheckAndReturnPsiFile(fileName, clearText); +//// } +//// +//// public void getActualText(BindingContext bindingContext, StringBuilder actualText) { +//// CheckerTestUtil.diagnosticsDiff(diagnosedRanges, CheckerTestUtil.getDiagnosticsIncludingSyntaxErrors(bindingContext, jetFile), new CheckerTestUtil.DiagnosticDiffCallbacks() { +//// @Override +//// public void missingDiagnostic(String type, int expectedStart, int expectedEnd) { +//// String message = "Missing " + type + DiagnosticUtils.atLocation(jetFile, new TextRange(expectedStart, expectedEnd)); +//// System.err.println(message); +//// } +//// +//// @Override +//// public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) { +//// String message = "Unexpected " + type + DiagnosticUtils.atLocation(jetFile, new TextRange(actualStart, actualEnd)); +//// System.err.println(message); +//// } +//// }); +//// +//// actualText.append(CheckerTestUtil.addDiagnosticMarkersToText(jetFile, bindingContext, AnalyzingUtils.getSyntaxErrorRanges(jetFile))); +//// } +//// +//// } +// +// @Override +// public void runTest() throws Exception { +// String testFileName = name + ".jet"; +// +// String expectedText = loadFile(testFileName); +// +// final JetFile file = createCheckAndReturnPsiFile(testFileName, expectedText); +// +// +//// List<TestFile> testFileFiles = createTestFiles(testFileName, expectedText); +//// +//// boolean importJdk = expectedText.contains("+JDK"); +//// Configuration configuration = importJdk ? JavaBridgeConfiguration.createJavaBridgeConfiguration(getProject()) : Configuration.EMPTY; +//// +//// List<JetDeclaration> namespaces = Lists.newArrayList(); +//// for (TestFile testFileFile : testFileFiles) { +//// namespaces.add(testFileFile.jetFile.getRootNamespace()); +//// } +//// +//// BindingContext bindingContext; +//// if (importJdk) { +//// bindingContext = AnalyzerFacade.analyzeNamespacesWithJavaIntegration(getProject(), namespaces, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY); +//// } +//// else { +//// bindingContext = AnalyzingUtils.analyzeNamespaces(getProject(), Configuration.EMPTY, namespaces, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY, JetSemanticServices.createSemanticServices(getProject())); +//// } +//// +//// StringBuilder actualText = new StringBuilder(); +//// for (TestFile testFileFile : testFileFiles) { +//// testFileFile.getActualText(bindingContext, actualText); +//// } +//// +//// Assert.assertEquals(expectedText, actualText.toString()); +//// final JetFile file = JetPsiFactory.createFile(environment.getProject(), "namespace foo\nclass A"); +// ((MockApplication) ApplicationManager.getApplication()).registerService(PomModel.class, new PomModelImpl(getProject())); +// final ASTNode packageKeyword = JetPsiFactory.createFile(getProject(), "package foo").getRootNamespace().getHeader().getNode().findChildByType(NAMESPACE_KEYWORD); +// +//// SwingUtilities.invokeAndWait(new Runnable() { +//// @Override +//// public void run() { +// ApplicationManager.getApplication().runWriteAction(new Runnable() { +// @Override +// public void run() { +// convert(file, packageKeyword); +// } +// }); +//// } +//// }); +// +// } +// +// private static void convert(JetFile file, final ASTNode packageKeyword) { +// file.getRootNamespace().accept(new JetTreeVisitor<Void>() { +// @Override +// public Void visitNamespace(JetNamespace namespace, Void data) { +// ASTNode namespaceNode = namespace.getHeader().getNode(); +// ASTNode token = namespaceNode.findChildByType(NAMESPACE_KEYWORD); +// namespaceNode.replaceChild(token, packageKeyword); +// return super.visitNamespace(namespace, data); +// } +// }, null); +// System.out.println("file = " + file.getText()); +// } +// +// +// // 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 = doLoadFile(file.getParentFile().getAbsolutePath(), file.getName()); +//// Pattern pattern = Pattern.compile("</?(error|warning)>"); +//// String clearText = pattern.matcher(text).replaceAll(""); +//// createAndCheckPsiFile(name, clearText); +//// +//// BindingContext bindingContext = AnalyzingUtils.getInstance(ImportingStrategy.NONE).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(), "/diagnostics/tests/shift", true, new JetTestCaseBuilder.NamedTestFactory() { +// @NotNull +// @Override +// public Test createTest(@NotNull String dataPath, @NotNull String name, @NotNull File file) { +// return new Shifter(dataPath, name); +// } +// }); +// } +//} diff --git a/stdlib.ipr b/stdlib.ipr index 30c354500c5..693c766ab77 100644 --- a/stdlib.ipr +++ b/stdlib.ipr @@ -27,6 +27,9 @@ <option name="SKIP_IMPORT_STATEMENTS" value="false" /> </component> <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> + <component name="EntryPointsManager"> + <entry_points version="2.0" /> + </component> <component name="IdProvider" IDEtalkID="89F322227D19AFBE9B68C2A85DBC4124" /> <component name="InspectionProjectProfileManager"> <profiles> diff --git a/stdlib/ktSrc/Arrays.kt b/stdlib/ktSrc/Arrays.kt index 68f2234c716..48e1c8fc595 100644 --- a/stdlib/ktSrc/Arrays.kt +++ b/stdlib/ktSrc/Arrays.kt @@ -1,4 +1,4 @@ -namespace std +package std import java.io.ByteArrayInputStream diff --git a/stdlib/ktSrc/Filter.kt b/stdlib/ktSrc/Filter.kt index 1fa5cb45317..45439740e42 100644 --- a/stdlib/ktSrc/Filter.kt +++ b/stdlib/ktSrc/Filter.kt @@ -1,4 +1,4 @@ -namespace std +package std import java.util.* import java.lang.Iterable @@ -6,7 +6,7 @@ import java.lang.Iterable /* Filters given iterator */ -inline fun <T> java.util.Iterator<T>.filter(f: fun(T): Boolean) : java.util.Iterator<T> = FilterIterator<T>(this, f) +inline fun <T> java.util.Iterator<T>.filter(f: (T)-> Boolean) : java.util.Iterator<T> = FilterIterator<T>(this, f) /* Adds filtered elements in to given container @@ -28,15 +28,15 @@ Create iterator filtering given java.lang.Iterable inline fun <T> java.lang.Iterable<T>.filter(f: fun(T): Boolean) : java.util.Iterator<T> = (iterator() as java.util.Iterator<T>).filter(f) */ -private class FilterIterator<T>(val original: java.util.Iterator<T>, val filter: fun(T): Boolean) : java.util.Iterator<T> { +private class FilterIterator<T>(val original: java.util.Iterator<T>, val filter: (T)-> Boolean) : java.util.Iterator<T> { var state = 0 var nextElement: T? = null override fun hasNext(): Boolean = when(state) { - 1 => true // checked and next present - 2 => false // checked and next not present - else => { + 1 -> true // checked and next present + 2 -> false // checked and next not present + else -> { while(original.hasNext()) { val candidate = original.next() if((filter)(candidate)) { diff --git a/stdlib/ktSrc/Iterators.kt b/stdlib/ktSrc/Iterators.kt index 8a9b592ab26..7b3087e952e 100644 --- a/stdlib/ktSrc/Iterators.kt +++ b/stdlib/ktSrc/Iterators.kt @@ -1,4 +1,4 @@ -namespace std.util +package std.util import java.util.* import java.util.Iterator diff --git a/stdlib/ktSrc/JavaCollections.kt b/stdlib/ktSrc/JavaCollections.kt new file mode 100644 index 00000000000..d788529d489 --- /dev/null +++ b/stdlib/ktSrc/JavaCollections.kt @@ -0,0 +1,10 @@ +package std.util + +import java.util.* + +/** Returns a new collection containing the results of applying the given function to each element in this collection */ +inline fun <T, R> java.util.Collection<T>.map(result: Collection<R> = ArrayList<R>(this.size), transform : (T) -> R) : Collection<R> { + for (item in this) + result.add(transform(item)) + return result +} diff --git a/stdlib/ktSrc/JavaIo.kt b/stdlib/ktSrc/JavaIo.kt index 71ab785f556..8333eb37ca4 100644 --- a/stdlib/ktSrc/JavaIo.kt +++ b/stdlib/ktSrc/JavaIo.kt @@ -1,99 +1,143 @@ -namespace std +package std.io -namespace io { - import java.io.* - import java.nio.charset.* +import java.io.* +import java.nio.charset.* - inline fun print(message : Any?) { System.out?.print(message) } - inline fun print(message : Int) { System.out?.print(message) } - inline fun print(message : Long) { System.out?.print(message) } - inline fun print(message : Byte) { System.out?.print(message) } - inline fun print(message : Short) { System.out?.print(message) } - inline fun print(message : Char) { System.out?.print(message) } - inline fun print(message : Boolean) { System.out?.print(message) } - inline fun print(message : Float) { System.out?.print(message) } - inline fun print(message : Double) { System.out?.print(message) } - inline fun print(message : CharArray) { System.out?.print(message) } +inline fun print(message : Any?) { System.out?.print(message) } +inline fun print(message : Int) { System.out?.print(message) } +inline fun print(message : Long) { System.out?.print(message) } +inline fun print(message : Byte) { System.out?.print(message) } +inline fun print(message : Short) { System.out?.print(message) } +inline fun print(message : Char) { System.out?.print(message) } +inline fun print(message : Boolean) { System.out?.print(message) } +inline fun print(message : Float) { System.out?.print(message) } +inline fun print(message : Double) { System.out?.print(message) } +inline fun print(message : CharArray) { System.out?.print(message) } - inline fun println(message : Any?) { System.out?.println(message) } - inline fun println(message : Int) { System.out?.println(message) } - inline fun println(message : Long) { System.out?.println(message) } - inline fun println(message : Byte) { System.out?.println(message) } - inline fun println(message : Short) { System.out?.println(message) } - inline fun println(message : Char) { System.out?.println(message) } - inline fun println(message : Boolean) { System.out?.println(message) } - inline fun println(message : Float) { System.out?.println(message) } - inline fun println(message : Double) { System.out?.println(message) } - inline fun println(message : CharArray) { System.out?.println(message) } - inline fun println() { System.out?.println() } +inline fun println(message : Any?) { System.out?.println(message) } +inline fun println(message : Int) { System.out?.println(message) } +inline fun println(message : Long) { System.out?.println(message) } +inline fun println(message : Byte) { System.out?.println(message) } +inline fun println(message : Short) { System.out?.println(message) } +inline fun println(message : Char) { System.out?.println(message) } +inline fun println(message : Boolean) { System.out?.println(message) } +inline fun println(message : Float) { System.out?.println(message) } +inline fun println(message : Double) { System.out?.println(message) } +inline fun println(message : CharArray) { System.out?.println(message) } +inline fun println() { System.out?.println() } - private val stdin : BufferedReader = BufferedReader(InputStreamReader(object : InputStream() { - override fun read() : Int { - return System.`in`?.read() ?: -1 - } +private val stdin : BufferedReader = BufferedReader(InputStreamReader(object : InputStream() { + override fun read() : Int { + return System.`in`?.read() ?: -1 + } - override fun reset() { - System.`in`?.reset() - } + override fun reset() { + System.`in`?.reset() + } - override fun read(b: ByteArray?): Int { - return System.`in`?.read(b) ?: -1 - } + override fun read(b: ByteArray?): Int { + return System.`in`?.read(b) ?: -1 + } - override fun close() { - System.`in`?.close() - } + override fun close() { + System.`in`?.close() + } - override fun mark(readlimit: Int) { - System.`in`?.mark(readlimit) - } + override fun mark(readlimit: Int) { + System.`in`?.mark(readlimit) + } - override fun skip(n: Long): Long { - return System.`in`?.skip(n) ?: -1.lng - } + override fun skip(n: Long): Long { + return System.`in`?.skip(n) ?: -1.lng + } - override fun available(): Int { - return System.`in`?.available() ?: 0 - } + override fun available(): Int { + return System.`in`?.available() ?: 0 + } - override fun markSupported(): Boolean { - return System.`in`?.markSupported() ?: false - } + override fun markSupported(): Boolean { + return System.`in`?.markSupported() ?: false + } - override fun read(b: ByteArray?, off: Int, len: Int): Int { - return System.`in`?.read(b, off, len) ?: -1 - } - })) + override fun read(b: ByteArray?, off: Int, len: Int): Int { + return System.`in`?.read(b, off, len) ?: -1 + } +})) - inline fun readLine() : String? = stdin.readLine() +inline fun readLine() : String? = stdin.readLine() - fun InputStream.iterator() : ByteIterator = - object: ByteIterator() { - override val hasNext : Boolean - get() = available() > 0 +/** Uses the given resource then closes it to ensure its closed again */ +inline fun <T: Closeable, R> T.use(block: (T)-> R) : R { + var closed = false + try { + return block(this) + } catch (e: Exception) { + try { + this.close() + } catch (closeException: Exception) { + // eat the closeException as we are already throwing the original cause + // and we don't want to mask the real exception + } + throw e + } finally { + if (!closed) { + this.close() + } + } +} - override fun nextByte() = read().byt - } +fun InputStream.iterator() : ByteIterator = + object: ByteIterator() { + override val hasNext : Boolean + get() = available() > 0 - inline fun InputStream.buffered(bufferSize: Int) = BufferedInputStream(this, bufferSize) + override fun nextByte() = read().byt + } - inline val InputStream.reader : InputStreamReader - get() = InputStreamReader(this) +inline fun InputStream.buffered(bufferSize: Int) = BufferedInputStream(this, bufferSize) - inline val InputStream.bufferedReader : BufferedReader - get() = BufferedReader(reader) +inline val InputStream.reader : InputStreamReader + get() = InputStreamReader(this) - inline fun InputStream.reader(charset: Charset) : InputStreamReader = InputStreamReader(this, charset) +inline val InputStream.bufferedReader : BufferedReader + get() = BufferedReader(reader) - inline fun InputStream.reader(charsetName: String) = InputStreamReader(this, charsetName) +inline fun InputStream.reader(charset: Charset) : InputStreamReader = InputStreamReader(this, charset) - inline fun InputStream.reader(charsetDecoder: CharsetDecoder) = InputStreamReader(this, charsetDecoder) +inline fun InputStream.reader(charsetName: String) = InputStreamReader(this, charsetName) - inline val InputStream.buffered : BufferedInputStream - get() = if(this is BufferedInputStream) this else BufferedInputStream(this) +inline fun InputStream.reader(charsetDecoder: CharsetDecoder) = InputStreamReader(this, charsetDecoder) -// inline val Reader.buffered : BufferedReader +inline val InputStream.buffered : BufferedInputStream + get() = if(this is BufferedInputStream) this else BufferedInputStream(this) + +// inline val Reader.buffered : BufferedReader // get() = if(this is BufferedReader) this else BufferedReader(this) - inline fun Reader.buffered(bufferSize: Int) = BufferedReader(this, bufferSize) -} \ No newline at end of file +inline fun Reader.buffered(): BufferedReader = if(this is BufferedReader) this else BufferedReader(this) + +inline fun Reader.buffered(bufferSize: Int) = BufferedReader(this, bufferSize) + +inline fun <T> Reader.useLines(block: (Iterator<String>) -> T): T = this.buffered().use<BufferedReader, T>{block(it.lineIterator())} +/** + * Returns an iterator over each line. + * <b>Note</b> the caller must close the underlying <code>BufferedReader</code> + * when the iteration is finished; as the user may not complete the iteration loop (e.g. using a method like find() or any() on the iterator + * may terminate the iteration early. + * <br> + * We suggest you try the method useLines() instead which closes the stream when the processing is complete. + */ +inline fun BufferedReader.lineIterator() : Iterator<String> = LineIterator(this) + +protected class LineIterator(val reader: BufferedReader) : Iterator<String> { + private var nextLine: String? = null + + override val hasNext: Boolean + get() { + nextLine = reader.readLine() + return nextLine != null + } + + override fun next(): String = nextLine.sure() +} + diff --git a/stdlib/ktSrc/JavaIterables.kt b/stdlib/ktSrc/JavaIterables.kt new file mode 100644 index 00000000000..e209250b1fc --- /dev/null +++ b/stdlib/ktSrc/JavaIterables.kt @@ -0,0 +1,132 @@ +package std.util + +import java.util.* + +/** Returns true if any elements in the collection match the given predicate */ +inline fun <T> java.lang.Iterable<T>.any(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (predicate(elem)) { + return true + } + } + return false +} + +/** Returns true if all elements in the collection match the given predicate */ +inline fun <T> java.lang.Iterable<T>.all(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (!predicate(elem)) { + return false + } + } + return true +} + +/** Returns the number of items which match the given predicate */ +inline fun <T> java.lang.Iterable<T>.count(predicate: (T)-> Boolean) : Int { + var answer = 0 + for (elem in this) { + if (predicate(elem)) + answer += 1 + } + return answer +} + +/** Returns the first item in the collection which matches the given predicate or null if none matched */ +inline fun <T> java.lang.Iterable<T>.find(predicate: (T)-> Boolean) : T? { + for (elem in this) { + if (predicate(elem)) + return elem + } + return null +} + +/** Returns a new collection containing all elements in this collection which match the given predicate */ +inline fun <T> java.lang.Iterable<T>.filter(result: Collection<T> = ArrayList<T>(), predicate: (T)-> Boolean) : Collection<T> { + for (elem in this) { + if (predicate(elem)) + result.add(elem) + } + return result +} + +/** Returns a new collection containing all elements in this collection which do not match the given predicate */ +inline fun <T> java.lang.Iterable<T>.filterNot(result: Collection<T> = ArrayList<T>(), predicate: (T)-> Boolean) : Collection<T> { + for (elem in this) { + if (!predicate(elem)) + result.add(elem) + } + return result +} + +/** + * Returns the result of transforming each item in the collection to a one or more values which + * are concatenated together into a single collection + */ +inline fun <T, out R> java.lang.Iterable<T>.flatMap(result: Collection<R> = ArrayList<R>(), transform: (T)-> Collection<R>) : Collection<R> { + for (elem in this) { + val coll = transform(elem) + if (coll != null) { + for (r in coll) { + result.add(r) + } + } + } + return result +} + +/** Performs the given operation on each element inside the collection */ +inline fun <T> java.lang.Iterable<T>.foreach(operation: (element: T) -> Unit) { + for (elem in this) + operation(elem) +} + +/** + * Iterates through the collection performing the transformation on each element and using the result + * as the key in a map to group elements by the result + */ +inline fun <T,K> java.lang.Iterable<T>.groupBy(result: Map<K,List<T>> = HashMap<K,List<T>>(), toKey: (T)-> K) : Map<K,List<T>> { + for (elem in this) { + val key = toKey(elem) + val list = result.getOrElseUpdate(key){ ArrayList<T>() } + list.add(elem) + } + return result +} + + +/** Creates a String from all the elements in the collection, using the seperator between them and using the given prefix and postfix if supplied */ +inline fun <T> java.lang.Iterable<T>.join(separator: String, prefix: String = "", postfix: String = "") : String { + val buffer = StringBuilder(prefix) + var first = true + for (elem in this) { + if (first) + first = false + else + buffer.append(separator) + buffer.append(elem) + } + buffer.append(postfix) + return buffer.toString().sure() +} + +inline fun <T, C: Collection<T>> java.lang.Iterable<T>.to(result: C) : C { + for (elem in this) + result.add(elem) + return result +} + +inline fun <T> java.lang.Iterable<T>.toLinkedList() : LinkedList<T> = this.to(LinkedList<T>()) + +inline fun <T> java.lang.Iterable<T>.toList() : List<T> = this.to(ArrayList<T>()) + +inline fun <T> java.lang.Iterable<T>.toSet() : Set<T> = this.to(HashSet<T>()) + +/** + TODO figure out necessary variance/generics ninja stuff... :) +inline fun <in T> java.lang.Iterable<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> { + val answer = this.toList() + answer.sort(transform) + return answer +} +*/ diff --git a/stdlib/ktSrc/JavaUtil.kt b/stdlib/ktSrc/JavaUtil.kt index a96ac23b357..f1043599bd1 100644 --- a/stdlib/ktSrc/JavaUtil.kt +++ b/stdlib/ktSrc/JavaUtil.kt @@ -1,4 +1,4 @@ -namespace std.util +package std.util import java.util.* @@ -11,149 +11,14 @@ val Collection<*>.empty : Boolean get() = isEmpty() /** Returns a new ArrayList with a variable number of initial elements */ -inline fun arrayList<T>(vararg values: T) : ArrayList<T> { - val answer = ArrayList<T>() - for (v in values) - answer.add(v) - return answer; -} +inline fun arrayList<T>(vararg values: T) : ArrayList<T> = values.to(ArrayList<T>(values.size)) /** Returns a new LinkedList with a variable number of initial elements */ -inline fun linkedList<T>(vararg values: T) : LinkedList<T> { - val answer = LinkedList<T>() - for (v in values) - answer.add(v) - return answer; -} +inline fun linkedList<T>(vararg values: T) : LinkedList<T> = values.to(LinkedList<T>()) /** Returns a new HashSet with a variable number of initial elements */ -inline fun hashSet<T>(vararg values: T) : HashSet<T> { - val answer = HashSet<T>() - for (v in values) - answer.add(v) - return answer; -} +inline fun hashSet<T>(vararg values: T) : HashSet<T> = values.to(HashSet<T>(values.size)) -/** Returns true if any elements in the collection match the given predicate */ -inline fun <T> java.lang.Iterable<T>.any(predicate: fun(T): Boolean) : Boolean { - for (elem in this) { - if (predicate(elem)) { - return true - } - } - return false -} - -/** Returns true if all elements in the collection match the given predicate */ -inline fun <T> java.lang.Iterable<T>.all(predicate: fun(T): Boolean) : Boolean { - for (elem in this) { - if (!predicate(elem)) { - return false - } - } - return true -} - -/** Returns the first item in the collection which matches the given predicate or null if none matched */ -inline fun <T> java.lang.Iterable<T>.find(predicate: fun(T): Boolean) : T? { - for (elem in this) { - if (predicate(elem)) - return elem - } - return null -} - -/** Returns a new collection containing all elements in this collection which match the given predicate */ -inline fun <T> java.lang.Iterable<T>.filter(result: Collection<T> = ArrayList<T>(), predicate: fun(T): Boolean) : Collection<T> { - for (elem in this) { - if (predicate(elem)) - result.add(elem) - } - return result -} - -/** - * Returns the result of transforming each item in the collection to a one or more values which - * are concatenated together into a single collection - */ -inline fun <T, out R> java.lang.Iterable<T>.flatMap(result: Collection<R> = ArrayList<R>(), transform: fun(T): Collection<R>) : Collection<R> { - for (elem in this) { - val coll = transform(elem) - if (coll != null) { - for (r in coll) { - result.add(r) - } - } - } - return result -} - -/** Performs the given operation on each element inside the collection */ -inline fun <T> java.lang.Iterable<T>.foreach(operation: fun(element: T) : Unit) { - for (elem in this) - operation(elem) -} - -/** Creates a String from all the elements in the collection, using the seperator between them and using the given prefix and postfix if supplied */ -inline fun <T> java.lang.Iterable<T>.join(separator: String, prefix: String = "", postfix: String = "") : String { - val buffer = StringBuilder(prefix) - var first = true - for (elem in this) { - if (first) - first = false - else - buffer.append(separator) - buffer.append(elem) - } - buffer.append(postfix) - return buffer.toString().sure() -} - -/** Returns a new collection containing the results of applying the given function to each element in this collection */ -inline fun <T, R> java.lang.Iterable<T>.map(result: Collection<R> = ArrayList<R>(), transform : fun(T) : R) : Collection<R> { - for (item in this) - result.add(transform(item)) - return result -} - -/** Returns a new collection containing the results of applying the given function to each element in this collection */ -inline fun <T, R> java.util.Collection<T>.map(result: Collection<R> = ArrayList<R>(this.size), transform : fun(T) : R) : Collection<R> { - for (item in this) - result.add(transform(item)) - return result -} - -inline fun <in T: java.lang.Comparable<T>> java.lang.Iterable<T>.toSortedList() : List<T> { - val answer = this.toList() - answer.sort() - return answer -} - -inline fun <in T: java.lang.Comparable<T>> java.lang.Iterable<T>.toSortedList(comparator: java.util.Comparator<T>) : List<T> { - val answer = this.toList() - answer.sort(comparator) - return answer -} - -/** - TODO figure out necessary variance/generics ninja stuff... :) -inline fun <in T> java.lang.Iterable<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> { - val answer = this.toList() - answer.sort(transform) - return answer -} -*/ - -inline fun <T> java.lang.Iterable<T>.toList() : List<T> { - if (this is List<T>) - return this - else { - val list = ArrayList<T>() - for (elem in this) - list.add(elem) - return list - } -} inline fun <T> java.util.Collection<T>.toArray() : Array<T> { val answer = Array<T>(this.size) @@ -163,15 +28,23 @@ inline fun <T> java.util.Collection<T>.toArray() : Array<T> { return answer as Array<T> } +/** TODO these functions don't work when they generate the Array<T> versions when they are in JavaIterables */ +inline fun <in T: java.lang.Comparable<T>> java.lang.Iterable<T>.toSortedList() : List<T> = toList().sort() + +inline fun <in T: java.lang.Comparable<T>> java.lang.Iterable<T>.toSortedList(comparator: java.util.Comparator<T>) : List<T> = toList().sort(comparator) + + // List APIs -inline fun <in T: java.lang.Comparable<T>> List<T>.sort() : Unit { +inline fun <in T: java.lang.Comparable<T>> List<T>.sort() : List<T> { Collections.sort(this) + return this } -inline fun <in T: java.lang.Comparable<T>> List<T>.sort(comparator: java.util.Comparator<T>) : Unit { +inline fun <in T: java.lang.Comparable<T>> List<T>.sort(comparator: java.util.Comparator<T>) : List<T> { Collections.sort(this, comparator) + return this } /** @@ -202,8 +75,10 @@ val <T> List<T>.tail : T? get() { val s = this.size return if (s > 0) this.get(s - 1) else null - } -val <T> List<T>.last : T? - get() = this.tail + +val <T> List<T>.last : T? + get() = this.tail + + diff --git a/stdlib/ktSrc/JavaUtilMap.kt b/stdlib/ktSrc/JavaUtilMap.kt new file mode 100644 index 00000000000..4dcd2e9bd19 --- /dev/null +++ b/stdlib/ktSrc/JavaUtilMap.kt @@ -0,0 +1,39 @@ +package std.util + +import java.util.* + +// Map APIs + +/** Returns the size of the map */ +/* TODO get redeclaration errors +val Map<*,*>.size : Int + get() = size() +*/ + +/** Returns true if this map is empty */ +/* TODO get redeclaration errors +val Map<*,*>.empty : Boolean + get() = isEmpty() +*/ + +/** Returns the value for the given key or returns the result of the defaultValue function if there was no entry for the given key */ +inline fun <K,V> java.util.Map<K,V>.getOrElse(key: K, defaultValue: ()-> V) : V { + val current = this.get(key) + if (current != null) { + return current + } else { + return defaultValue() + } +} + +/** Returns the value for the given key or the result of the defaultValue function is put into the map for the given value and returned */ +inline fun <K,V> java.util.Map<K,V>.getOrElseUpdate(key: K, defaultValue: ()-> V) : V { + val current = this.get(key) + if (current != null) { + return current + } else { + val answer = defaultValue() + this.put(key, answer) + return answer + } +} diff --git a/stdlib/ktSrc/Standard.kt b/stdlib/ktSrc/Standard.kt new file mode 100644 index 00000000000..9ac302cf775 --- /dev/null +++ b/stdlib/ktSrc/Standard.kt @@ -0,0 +1,47 @@ +package std + +import java.util.Collection +import java.util.ArrayList +import java.util.LinkedList +import java.util.HashSet +import java.util.LinkedHashSet +import java.util.TreeSet + +/* + * Extension functions on the standard Kotlin types to behave like the java.lang.* and java.util.* collections + */ + +/* +Add iterated elements to given container +*/ +fun <T,U: Collection<in T>> Iterator<T>.to(container: U) : U { + while(hasNext) + container.add(next()) + return container +} + +/* +Add iterated elements to java.util.ArrayList +*/ +inline fun <T> Iterator<T>.toArrayList() = to(ArrayList<T>()) + +/* +Add iterated elements to java.util.LinkedList +*/ +inline fun <T> Iterator<T>.toLinkedList() = to(LinkedList<T>()) + +/* +Add iterated elements to java.util.HashSet +*/ +inline fun <T> Iterator<T>.toHashSet() = to(HashSet<T>()) + +/* +Add iterated elements to java.util.LinkedHashSet +*/ +inline fun <T> Iterator<T>.toLinkedHashSet() = to(LinkedHashSet<T>()) + +/* +Add iterated elements to java.util.TreeSet +*/ +inline fun <T> Iterator<T>.toTreeSet() = to(TreeSet<T>()) + diff --git a/stdlib/ktSrc/String.kt b/stdlib/ktSrc/String.kt index 4df7c099d29..fe5912fa03e 100644 --- a/stdlib/ktSrc/String.kt +++ b/stdlib/ktSrc/String.kt @@ -1,4 +1,4 @@ -namespace std +package std import java.io.StringReader @@ -6,7 +6,7 @@ inline fun <T> T?.plus(str: String?) : String { return toString() + str } inline fun String.lastIndexOf(s: String) = (this as java.lang.String).lastIndexOf(s) -inline fun String.lastIndexOf(s: Char) = (this as java.lang.String).lastIndexOf(s.toString()) } +inline fun String.lastIndexOf(s: Char) = (this as java.lang.String).lastIndexOf(s.toString()) inline fun String.indexOf(s : String) = (this as java.lang.String).indexOf(s) diff --git a/stdlib/ktSrc/System.kt b/stdlib/ktSrc/System.kt index 1b5545f0266..3d7b443991d 100644 --- a/stdlib/ktSrc/System.kt +++ b/stdlib/ktSrc/System.kt @@ -1,9 +1,9 @@ -namespace std.util +package std.util /** Executes current block and returns elapsed time in milliseconds */ -fun measureTimeMillis(block: fun() : Unit) : Long { +fun measureTimeMillis(block: () -> Unit) : Long { val start = System.currentTimeMillis() block() return System.currentTimeMillis() - start @@ -12,7 +12,7 @@ fun measureTimeMillis(block: fun() : Unit) : Long { /** Executes current block and returns elapsed time in milliseconds */ -fun measureTimeNano(block: fun() : Unit) : Long { +fun measureTimeNano(block: () -> Unit) : Long { val start = System.nanoTime() block() return System.nanoTime() - start diff --git a/stdlib/ktSrc/Thread.kt b/stdlib/ktSrc/Thread.kt index 637418ea902..e55b77e3a86 100644 --- a/stdlib/ktSrc/Thread.kt +++ b/stdlib/ktSrc/Thread.kt @@ -1,4 +1,4 @@ -namespace std.concurrent +package std.concurrent import java.lang.* @@ -21,7 +21,7 @@ inline var Thread.contextClassLoader : ClassLoader? get() = getContextClassLoader() set(loader: ClassLoader?) { setContextClassLoader(loader) } -fun thread(start: Boolean = true, daemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: fun():Unit) : Thread { +fun thread(start: Boolean = true, daemon: Boolean = false, contextClassLoader: ClassLoader? = null, name: String? = null, priority: Int = -1, block: ()->Unit) : Thread { val thread = object: Thread() { override fun run() { block() diff --git a/stdlib/ktSrc/generated/ArraysFromJavaCollections.kt b/stdlib/ktSrc/generated/ArraysFromJavaCollections.kt new file mode 100644 index 00000000000..12db122013e --- /dev/null +++ b/stdlib/ktSrc/generated/ArraysFromJavaCollections.kt @@ -0,0 +1,11 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaCollections.kt +package std + +import java.util.* + +/** Returns a new collection containing the results of applying the given function to each element in this collection */ +inline fun <T, R> Array<T>.map(result: Collection<R> = ArrayList<R>(this.size), transform : (T) -> R) : Collection<R> { + for (item in this) + result.add(transform(item)) + return result +} diff --git a/stdlib/ktSrc/generated/ArraysFromJavaIterables.kt b/stdlib/ktSrc/generated/ArraysFromJavaIterables.kt new file mode 100644 index 00000000000..9794644f7d7 --- /dev/null +++ b/stdlib/ktSrc/generated/ArraysFromJavaIterables.kt @@ -0,0 +1,109 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaIterables.kt +package std + +import java.util.* + +/** Returns true if any elements in the collection match the given predicate */ +inline fun <T> Array<T>.any(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (predicate(elem)) { + return true + } + } + return false +} + +/** Returns true if all elements in the collection match the given predicate */ +inline fun <T> Array<T>.all(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (!predicate(elem)) { + return false + } + } + return true +} + +/** Returns the first item in the collection which matches the given predicate or null if none matched */ +inline fun <T> Array<T>.find(predicate: (T)-> Boolean) : T? { + for (elem in this) { + if (predicate(elem)) + return elem + } + return null +} + +/** Returns a new collection containing all elements in this collection which match the given predicate */ +inline fun <T> Array<T>.filter(result: Collection<T> = ArrayList<T>(), predicate: (T)-> Boolean) : Collection<T> { + for (elem in this) { + if (predicate(elem)) + result.add(elem) + } + return result +} + +/** Returns a new collection containing all elements in this collection which do not match the given predicate */ +inline fun <T> Array<T>.filterNot(result: Collection<T> = ArrayList<T>(), predicate: (T)-> Boolean) : Collection<T> { + for (elem in this) { + if (!predicate(elem)) + result.add(elem) + } + return result +} + +/** + * Returns the result of transforming each item in the collection to a one or more values which + * are concatenated together into a single collection + */ +inline fun <T, out R> Array<T>.flatMap(result: Collection<R> = ArrayList<R>(), transform: (T)-> Collection<R>) : Collection<R> { + for (elem in this) { + val coll = transform(elem) + if (coll != null) { + for (r in coll) { + result.add(r) + } + } + } + return result +} + +/** Performs the given operation on each element inside the collection */ +inline fun <T> Array<T>.foreach(operation: (element: T) -> Unit) { + for (elem in this) + operation(elem) +} + +/** Creates a String from all the elements in the collection, using the seperator between them and using the given prefix and postfix if supplied */ +inline fun <T> Array<T>.join(separator: String, prefix: String = "", postfix: String = "") : String { + val buffer = StringBuilder(prefix) + var first = true + for (elem in this) { + if (first) + first = false + else + buffer.append(separator) + buffer.append(elem) + } + buffer.append(postfix) + return buffer.toString().sure() +} + +inline fun <T, C: Collection<T>> Array<T>.to(result: C) : C { + for (elem in this) + result.add(elem) + return result +} + +inline fun <T> Array<T>.toLinkedList() : LinkedList<T> = this.to(LinkedList<T>()) + +inline fun <T> Array<T>.toList() : List<T> = this.to(ArrayList<T>()) + +inline fun <T> Array<T>.toSet() : Set<T> = this.to(HashSet<T>()) + +/** + TODO figure out necessary variance/generics ninja stuff... :) +inline fun <in T> Array<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> { + val answer = this.toList() + answer.sort(transform) + return answer +} +*/ diff --git a/stdlib/ktSrc/generated/JavaUtilIterablesFromJavaCollections.kt b/stdlib/ktSrc/generated/JavaUtilIterablesFromJavaCollections.kt new file mode 100644 index 00000000000..e4592189fca --- /dev/null +++ b/stdlib/ktSrc/generated/JavaUtilIterablesFromJavaCollections.kt @@ -0,0 +1,11 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaCollections.kt +package std.util + +import java.util.* + +/** Returns a new collection containing the results of applying the given function to each element in this collection */ +inline fun <T, R> java.lang.Iterable<T>.map(result: Collection<R> = ArrayList<R>(), transform : (T) -> R) : Collection<R> { + for (item in this) + result.add(transform(item)) + return result +} diff --git a/stdlib/ktSrc/generated/StandardFromJavaCollections.kt b/stdlib/ktSrc/generated/StandardFromJavaCollections.kt new file mode 100644 index 00000000000..e94ec1d52d3 --- /dev/null +++ b/stdlib/ktSrc/generated/StandardFromJavaCollections.kt @@ -0,0 +1,11 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaCollections.kt +package std + +import java.util.* + +/** Returns a new collection containing the results of applying the given function to each element in this collection */ +inline fun <T, R> Iterable<T>.map(result: Collection<R> = ArrayList<R>(), transform : (T) -> R) : Collection<R> { + for (item in this) + result.add(transform(item)) + return result +} diff --git a/stdlib/ktSrc/generated/StandardFromJavaIterables.kt b/stdlib/ktSrc/generated/StandardFromJavaIterables.kt new file mode 100644 index 00000000000..00a566350ec --- /dev/null +++ b/stdlib/ktSrc/generated/StandardFromJavaIterables.kt @@ -0,0 +1,109 @@ +// NOTE this file is auto-generated from stdlib/ktSrc/JavaIterables.kt +package std + +import java.util.* + +/** Returns true if any elements in the collection match the given predicate */ +inline fun <T> Iterable<T>.any(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (predicate(elem)) { + return true + } + } + return false +} + +/** Returns true if all elements in the collection match the given predicate */ +inline fun <T> Iterable<T>.all(predicate: (T)-> Boolean) : Boolean { + for (elem in this) { + if (!predicate(elem)) { + return false + } + } + return true +} + +/** Returns the first item in the collection which matches the given predicate or null if none matched */ +inline fun <T> Iterable<T>.find(predicate: (T)-> Boolean) : T? { + for (elem in this) { + if (predicate(elem)) + return elem + } + return null +} + +/** Returns a new collection containing all elements in this collection which match the given predicate */ +inline fun <T> Iterable<T>.filter(result: Collection<T> = ArrayList<T>(), predicate: (T)-> Boolean) : Collection<T> { + for (elem in this) { + if (predicate(elem)) + result.add(elem) + } + return result +} + +/** Returns a new collection containing all elements in this collection which do not match the given predicate */ +inline fun <T> Iterable<T>.filterNot(result: Collection<T> = ArrayList<T>(), predicate: (T)-> Boolean) : Collection<T> { + for (elem in this) { + if (!predicate(elem)) + result.add(elem) + } + return result +} + +/** + * Returns the result of transforming each item in the collection to a one or more values which + * are concatenated together into a single collection + */ +inline fun <T, out R> Iterable<T>.flatMap(result: Collection<R> = ArrayList<R>(), transform: (T)-> Collection<R>) : Collection<R> { + for (elem in this) { + val coll = transform(elem) + if (coll != null) { + for (r in coll) { + result.add(r) + } + } + } + return result +} + +/** Performs the given operation on each element inside the collection */ +inline fun <T> Iterable<T>.foreach(operation: (element: T) -> Unit) { + for (elem in this) + operation(elem) +} + +/** Creates a String from all the elements in the collection, using the seperator between them and using the given prefix and postfix if supplied */ +inline fun <T> Iterable<T>.join(separator: String, prefix: String = "", postfix: String = "") : String { + val buffer = StringBuilder(prefix) + var first = true + for (elem in this) { + if (first) + first = false + else + buffer.append(separator) + buffer.append(elem) + } + buffer.append(postfix) + return buffer.toString().sure() +} + +inline fun <T, C: Collection<T>> Iterable<T>.to(result: C) : C { + for (elem in this) + result.add(elem) + return result +} + +inline fun <T> Iterable<T>.toLinkedList() : LinkedList<T> = this.to(LinkedList<T>()) + +inline fun <T> Iterable<T>.toList() : List<T> = this.to(ArrayList<T>()) + +inline fun <T> Iterable<T>.toSet() : Set<T> = this.to(HashSet<T>()) + +/** + TODO figure out necessary variance/generics ninja stuff... :) +inline fun <in T> Iterable<T>.toSortedList(transform: fun(T) : java.lang.Comparable<*>) : List<T> { + val answer = this.toList() + answer.sort(transform) + return answer +} +*/ diff --git a/stdlib/ktSrc/ModuleBuilder.kt b/stdlib/ktSrc/modules/ModuleBuilder.kt similarity index 83% rename from stdlib/ktSrc/ModuleBuilder.kt rename to stdlib/ktSrc/modules/ModuleBuilder.kt index ca94ba92ea1..d0f2985880a 100644 --- a/stdlib/ktSrc/ModuleBuilder.kt +++ b/stdlib/ktSrc/modules/ModuleBuilder.kt @@ -1,14 +1,18 @@ -namespace kotlin - -namespace modules { +package kotlin.modules import java.util.* import jet.modules.* -class ModuleSetBuilder(): IModuleSetBuilder { - val modules: ArrayList<IModuleBuilder?> = ArrayList<IModuleBuilder?>() +fun moduleSet(description: ModuleSetBuilder.() -> Unit) = description - fun module(name: String, callback: fun ModuleBuilder.()) { +fun module(name: String, description: ModuleBuilder.() -> Unit) = moduleSet { + module(name, description) +} + +class ModuleSetBuilder(): IModuleSetBuilder { + private val modules = ArrayList<IModuleBuilder?>() + + fun module(name: String, callback: ModuleBuilder.() -> Unit) { val builder = ModuleBuilder(name) builder.callback() modules.add(builder) @@ -72,5 +76,4 @@ class ModuleBuilder2(name: String): ModuleBuilder(name) { } -} diff --git a/stdlib/src/jet/typeinfo/TypeInfo.java b/stdlib/src/jet/typeinfo/TypeInfo.java index 3e9a3ddaa30..379bf2dc245 100644 --- a/stdlib/src/jet/typeinfo/TypeInfo.java +++ b/stdlib/src/jet/typeinfo/TypeInfo.java @@ -12,6 +12,7 @@ import org.jetbrains.jet.rt.TypeInfoProjectionImpl; */ public abstract class TypeInfo<T> implements JetObject { + public static final TypeInfo<Object> ANY_TYPE_INFO = getTypeInfo(Object.class, false); public static final TypeInfo<Byte> BYTE_TYPE_INFO = getTypeInfo(Byte.class, false); public static final TypeInfo<Short> SHORT_TYPE_INFO = getTypeInfo(Short.class, false); public static final TypeInfo<Integer> INT_TYPE_INFO = getTypeInfo(Integer.class, false); @@ -33,6 +34,7 @@ public abstract class TypeInfo<T> implements JetObject { public static final TypeInfo<String> STRING_TYPE_INFO = getTypeInfo(String.class, false); public static final TypeInfo<Tuple0> TUPLE0_TYPE_INFO = getTypeInfo(Tuple0.class, false); + public static final TypeInfo<Object> NULLABLE_ANY_TYPE_INFO = getTypeInfo(Object.class, true); public static final TypeInfo<Byte> NULLABLE_BYTE_TYPE_INFO = getTypeInfo(Byte.class, true); public static final TypeInfo<Short> NULLABLE_SHORT_TYPE_INFO = getTypeInfo(Short.class, true); public static final TypeInfo<Integer> NULLABLE_INT_TYPE_INFO = getTypeInfo(Integer.class, true); diff --git a/stdlib/src/org/jetbrains/jet/rt/signature/JetSignatureReader.java b/stdlib/src/org/jetbrains/jet/rt/signature/JetSignatureReader.java index bda1063e04c..44112938959 100644 --- a/stdlib/src/org/jetbrains/jet/rt/signature/JetSignatureReader.java +++ b/stdlib/src/org/jetbrains/jet/rt/signature/JetSignatureReader.java @@ -107,6 +107,10 @@ public class JetSignatureReader { int pos, final JetSignatureVisitor v) { + if (signature.length() == 0) { + throw new IllegalStateException(); + } + char c; int start, end; boolean visited, inner; diff --git a/templatelib/src/TemplateCore.kt b/templatelib/src/TemplateCore.kt new file mode 100644 index 00000000000..c89004208fc --- /dev/null +++ b/templatelib/src/TemplateCore.kt @@ -0,0 +1,59 @@ +package std.template + +import std.io.* + +/** + * Represents a generic API to templates which should be usable + * in JavaScript in a browser or on the server side stand alone or in a web app etc. + * + * To make things easier to implement in JS this namespace won't refer to any java.io or servlet + * stuff + */ +trait Template { + var printer: Printer + + /** Renders the template to the output printer */ + fun render(): Unit +} + +/** + * Represents the output of a template which is a stream of objects + * usually strings which then write to some underlying output stream + * such as a java.io.Writer on the server side. + * + * We abstract away java.io.* APIs here to make the JS implementation simpler + */ +trait Printer { + fun print(value: Any): Unit + //fun print(text: String): Unit +} + +class NullPrinter() : Printer { + //override fun print(text: String) = none() + override fun print(value: Any) { + throw UnsupportedOperationException("No Printer defined on the Template") + } +} + +/** + * Base class for template implementations to hold any helpful behaviour + */ +abstract class TemplateSupport : Template { +} + +/** + * Base class for templates generating text output + * by printing values to some underlying Printer which + * will typically output to a String, File, stream etc. + */ +abstract class TextTemplate() : TemplateSupport, Printer { + override var printer: Printer = NullPrinter() + + fun String.plus(): Unit { + printer.print(this) + } + + //override fun print(value: String) = printer.print(value) + + override fun print(value: Any) = printer.print(value) +} diff --git a/templatelib/src/TemplateHtml.kt b/templatelib/src/TemplateHtml.kt new file mode 100644 index 00000000000..bd870fd3e07 --- /dev/null +++ b/templatelib/src/TemplateHtml.kt @@ -0,0 +1,122 @@ +package std.template.html + +import std.* +import std.template.* +import std.io.* +import std.util.* +import java.io.* +import java.util.* + + +trait Factory<T> { + fun create() : T +} + +abstract class Element + +class TextElement(val text : String) : Element + +abstract class Tag(val name : String) : Element { + val children = ArrayList<Element>() + val attributes = HashMap<String, String>() + + protected fun initTag<T : Element>(init : T.()-> Unit) : T + where class object T : Factory<T> { + val tag = T.create() + tag.init() + children.add(tag) + return tag + } +} + +abstract class TagWithText(name : String) : Tag(name) { + fun String.plus() { + children.add(TextElement(this)) + } +} + +class HTML() : TagWithText("html") { + class object : Factory<HTML> { + override fun create() = HTML() + } + + fun head(init : Head.()-> Unit) = initTag(init) + + fun body(init : Body.()-> Unit) = initTag(init) +} + +class Head() : TagWithText("head") { + class object : Factory<Head> { + override fun create() = Head() + } + + fun title(init : Title.()-> Unit) = initTag(init) +} + +class Title() : TagWithText("title") + +abstract class BodyTag(name : String) : TagWithText(name) { +} + +class Body() : BodyTag("body") { + class object : Factory<Body> { + override fun create() = Body() + } + + fun b(init : B.()-> Unit) = initTag(init) + fun p(init : P.()-> Unit) = initTag(init) + fun h1(init : H1.()-> Unit) = initTag(init) + + fun a(href : String) { + a(href) {} + } + + fun a(href : String, init : A.()-> Unit) { + val a = initTag(init) + a.href = href + } +} + +class B() : BodyTag("b") +class P() : BodyTag("p") +class H1() : BodyTag("h1") + +class A() : BodyTag("a") { + var href: String? = null + /* + TODO this doesn't compile + see http://youtrack.jetbrains.net/issue/KT-866 + + var href : String + get() = attributes["href"] + set(value) { attributes["href"] = value } + */ +} + +fun body(init: Body.()-> Unit): Body { + val elem = Body() + elem.init() + return elem +} + +fun html(init : HTML.()-> Unit) : HTML { + val html = HTML() + html.init() + return html +} + +/** + * Base class for templates which generate markup (XML or HTML for example) + * which have additional helper methods for escaping markup etc + */ +abstract class MarkupTemplate() : TemplateSupport { + + override fun render() { + val markup = markup() + print(markup) + } + + /** Returns the markup to be rendered */ + abstract fun markup(): Iterable<Element> +} + diff --git a/templatelib/src/TemplateJavaIo.kt b/templatelib/src/TemplateJavaIo.kt new file mode 100644 index 00000000000..79e33c79630 --- /dev/null +++ b/templatelib/src/TemplateJavaIo.kt @@ -0,0 +1,34 @@ +// Server side Java IO code to avoid coupling +// the core template code to java.* for easier JS porting +package std.template.io + +import std.template.* +import java.io.Writer +import java.io.OutputStream +import java.io.OutputStreamWriter +import java.io.PrintStream +import java.io.StringWriter + +/** + * A Printer implementation which uses a Writer + */ +class WriterPrinter(val writer: Writer) : Printer { + + override fun print(value: Any) { + // TODO should be using a formatter to do the conversion + writer.write(value.toString()) + } +} + +fun Template.renderToText(): String { + val buffer = StringWriter() + renderTo(buffer) + return buffer.toString().sure() +} + +fun Template.renderTo(writer: Writer): Unit { + this.printer = WriterPrinter(writer) + this.render() +} + +fun Template.renderTo(os: OutputStream): Unit = renderTo(OutputStreamWriter(os)) diff --git a/templatelib/templatelib.iml b/templatelib/templatelib.iml new file mode 100644 index 00000000000..148c33735b9 --- /dev/null +++ b/templatelib/templatelib.iml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="stdlib" /> + <orderEntry type="module" module-name="testlib" /> + </component> +</module> + diff --git a/templatelib/test/TemplateCoreTest.kt b/templatelib/test/TemplateCoreTest.kt new file mode 100644 index 00000000000..4a118a94f45 --- /dev/null +++ b/templatelib/test/TemplateCoreTest.kt @@ -0,0 +1,55 @@ +package std.template + +import std.* +import std.template.io.* +import std.io.* +import std.util.* +import std.test.* +import java.util.* + +class EmailTemplate(var name: String = "James", var time: Date = Date()) : TextTemplate() { + override fun render() { + print("Hello there $name and how are you? Today is $time. Kotlin rocks") + } +} + +/** + TODO compile error + http://youtrack.jetbrains.net/issue/KT-865 + +class MoreDryTemplate(var name: String = "James", var time: Date = Date()) : TextTemplate() { + override fun render() { + +"Hey there $name and how are you? Today is $time. Kotlin rocks" + } +} +*/ + +class TemplateCoreTest() : TestSupport() { + fun testDefaultValues() { + val text = EmailTemplate().renderToText() + assert { + println(text) + text.startsWith("Hello there James") + } + } + + fun testDifferentValues() { + val text = EmailTemplate("Andrey").renderToText() + assert { + println(text) + text.startsWith("Hello there Andrey") + } + } + + /* + TODO compile error + + fun testMoreDryTemplate() { + val text = MoreDryTemplate("Alex").renderToText() + assert { + println(text) + text.startsWith("Hey there Alex") + } + } + */ +} \ No newline at end of file diff --git a/templatelib/test/TemplateHtmlTest.kt b/templatelib/test/TemplateHtmlTest.kt new file mode 100644 index 00000000000..3367087c072 --- /dev/null +++ b/templatelib/test/TemplateHtmlTest.kt @@ -0,0 +1,79 @@ +package std.template.html + +import std.* +import std.template.* +import std.template.io.* +import std.io.* +import std.util.* +import std.test.* +import java.util.* + +/* + TODO generates compiler error + see: http://youtrack.jetbrains.net/issue/KT-866 + +val justBody = body { + +"Hello world" + } + +fun result(args : List<String>) = + html { + head { + title {+"XML encoding with Kotlin"} + } + body { + h1 {+"XML encoding with Kotlin"} + p {+"this format can be used as an alternative markup to XML"} + + // an element with attributes and text content + a(href = "http://jetbrains.com/kotlin") {+"Kotlin"} + + // mixed content + p { + +"This is some" + b {+"mixed"} + +"text. For more see the" + a(href = "http://jetbrains.com/kotlin") {+"Kotlin"} + +"project" + } + p {+"some text"} + + // content generated by + p { + for (arg in args) + +arg + } + } + } +*/ + +class TemplateHtmlTest() : TestSupport() { + fun testNoneCompileYet() { + } + +/* + TODO: compiler bug + see: http://youtrack.jetbrains.net/issue/KT-866 + + fun testJustBody() { + println(justBody) + } + + fun testHtmlFunction() { + val text = result(arrayList("a", "b", "c")) + println(text) + } + + fun testEmbeddedFunction() { + val e = html { + head { + title {+"XML encoding with Kotlin"} + } + body { + a("http://jetbrains.com/kotlin") + } + } + println(e) + } +*/ +} \ No newline at end of file diff --git a/templatelib/test/std/template/TemplateTestAll.java b/templatelib/test/std/template/TemplateTestAll.java new file mode 100644 index 00000000000..08e1e34d138 --- /dev/null +++ b/templatelib/test/std/template/TemplateTestAll.java @@ -0,0 +1,13 @@ +package std.template; + +import std.template.html.*; + +import junit.framework.TestSuite; + +/** + */ +public class TemplateTestAll { + public static TestSuite suite() { + return new TestSuite(TemplateCoreTest.class, TemplateHtmlTest.class); + } +} diff --git a/testlib/src/Test.kt b/testlib/src/Test.kt index 80fc3550f26..7694865d2a1 100644 --- a/testlib/src/Test.kt +++ b/testlib/src/Test.kt @@ -1,4 +1,4 @@ -namespace std.test +package std.test import std.io.* import std.util.* @@ -9,18 +9,73 @@ import org.junit.runner.* import org.junit.runner.notification.* import junit.framework.* -fun assert(message: String, block: fun() : Boolean) { +class BuiltTest<T>(name: String, val builder: TestBuilder<T>, val test: BuiltTest<T>.() -> Unit) : TestCase(name) { + private var myState: T? = null + + var state : T + get() = myState.sure() + set(newState: T) { myState = newState } + + override fun countTestCases(): Int = 1 + + var name : String + get() = super.getName().sure() + set(newName: String) = super.setName(newName) + + override fun setUp() = this.(builder.setUp)() + + override fun tearDown() = this.(builder.tearDown)() + + override fun runTest() = this.(test)() +} + +open class TestBuilder<T>(name: String) { + val mySuite = TestSuite(name) + + var setUp : BuiltTest<T>.() -> Unit = {} + + var tearDown : BuiltTest<T>.() -> Unit = {} + + fun String.minus(test: BuiltTest<T>.() -> Unit) { + mySuite.addTest(BuiltTest<T>(this, this@TestBuilder, test)) + } +} + +private val currentTestBuilder = ThreadLocal<TestSuite> () + +private fun <T> testSuite(builder: TestBuilder<T>, description: TestBuilder<T>.() -> Unit) : TestSuite? { + val currentTestSuite = currentTestBuilder.get() + currentTestBuilder.set(builder.mySuite) + try { + builder.(description)() + return if(currentTestSuite != null) { + currentTestSuite.addTest(builder.mySuite) + null + } + else { + builder.mySuite + } + } + finally { + currentTestBuilder.set(currentTestSuite) + } +} + +fun <T> testSuite(name: String, description: TestBuilder<T>.() -> Unit) : TestSuite? = + testSuite(TestBuilder<T>(name), description) + +fun assert(message: String, block: ()-> Boolean) { val actual = block() Assert.assertTrue(message, actual) } -fun assert(block: fun() : Boolean) = assert(block.toString(), block) +fun assert(block: ()-> Boolean) = assert(block.toString(), block) -fun assertNot(message: String, block: fun() : Boolean) { +fun assertNot(message: String, block: ()-> Boolean) { assert(message){ !block() } } -fun assertNot(block: fun() : Boolean) = assertNot(block.toString(), block) +fun assertNot(block: ()-> Boolean) = assertNot(block.toString(), block) fun assert(actual: Boolean, message: String) { println("Answer: ${actual} for ${message}") @@ -34,7 +89,7 @@ fun assertNull(actual: Any?, message: String = "") { Assert.assertNull(message, actual) } -fun fails(block: fun() : Any) { +fun fails(block: ()-> Any) { try { block() Assert.fail("Expected an exception to be thrown") @@ -43,7 +98,7 @@ fun fails(block: fun() : Any) { } } -fun todo(block: fun(): Any) { +fun todo(block: ()-> Any) { println("TODO at " + Exception().getStackTrace()?.get(1) + " for " + block) } diff --git a/testlib/test/CollectionApiCheck.kt b/testlib/test/CollectionApiCheck.kt index 4396cc2617d..8035f455fba 100644 --- a/testlib/test/CollectionApiCheck.kt +++ b/testlib/test/CollectionApiCheck.kt @@ -1,4 +1,4 @@ -namespace test.apicheck +package test.apicheck import std.util.* import java.util.* @@ -6,24 +6,24 @@ import java.util.* trait Traversable<T> { /** Returns true if any elements in the collection match the given predicate */ - fun any(predicate: fun(T): Boolean) : Boolean + fun any(predicate: (T)-> Boolean) : Boolean /** Returns true if all elements in the collection match the given predicate */ - fun all(predicate: fun(T): Boolean) : Boolean + fun all(predicate: (T)-> Boolean) : Boolean /** Returns the first item in the collection which matches the given predicate or null if none matched */ - fun find(predicate: fun(T): Boolean) : T? + fun find(predicate: (T)-> Boolean) : T? /** Returns a new collection containing all elements in this collection which match the given predicate */ // TODO using: Collection<T> for the return type - I wonder if this exact type could be // deduced somewhat from the This.Type; e.g. returning Set on a Set, Array on Array etc - fun filter(predicate: fun(T): Boolean) : Collection<T> + fun filter(predicate: (T)-> Boolean) : Collection<T> /** Performs the given operation on each element inside the collection */ - fun foreach(operation: fun(element: T) : Unit) + fun foreach(operation: (element: T)-> Unit) /** Returns a new collection containing the results of applying the given function to each element in this collection */ - fun <T, R> java.lang.Iterable<T>.map(transform : fun(T) : R) : Collection<R> + fun <T, R> java.lang.Iterable<T>.map(transform : (T)-> R) : Collection<R> } /** diff --git a/testlib/test/CollectionTest.kt b/testlib/test/CollectionTest.kt index eb079534850..5fc1a980b4a 100644 --- a/testlib/test/CollectionTest.kt +++ b/testlib/test/CollectionTest.kt @@ -1,4 +1,4 @@ -namespace test.collections +package test.collections // TODO can we avoid importing all this stuff by default I wonder? // e.g. making println and the collection builder methods public by default? @@ -25,10 +25,16 @@ class CollectionTest() : TestSupport() { data.all{it.length == 3} } assertNot { - data.all{s => s.startsWith("b")} + data.all{s -> s.startsWith("b")} } } + fun testCount() { + assertEquals(1, data.count{it.startsWith("b")}) + // TODO size should implement size property to be polymorphic with collections + assertEquals(2, data.count{it.length == 3}) + } + fun testFilter() { val foo = data.filter{it.startsWith("f")} @@ -39,6 +45,16 @@ class CollectionTest() : TestSupport() { assertEquals(arrayList("foo"), foo) } + fun testFilterNot() { + val foo = data.filterNot{it.startsWith("b")} + + assert { + foo.all{it.startsWith("f")} + } + assertEquals(1, foo.size) + assertEquals(arrayList("foo"), foo) + } + fun testFilterIntoLinkedList() { // TODO would be nice to avoid the <String> val foo = data.filter(linkedList<String>()){it.startsWith("f")} @@ -82,17 +98,11 @@ class CollectionTest() : TestSupport() { } fun testFlatMap() { - /** - TODO compiler bug - we should be able to remove the explicit type on the function - http://youtrack.jetbrains.net/issue/KT-849 - */ - // TODO there should be a neater way to do this :) - val characters = arrayList('f', 'o', 'o', 'b', 'a', 'r') + // TODO figure out how to get a line like this to compile :) /* val characters = data.flatMap<String,Character>{ - Arrays.asList((it as java.lang.String).toCharArray()) as Collection<Character> + it.toCharArray().toList() as Collection<Character> } */ todo { @@ -108,6 +118,24 @@ class CollectionTest() : TestSupport() { assertEquals(6, count) } + fun testGroupBy() { + val words = arrayList("a", "ab", "abc", "def", "abcd") + /* + TODO inference engine should not need this type info? + */ + val byLength = words.groupBy<String,Int>{it.length} + assertEquals(4, byLength.size()) + + println("Grouped by length is: $byLength") + /* + TODO compiler bug... + + val l3 = byLength.getOrElse(3, {ArrayList<String>()}) + assertEquals(2, l3.size) + */ + + } + fun testJoin() { val text = data.join("-", "<", ">") assertEquals("<foo-bar>", text) @@ -119,7 +147,7 @@ class CollectionTest() : TestSupport() { we should be able to remove the explicit type on the function http://youtrack.jetbrains.net/issue/KT-849 */ - val lengths = data.map<String,Int>{s => s.length} + val lengths = data.map<String,Int>{s -> s.length} assert { lengths.all{it == 3} } @@ -149,5 +177,4 @@ class CollectionTest() : TestSupport() { } } } - } \ No newline at end of file diff --git a/testlib/test/GenerateStandardLib.kt b/testlib/test/GenerateStandardLib.kt new file mode 100644 index 00000000000..3903cf717d5 --- /dev/null +++ b/testlib/test/GenerateStandardLib.kt @@ -0,0 +1,83 @@ +package kotlin.tools + +import std.* +import std.io.* +import std.util.* +import java.io.* +import java.util.* + +fun generateFile(outFile: File, header: String, inputFile: File, f: (String)-> String) { + println("Parsing $inputFile and writing $outFile") + + outFile.getParentFile()?.mkdirs() + val writer = PrintWriter(FileWriter(outFile)) + try { + writer.println("// NOTE this file is auto-generated from $inputFile") + writer.println(header) + + val reader = FileReader(inputFile).buffered() + try { + // TODO ideally we'd use a filterNot() here :) + val iter = reader.lineIterator() + while (iter.hasNext) { + val line = iter.next() + + if (line.startsWith("package")) continue + + val xform = f(line) + writer.println(xform) + } + } finally { + reader.close() + reader.close() + } + } finally { + writer.close() + } +} + + +/** + * Generates methods in the standard library which are mostly identical + * but just using a different input kind. + * + * Kinda like mimicking source macros here, but this avoids the inefficiency of type conversions + * at runtime. + */ +fun main(args: Array<String>) { + var stdlib = File("stdlib") + if (!stdlib.exists()) { + stdlib = File("../stdlib") + if (!stdlib.exists()) { + println("Cannot find stdlib!") + return + } + } + val srcDir = File(stdlib, "ktSrc") + val outDir = File(srcDir, "generated") + + + // JavaIterables - Generic iterable stuff + generateFile(File(outDir, "ArraysFromJavaIterables.kt"), "package std", File(srcDir, "JavaIterables.kt")) { + it.replaceAll("java.lang.Iterable<T>", "Array<T>") + } + + generateFile(File(outDir, "StandardFromJavaIterables.kt"), "package std", File(srcDir, "JavaIterables.kt")) { + it.replaceAll("java.lang.Iterable<T>", "Iterable<T>") + } + + + // JavaCollections - methods returning a collection of the same input size (if its a collection) + + generateFile(File(outDir, "ArraysFromJavaCollections.kt"), "package std", File(srcDir, "JavaCollections.kt")) { + it.replaceAll("java.util.Collection<T>", "Array<T>") + } + + generateFile(File(outDir, "JavaUtilIterablesFromJavaCollections.kt"), "package std.util", File(srcDir, "JavaCollections.kt")) { + it.replaceAll("java.util.Collection<T>", "java.lang.Iterable<T>").replaceAll("(this.size)", "") + } + + generateFile(File(outDir, "StandardFromJavaCollections.kt"), "package std", File(srcDir, "JavaCollections.kt")) { + it.replaceAll("java.util.Collection<T>", "Iterable<T>").replaceAll("(this.size)", "") + } +} \ No newline at end of file diff --git a/testlib/test/HelloWorld.txt b/testlib/test/HelloWorld.txt new file mode 100644 index 00000000000..ed81d07f67b --- /dev/null +++ b/testlib/test/HelloWorld.txt @@ -0,0 +1,2 @@ +Hello +World \ No newline at end of file diff --git a/testlib/test/IoTest.kt b/testlib/test/IoTest.kt new file mode 100644 index 00000000000..450779e7d60 --- /dev/null +++ b/testlib/test/IoTest.kt @@ -0,0 +1,51 @@ +package test.collections + +import std.test.* + +import std.io.* +import std.util.* +import java.io.* +import java.util.* + +class IoTest() : TestSupport() { + val file = File("test/HelloWorld.txt") + + fun testLineIteratorWithManualClose() { + val reader = FileReader(file).buffered() + try { + val list = reader.lineIterator().toArrayList() + assertEquals(arrayList("Hello", "World"), list) + } finally { + reader.close() + } + } + + + fun testLineIterator() { + /* + // TODO compiler error + // both these expressions causes java.lang.NoClassDefFoundError: collections/namespace + val list = FileReader(file).useLines{it.toArrayList()} + val list = FileReader(file).useLines<ArrayList<String>>{it.toArrayList()} + + assertEquals(arrayList("Hello", "World"), list) + */ + } + + fun testUse() { + /** + val list = ArrayList<String>() + val reader = FileReader(file).buffered() + + TODO compiler error? + reader.use{ + val line = it.readLine() + if (line != null) { + list.add(line) + } + } + + assertEquals(arrayList("Hello", "World"), list) + */ + } +} \ No newline at end of file diff --git a/testlib/test/ListTest.kt b/testlib/test/ListTest.kt index 85ea7007ba9..91cf6ff367d 100644 --- a/testlib/test/ListTest.kt +++ b/testlib/test/ListTest.kt @@ -1,4 +1,4 @@ -namespace test.collections +package test.collections import std.test.* diff --git a/testlib/test/MapTest.kt b/testlib/test/MapTest.kt new file mode 100644 index 00000000000..d4b00f9f6ff --- /dev/null +++ b/testlib/test/MapTest.kt @@ -0,0 +1,43 @@ +package test.collections + +import std.test.* + +// TODO can we avoid importing all this stuff by default I wonder? +// e.g. making println and the collection builder methods public by default? +import std.* +import std.io.* +import std.util.* +import java.util.* + +class MapTest() : TestSupport() { + val data: Map<String,Int> = HashMap<String, Int>() + + fun testGetOrElse() { + val a = data.getOrElse("foo"){2} + assertEquals(2, a) + + val b = data.getOrElse("foo"){3} + assertEquals(3, b) + + // TODO should be able to miss the () off of size + assertEquals(0, data.size()) + } + + fun testGetOrElseUpdate() { + val a = data.getOrElseUpdate("foo"){2} + assertEquals(2, a) + + val b = data.getOrElseUpdate("foo"){3} + assertEquals(2, b) + + assertEquals(1, data.size()) + } + + /** TODO can't seem to define size/empty properties for Map + fun testSizeAndEmpty() { + assert{ data.empty } + + assertEquals(data.size, 0) + } + */ +} \ No newline at end of file diff --git a/testlib/test/SetTest.kt b/testlib/test/SetTest.kt index 3ae835dd029..ee03be580a6 100644 --- a/testlib/test/SetTest.kt +++ b/testlib/test/SetTest.kt @@ -1,4 +1,4 @@ -namespace test.collections +package test.collections import std.* import std.io.* @@ -23,24 +23,21 @@ class SetTest() : TestSupport() { data.all{it.length == 3} } assertNot { - data.all{s => s.startsWith("b")} + data.all{(s: String) -> s.startsWith("b")} } } fun testFilter() { - val foo = data.filter{it.startsWith("f")} + val foo = data.filter{it.startsWith("f")}.toSet() assert { foo.all{it.startsWith("f")} } assertEquals(1, foo.size) - assertEquals(arrayList("foo"), foo) + assertEquals(hashSet("foo"), foo) - // TODO ideally foo would now be a set - todo { - assert("Filter on a Set should return a Set") { - foo is Set<String> - } + assert("Filter on a Set should return a Set") { + foo is Set<String> } } @@ -62,7 +59,7 @@ class SetTest() : TestSupport() { we should be able to remove the explicit type on the function http://youtrack.jetbrains.net/issue/KT-849 */ - val lengths = data.map<String,Int>{s => s.length} + val lengths = data.map<String,Int>{(s: String) -> s.length} assert { lengths.all{it == 3} } diff --git a/testlib/test/TestDslExample.kt b/testlib/test/TestDslExample.kt new file mode 100644 index 00000000000..3f8c1b59aff --- /dev/null +++ b/testlib/test/TestDslExample.kt @@ -0,0 +1,60 @@ +package testDslExample + +import std.io.* +import std.test.* + +import junit.framework.* +import junit.textui.TestRunner + +val suite = testSuite<Int>("test group") { + var staticState = 10 + + setUp = { + staticState += 10 + state = staticState + println("test '$name' started") + } + + tearDown = { + println("test '$name' ended") + } + + "test 1" - { + Assert.assertEquals(state, 20) + println("test '$name': state: $state") + } + + "test 2" - { + assert(state == 31, "message") + println("test '$name': state: $state") + } + + "test 3" - { + Assert.assertEquals(state, 40) + println("test '$name': state: $state") + } + + testSuite<Any>("nested test suite") { + setUp = { + staticState += 10 + state = staticState + println("nested test '$name' started") + } + + tearDown = { + println("nested test '$name' ended") + } + + "nested test 1" - { + println("test '$name'") + } + + "nested test 2" - { + println("test '$name'") + } + + "nested test 3" - { + println("test '$name'") + } + } +} diff --git a/testlib/test/test/collections/TestAll.java b/testlib/test/test/collections/TestAll.java new file mode 100644 index 00000000000..7d465c5b03e --- /dev/null +++ b/testlib/test/test/collections/TestAll.java @@ -0,0 +1,13 @@ +package test.collections; + +import junit.framework.TestSuite; + +/** + */ +public class TestAll { + public static TestSuite suite() { + TestSuite suite = new TestSuite(CollectionTest.class, IoTest.class, ListTest.class, MapTest.class, SetTest.class); + suite.addTest(testDslExample.namespace.getSuite()); + return suite; + } +} \ No newline at end of file