From 6ce0b9b91949aa417c021f8646040ac8605af453 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 17 Jan 2014 19:24:25 +0400 Subject: [PATCH] Annotations used instead of List --- .idea/kotlinc.xml | 3 ++ .../AccessorForFunctionDescriptor.java | 4 +- .../AccessorForPropertyDescriptor.java | 8 ++-- .../jet/codegen/ClassBodyCodegen.java | 4 +- .../jetbrains/jet/codegen/CodegenUtil.java | 4 +- .../jet/codegen/PackagePartCodegen.java | 4 +- .../jet/codegen/PropertyCodegen.java | 2 +- .../jet/codegen/context/CodegenContext.java | 4 +- .../jet/codegen/context/RootContext.java | 6 +-- .../serialization/DescriptorDeserializer.java | 12 ++--- .../serialization/DescriptorSerializer.java | 2 +- .../serialization/TypeDeserializer.java | 6 +-- .../descriptors/AnnotationDeserializer.java | 18 ++++---- .../DeserializedClassDescriptor.java | 17 +++---- .../DeserializedSimpleFunctionDescriptor.java | 8 ++-- .../impl/LocalVariableDescriptor.java | 6 +-- .../jet/lang/resolve/AnnotationResolver.java | 24 +++++----- .../jet/lang/resolve/AnnotationUtils.java | 29 ++++++------ .../jet/lang/resolve/DeclarationResolver.java | 4 +- .../jet/lang/resolve/DescriptorResolver.java | 18 ++++---- .../lang/resolve/ScriptHeaderResolver.java | 5 +-- .../jet/lang/resolve/TypeResolver.java | 6 +-- .../resolve/calls/ArgumentTypeResolver.java | 6 +-- .../lang/resolve/calls/CallResolverUtil.java | 8 ---- .../util/ExpressionAsFunctionDescriptor.java | 11 ++--- .../lazy/descriptors/LazyClassDescriptor.java | 17 +++---- .../descriptors/LazyPackageDescriptor.java | 8 ++-- .../jet/lang/types/DeferredType.java | 4 +- .../BasicExpressionTypingVisitor.java | 5 ++- .../ClosureExpressionsTypingVisitor.java | 8 ++-- .../ControlStructureTypingUtils.java | 17 +++---- .../jetbrains/jet/types/TypeUnifierTest.java | 5 +-- .../java/descriptor/JavaMethodDescriptor.java | 6 +-- .../JavaPackageFragmentDescriptorImpl.java | 6 +-- .../descriptor/JavaPropertyDescriptor.java | 6 +-- .../lang/resolve/java/lazy/annotationUtils.kt | 12 ++--- .../descriptors/LazyJavaClassDescriptor.kt | 7 ++- .../descriptors/LazyJavaClassMemberScope.kt | 7 +-- .../descriptors/LazyJavaPackageFragment.kt | 3 +- .../resolve/java/lazy/types/LazyJavaType.kt | 4 +- .../java/resolver/JavaAnnotationResolver.java | 10 +++-- .../resolver/JavaConstructorResolver.java | 8 ++-- .../resolver/JavaTypeParameterResolver.java | 9 ++-- .../java/resolver/JavaTypeTransformer.java | 4 +- .../java/sam/SingleAbstractMethodUtils.java | 6 +-- .../AnnotationDescriptorDeserializer.java | 28 ++++++------ .../descriptors/ModuleDescriptorImpl.java | 8 ++-- .../lang/descriptors/ScriptDescriptor.java | 9 ++-- .../descriptors/annotations/Annotated.java | 6 +-- .../annotations/AnnotatedImpl.java | 8 ++-- .../descriptors/annotations/Annotations.java | 44 +++++++++++++++++++ .../annotations/AnnotationsImpl.java | 42 ++++++++++++++++++ .../AbstractLazyTypeParameterDescriptor.java | 7 +-- .../AbstractReceiverParameterDescriptor.java | 4 +- .../impl/AnonymousFunctionDescriptor.java | 6 +-- .../descriptors/impl/ClassDescriptorImpl.java | 8 ++-- .../impl/ConstructorDescriptorImpl.java | 9 ++-- .../impl/DeclarationDescriptorImpl.java | 6 +-- .../DeclarationDescriptorNonRootImpl.java | 6 +-- .../EnumEntrySyntheticClassDescriptor.java | 5 ++- .../impl/FunctionDescriptorImpl.java | 6 +-- .../impl/LazySubstitutingClassDescriptor.java | 4 +- .../impl/MutableClassDescriptorLite.java | 15 ++++--- .../MutablePackageFragmentDescriptor.java | 6 +-- .../impl/PackageViewDescriptorImpl.java | 5 +-- .../impl/PropertyAccessorDescriptorImpl.java | 4 +- .../impl/PropertyDescriptorImpl.java | 12 ++--- .../impl/PropertyGetterDescriptorImpl.java | 6 +-- .../impl/PropertySetterDescriptorImpl.java | 7 +-- .../impl/ScriptCodeDescriptor.java | 4 +- .../impl/SimpleFunctionDescriptorImpl.java | 6 +-- .../impl/TypeParameterDescriptorImpl.java | 11 +++-- .../impl/ValueParameterDescriptorImpl.java | 10 ++--- .../impl/VariableDescriptorImpl.java | 6 +-- .../jet/lang/resolve/DescriptorFactory.java | 14 +++--- .../constants/IntegerValueTypeConstant.java | 4 +- .../IntegerValueTypeConstructor.java | 6 +-- .../jet/lang/types/CommonSupertypes.java | 4 +- .../jetbrains/jet/lang/types/ErrorUtils.java | 11 ++--- .../types/IntersectionTypeConstructor.java | 4 +- .../jetbrains/jet/lang/types/JetTypeImpl.java | 12 ++--- .../jetbrains/jet/lang/types/PackageType.java | 4 +- .../jet/lang/types/TypeConstructorImpl.java | 4 +- .../jetbrains/jet/lang/types/TypeUtils.java | 15 +++---- .../types/error/ErrorClassDescriptor.java | 4 +- .../ErrorSimpleFunctionDescriptorImpl.java | 7 +-- .../types/lang/BuiltinsPackageFragment.java | 4 +- .../jet/lang/types/lang/InlineUtil.java | 7 ++- .../jet/lang/types/lang/KotlinBuiltIns.java | 21 +++++---- .../plugin/project/ResolveElementCache.java | 2 +- .../general/JetTestFunctionDetector.java | 17 ++++--- 91 files changed, 433 insertions(+), 376 deletions(-) create mode 100644 core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/Annotations.java create mode 100644 core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotationsImpl.java diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml index 4aa82ece3df..4fadd011de8 100644 --- a/.idea/kotlinc.xml +++ b/.idea/kotlinc.xml @@ -1,5 +1,8 @@ + + diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AccessorForFunctionDescriptor.java b/compiler/backend/src/org/jetbrains/jet/codegen/AccessorForFunctionDescriptor.java index be1ac519d9d..640d5234102 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AccessorForFunctionDescriptor.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AccessorForFunctionDescriptor.java @@ -18,7 +18,7 @@ package org.jetbrains.jet.codegen; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.name.Name; @@ -35,7 +35,7 @@ public class AccessorForFunctionDescriptor extends SimpleFunctionDescriptorImpl @NotNull DeclarationDescriptor containingDeclaration, int index ) { - super(containingDeclaration, Collections.emptyList(), + super(containingDeclaration, Annotations.EMPTY, Name.identifier((descriptor instanceof ConstructorDescriptor ? "$init" : descriptor.getName()) + "$b$" + index), Kind.DECLARATION); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AccessorForPropertyDescriptor.java b/compiler/backend/src/org/jetbrains/jet/codegen/AccessorForPropertyDescriptor.java index a215d32a759..ac6d40c8c45 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AccessorForPropertyDescriptor.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AccessorForPropertyDescriptor.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.codegen; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.PropertyGetterDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.PropertySetterDescriptorImpl; @@ -43,7 +43,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl { @NotNull DeclarationDescriptor containingDeclaration, int index ) { - super(containingDeclaration, Collections.emptyList(), Modality.FINAL, Visibilities.LOCAL, + super(containingDeclaration, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL, original.isVar(), Name.identifier(original.getName() + "$b$" + index), Kind.DECLARATION); @@ -53,7 +53,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl { public static class Getter extends PropertyGetterDescriptorImpl { public Getter(AccessorForPropertyDescriptor property) { - super(property, Collections.emptyList(), Modality.FINAL, Visibilities.LOCAL, + super(property, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL, false, false, Kind.DECLARATION); initialize(property.getType()); @@ -62,7 +62,7 @@ public class AccessorForPropertyDescriptor extends PropertyDescriptorImpl { public static class Setter extends PropertySetterDescriptorImpl { public Setter(AccessorForPropertyDescriptor property) { - super(property, Collections.emptyList(), Modality.FINAL, Visibilities.LOCAL, + super(property, Annotations.EMPTY, Modality.FINAL, Visibilities.LOCAL, false, false, Kind.DECLARATION); initializeDefault(); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java index 9b0f68bb72a..dc9b29acd4a 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java @@ -23,7 +23,7 @@ import org.jetbrains.asm4.Type; import org.jetbrains.jet.codegen.context.ClassContext; import org.jetbrains.jet.codegen.state.GenerationState; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -180,7 +180,7 @@ public abstract class ClassBodyCodegen extends MemberCodegen { MethodVisitor method = createOrGetClInitMethod(); method.visitCode(); SimpleFunctionDescriptorImpl clInit = - new SimpleFunctionDescriptorImpl(descriptor, Collections.emptyList(), + new SimpleFunctionDescriptorImpl(descriptor, Annotations.EMPTY, Name.special(""), CallableMemberDescriptor.Kind.SYNTHESIZED); clInit.initialize(null, null, Collections.emptyList(), diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java index 71438a80aa2..752f2eb662d 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java @@ -28,7 +28,7 @@ import org.jetbrains.jet.codegen.context.CodegenContext; import org.jetbrains.jet.codegen.context.PackageContext; import org.jetbrains.jet.codegen.state.JetTypeMapper; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.jet.lang.resolve.DescriptorUtils; @@ -67,7 +67,7 @@ public class CodegenUtil { SimpleFunctionDescriptorImpl invokeDescriptor = new SimpleFunctionDescriptorImpl( fd.getExpectedThisObject() != null ? KotlinBuiltIns.getInstance().getExtensionFunction(arity) : KotlinBuiltIns.getInstance().getFunction(arity), - Collections.emptyList(), + Annotations.EMPTY, Name.identifier("invoke"), CallableMemberDescriptor.Kind.DECLARATION); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/PackagePartCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/PackagePartCodegen.java index 174fbb2091c..ce2e7fda1da 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/PackagePartCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/PackagePartCodegen.java @@ -25,7 +25,7 @@ import org.jetbrains.asm4.Type; import org.jetbrains.jet.codegen.context.FieldOwnerContext; import org.jetbrains.jet.codegen.state.GenerationState; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; @@ -108,7 +108,7 @@ public class PackagePartCodegen extends MemberCodegen { FrameMap frameMap = new FrameMap(); SimpleFunctionDescriptorImpl clInit = - new SimpleFunctionDescriptorImpl(this.descriptor, Collections.emptyList(), + new SimpleFunctionDescriptorImpl(this.descriptor, Annotations.EMPTY, Name.special(""), CallableMemberDescriptor.Kind.SYNTHESIZED); clInit.initialize(null, null, Collections.emptyList(), diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java index 5326784697b..bc5308c5f77 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java @@ -149,7 +149,7 @@ public class PropertyCodegen extends GenerationStateAware { // Annotations on properties without backing fields are stored in bytecode on an empty synthetic method. This way they're still // accessible via reflection, and 'deprecated' and 'private' flags prevent this method from being called accidentally private void generateSyntheticMethodIfNeeded(@NotNull PropertyDescriptor descriptor) { - if (descriptor.getAnnotations().isEmpty()) return; + if (descriptor.getAnnotations().getAnnotationDescriptors().isEmpty()) return; ReceiverParameterDescriptor receiver = descriptor.getReceiverParameter(); Type receiverAsmType = receiver == null ? null : typeMapper.mapType(receiver.getType()); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java index 5fbb91f4388..ef435758bf8 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/CodegenContext.java @@ -26,7 +26,7 @@ import org.jetbrains.jet.codegen.binding.MutableClosure; import org.jetbrains.jet.codegen.state.GenerationState; import org.jetbrains.jet.codegen.state.JetTypeMapper; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.DescriptorUtils; @@ -190,7 +190,7 @@ public abstract class CodegenContext { @NotNull public ConstructorContext intoConstructor(@Nullable ConstructorDescriptor descriptor, @Nullable MutableClosure closure) { if (descriptor == null) { - descriptor = new ConstructorDescriptorImpl(getThisDescriptor(), Collections.emptyList(), true) + descriptor = new ConstructorDescriptorImpl(getThisDescriptor(), Annotations.EMPTY, true) .initialize(Collections.emptyList(), Collections.emptyList(), Visibilities.PUBLIC); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/context/RootContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/context/RootContext.java index 44187e8b9f2..94946f7cdd2 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/context/RootContext.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/context/RootContext.java @@ -20,12 +20,10 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.codegen.OwnerKind; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.TypeSubstitutor; -import java.util.List; - class RootContext extends CodegenContext { public RootContext() { super(new FakeDescriptor(), OwnerKind.PACKAGE, null, null, null, null); @@ -70,7 +68,7 @@ class RootContext extends CodegenContext { @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { throw new IllegalStateException(); } diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/DescriptorDeserializer.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/DescriptorDeserializer.java index 4100b8d8249..ffa24c715ca 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/DescriptorDeserializer.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/DescriptorDeserializer.java @@ -23,6 +23,8 @@ import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedSimpl import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedTypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationsImpl; import org.jetbrains.jet.lang.descriptors.impl.*; import org.jetbrains.jet.lang.resolve.DescriptorFactory; import org.jetbrains.jet.lang.resolve.DescriptorUtils; @@ -248,11 +250,11 @@ public class DescriptorDeserializer { } @NotNull - private List getAnnotations(@NotNull Callable proto, int flags, @NotNull AnnotatedCallableKind kind) { + private Annotations getAnnotations(@NotNull Callable proto, int flags, @NotNull AnnotatedCallableKind kind) { return getAnnotations(containingDeclaration, proto, flags, kind, annotationDeserializer, nameResolver); } - public static List getAnnotations( + public static Annotations getAnnotations( @NotNull DeclarationDescriptor containingDeclaration, @NotNull Callable proto, int flags, @@ -265,7 +267,7 @@ public class DescriptorDeserializer { return Flags.HAS_ANNOTATIONS.get(flags) ? annotationDeserializer .loadCallableAnnotations((ClassOrPackageFragmentDescriptor) containingDeclaration, proto, nameResolver, kind) - : Collections.emptyList(); + : Annotations.EMPTY; } public static CallableMemberDescriptor.Kind memberKind(Callable.MemberKind memberKind) { @@ -393,7 +395,7 @@ public class DescriptorDeserializer { } @NotNull - private List getAnnotations( + private Annotations getAnnotations( @NotNull ClassOrPackageFragmentDescriptor classOrPackage, @NotNull Callable callable, @NotNull AnnotatedCallableKind kind, @@ -401,6 +403,6 @@ public class DescriptorDeserializer { ) { return Flags.HAS_ANNOTATIONS.get(valueParameter.getFlags()) ? annotationDeserializer.loadValueParameterAnnotations(classOrPackage, callable, nameResolver, kind, valueParameter) - : Collections.emptyList(); + : Annotations.EMPTY; } } diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/DescriptorSerializer.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/DescriptorSerializer.java index 4b937398c67..7c9bef68d6d 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/DescriptorSerializer.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/DescriptorSerializer.java @@ -431,7 +431,7 @@ public class DescriptorSerializer { } private static boolean hasAnnotations(Annotated descriptor) { - return !descriptor.getAnnotations().isEmpty(); + return !descriptor.getAnnotations().getAnnotationDescriptors().isEmpty(); } @NotNull diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java index 4de8f5fd71a..df131a928d0 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/TypeDeserializer.java @@ -25,7 +25,7 @@ import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedTypeP import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.storage.MemoizedFunctionToNullable; @@ -270,8 +270,8 @@ public class TypeDeserializer { @NotNull @Override - public List getAnnotations() { - return Collections.emptyList(); + public Annotations getAnnotations() { + return Annotations.EMPTY; } } } diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/AnnotationDeserializer.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/AnnotationDeserializer.java index b818a09fa3c..213d84a5973 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/AnnotationDeserializer.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/AnnotationDeserializer.java @@ -21,21 +21,19 @@ import org.jetbrains.jet.descriptors.serialization.NameResolver; import org.jetbrains.jet.descriptors.serialization.ProtoBuf; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ClassOrPackageFragmentDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; - -import java.util.List; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; public interface AnnotationDeserializer { AnnotationDeserializer UNSUPPORTED = new AnnotationDeserializer() { @NotNull @Override - public List loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto) { + public Annotations loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto) { return notSupported(); } @NotNull @Override - public List loadCallableAnnotations( + public Annotations loadCallableAnnotations( @NotNull ClassOrPackageFragmentDescriptor container, @NotNull ProtoBuf.Callable proto, @NotNull NameResolver nameResolver, @@ -46,7 +44,7 @@ public interface AnnotationDeserializer { @NotNull @Override - public List loadValueParameterAnnotations( + public Annotations loadValueParameterAnnotations( @NotNull ClassOrPackageFragmentDescriptor container, @NotNull ProtoBuf.Callable callable, @NotNull NameResolver nameResolver, @@ -57,7 +55,7 @@ public interface AnnotationDeserializer { } @NotNull - private List notSupported() { + private Annotations notSupported() { throw new UnsupportedOperationException("Annotations are not supported"); } }; @@ -70,10 +68,10 @@ public interface AnnotationDeserializer { } @NotNull - List loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto); + Annotations loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto); @NotNull - List loadCallableAnnotations( + Annotations loadCallableAnnotations( @NotNull ClassOrPackageFragmentDescriptor container, @NotNull ProtoBuf.Callable proto, @NotNull NameResolver nameResolver, @@ -81,7 +79,7 @@ public interface AnnotationDeserializer { ); @NotNull - List loadValueParameterAnnotations( + Annotations loadValueParameterAnnotations( @NotNull ClassOrPackageFragmentDescriptor container, @NotNull ProtoBuf.Callable callable, @NotNull NameResolver nameResolver, diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/DeserializedClassDescriptor.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/DeserializedClassDescriptor.java index fab86d09a20..6d9ac135912 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/DeserializedClassDescriptor.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/DeserializedClassDescriptor.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.descriptors.serialization.*; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.AbstractClassDescriptor; import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.EnumEntrySyntheticClassDescriptor; @@ -59,7 +60,7 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme private final NullableLazyValue primaryConstructor; private final AnnotationDeserializer annotationDeserializer; - private final NotNullLazyValue> annotations; + private final NotNullLazyValue annotations; private final NullableLazyValue classObjectDescriptor; @@ -114,9 +115,9 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme this.isInner = Flags.INNER.get(flags); this.annotationDeserializer = annotationResolver; - this.annotations = storageManager.createLazyValue(new Function0>() { + this.annotations = storageManager.createLazyValue(new Function0() { @Override - public List invoke() { + public Annotations invoke() { return computeAnnotations(); } }); @@ -187,16 +188,16 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme return isInner; } - private List computeAnnotations() { + private Annotations computeAnnotations() { if (!Flags.HAS_ANNOTATIONS.get(classProto.getFlags())) { - return Collections.emptyList(); + return Annotations.EMPTY; } return annotationDeserializer.loadClassAnnotations(this, classProto); } @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { return annotations.invoke(); } @@ -349,8 +350,8 @@ public class DeserializedClassDescriptor extends AbstractClassDescriptor impleme @NotNull @Override - public List getAnnotations() { - return Collections.emptyList(); // TODO + public Annotations getAnnotations() { + return Annotations.EMPTY; // TODO } @Override diff --git a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/DeserializedSimpleFunctionDescriptor.java b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/DeserializedSimpleFunctionDescriptor.java index 9702539fb88..f8a1a0feb2d 100644 --- a/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/DeserializedSimpleFunctionDescriptor.java +++ b/compiler/frontend/serialization/src/org/jetbrains/jet/descriptors/serialization/descriptors/DeserializedSimpleFunctionDescriptor.java @@ -23,13 +23,11 @@ import org.jetbrains.jet.descriptors.serialization.NameResolver; import org.jetbrains.jet.descriptors.serialization.ProtoBuf; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.resolve.name.Name; -import java.util.List; - public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescriptorImpl { private final ProtoBuf.Callable functionProto; @@ -37,7 +35,7 @@ public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescript private DeserializedSimpleFunctionDescriptor( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @NotNull Kind kind, @NotNull ProtoBuf.Callable functionProto, @@ -51,7 +49,7 @@ public class DeserializedSimpleFunctionDescriptor extends SimpleFunctionDescript private DeserializedSimpleFunctionDescriptor( @NotNull DeclarationDescriptor containingDeclaration, @NotNull SimpleFunctionDescriptor original, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @NotNull Kind kind, @NotNull ProtoBuf.Callable functionProto, diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/LocalVariableDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/LocalVariableDescriptor.java index 7e4ecbacb29..805587a011e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/LocalVariableDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/impl/LocalVariableDescriptor.java @@ -22,19 +22,17 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor; import org.jetbrains.jet.lang.descriptors.Visibilities; import org.jetbrains.jet.lang.descriptors.Visibility; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeSubstitutor; -import java.util.List; - public class LocalVariableDescriptor extends VariableDescriptorImpl { private final boolean isVar; public LocalVariableDescriptor( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @Nullable JetType type, boolean mutable diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java index edb13616886..56630390509 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationResolver.java @@ -20,9 +20,7 @@ import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.Annotated; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl; +import org.jetbrains.jet.lang.descriptors.annotations.*; import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.evaluate.ConstantExpressionEvaluator; import org.jetbrains.jet.lang.psi.*; @@ -67,7 +65,7 @@ public class AnnotationResolver { } @NotNull - public List resolveAnnotationsWithoutArguments( + public Annotations resolveAnnotationsWithoutArguments( @NotNull JetScope scope, @Nullable JetModifierList modifierList, @NotNull BindingTrace trace @@ -76,7 +74,7 @@ public class AnnotationResolver { } @NotNull - public List resolveAnnotationsWithArguments( + public Annotations resolveAnnotationsWithArguments( @NotNull JetScope scope, @Nullable JetModifierList modifierList, @NotNull BindingTrace trace @@ -85,7 +83,7 @@ public class AnnotationResolver { } @NotNull - public List resolveAnnotationsWithArguments( + public Annotations resolveAnnotationsWithArguments( @NotNull JetScope scope, @NotNull List annotationEntries, @NotNull BindingTrace trace @@ -93,26 +91,26 @@ public class AnnotationResolver { return resolveAnnotationEntries(scope, annotationEntries, trace, true); } - private List resolveAnnotations( + private Annotations resolveAnnotations( @NotNull JetScope scope, @Nullable JetModifierList modifierList, @NotNull BindingTrace trace, boolean shouldResolveArguments ) { if (modifierList == null) { - return Collections.emptyList(); + return Annotations.EMPTY; } List annotationEntryElements = modifierList.getAnnotationEntries(); return resolveAnnotationEntries(scope, annotationEntryElements, trace, shouldResolveArguments); } - private List resolveAnnotationEntries( + private Annotations resolveAnnotationEntries( @NotNull JetScope scope, @NotNull List annotationEntryElements, @NotNull BindingTrace trace, boolean shouldResolveArguments ) { - if (annotationEntryElements.isEmpty()) return Collections.emptyList(); + if (annotationEntryElements.isEmpty()) return Annotations.EMPTY; List result = Lists.newArrayList(); for (JetAnnotationEntry entryElement : annotationEntryElements) { AnnotationDescriptorImpl descriptor = trace.get(BindingContext.ANNOTATION, entryElement); @@ -128,7 +126,7 @@ public class AnnotationResolver { result.add(descriptor); } - return result; + return new AnnotationsImpl(result); } public void resolveAnnotationStub( @@ -280,7 +278,7 @@ public class AnnotationResolver { @SuppressWarnings("MethodMayBeStatic") @NotNull - public List getResolvedAnnotations(@NotNull List annotations, @NotNull BindingTrace trace) { + public Annotations getResolvedAnnotations(@NotNull List annotations, @NotNull BindingTrace trace) { List result = new ArrayList(annotations.size()); for (JetAnnotationEntry annotation : annotations) { AnnotationDescriptor annotationDescriptor = trace.get(BindingContext.ANNOTATION, annotation); @@ -291,7 +289,7 @@ public class AnnotationResolver { result.add(annotationDescriptor); } - return result; + return new AnnotationsImpl(result); } public static void reportUnsupportedAnnotationForTypeParameter(@NotNull JetModifierListOwner modifierListOwner, BindingTrace trace) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationUtils.java index 1c16a287cfd..7aef6be000f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/AnnotationUtils.java @@ -17,8 +17,11 @@ package org.jetbrains.jet.lang.resolve; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.descriptors.*; +import org.jetbrains.jet.lang.descriptors.ClassDescriptor; +import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; +import org.jetbrains.jet.lang.descriptors.VariableDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.psi.JetParameter; import org.jetbrains.jet.lang.psi.JetTypeReference; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; @@ -89,26 +92,22 @@ public class AnnotationUtils { } public static boolean isArrayMethodCall(@NotNull ResolvedCall resolvedCall) { - List annotations = resolvedCall.getResultingDescriptor().getOriginal().getAnnotations(); - if (annotations != null) { - for (AnnotationDescriptor annotation : annotations) { - //noinspection ConstantConditions - if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) { - return "kotlin.arrays.array".equals(annotation.getAllValueArguments().values().iterator().next().getValue()); - } + Annotations annotations = resolvedCall.getResultingDescriptor().getOriginal().getAnnotations(); + for (AnnotationDescriptor annotation : annotations) { + //noinspection ConstantConditions + if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) { + return "kotlin.arrays.array".equals(annotation.getAllValueArguments().values().iterator().next().getValue()); } } return false; } public static boolean isJavaClassMethodCall(@NotNull ResolvedCall resolvedCall) { - List annotations = resolvedCall.getResultingDescriptor().getOriginal().getAnnotations(); - if (annotations != null) { - for (AnnotationDescriptor annotation : annotations) { - //noinspection ConstantConditions - if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) { - return "kotlin.javaClass.function".equals(annotation.getAllValueArguments().values().iterator().next().getValue()); - } + Annotations annotations = resolvedCall.getResultingDescriptor().getOriginal().getAnnotations(); + for (AnnotationDescriptor annotation : annotations) { + //noinspection ConstantConditions + if ("Intrinsic".equals(annotation.getType().getConstructor().getDeclarationDescriptor().getName().asString())) { + return "kotlin.javaClass.function".equals(annotation.getAllValueArguments().values().iterator().next().getValue()); } } return false; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java index 1f6437359da..daa05080ffa 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java @@ -154,8 +154,8 @@ public class DeclarationResolver { JetModifierList modifierList = entry.getKey().getModifierList(); if (modifierList != null) { MutableClassDescriptor descriptor = entry.getValue(); - descriptor.getAnnotations().addAll(annotationResolver.resolveAnnotationsWithoutArguments( - descriptor.getScopeForSupertypeResolution(), modifierList, trace)); + descriptor.addAnnotations(annotationResolver.resolveAnnotationsWithoutArguments( + descriptor.getScopeForSupertypeResolution(), modifierList, trace).getAnnotationDescriptors()); } } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java index 7a89d07fb63..f09a9fb7ad3 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java @@ -26,7 +26,7 @@ import jet.Function0; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.*; import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory1; import org.jetbrains.jet.lang.psi.*; @@ -101,7 +101,7 @@ public class DescriptorResolver { TypeParameterDescriptor typeParameterDescriptor = TypeParameterDescriptorImpl.createForFurtherModification( descriptor, - Collections.emptyList(), + Annotations.EMPTY, typeParameter.hasModifier(JetTokens.REIFIED_KEYWORD), typeParameter.getVariance(), JetPsiUtil.safeName(typeParameter.getName()), @@ -274,7 +274,7 @@ public class DescriptorResolver { @NotNull final JetNamedFunction function, @NotNull final BindingTrace trace, @NotNull final DataFlowInfo dataFlowInfo, - @NotNull List annotations + @NotNull Annotations annotations ) { final SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl( containingDescriptor, @@ -366,7 +366,7 @@ public class DescriptorResolver { SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl( classDescriptor, - Collections.emptyList(), + Annotations.EMPTY, Name.identifier(functionName), CallableMemberDescriptor.Kind.SYNTHESIZED ); @@ -396,7 +396,7 @@ public class DescriptorResolver { SimpleFunctionDescriptorImpl functionDescriptor = new SimpleFunctionDescriptorImpl( classDescriptor, - Collections.emptyList(), + Annotations.EMPTY, COPY_METHOD_NAME, CallableMemberDescriptor.Kind.SYNTHESIZED ); @@ -521,7 +521,7 @@ public class DescriptorResolver { private static ValueParameterDescriptorImpl resolveValueParameterDescriptor( DeclarationDescriptor declarationDescriptor, JetParameter valueParameter, int index, JetType type, BindingTrace trace, - List annotations + Annotations annotations ) { JetType varargElementType = null; JetType variableType = type; @@ -574,7 +574,7 @@ public class DescriptorResolver { TypeParameterDescriptorImpl typeParameterDescriptor = TypeParameterDescriptorImpl.createForFurtherModification( containingDescriptor, - Collections.emptyList(), + Annotations.EMPTY, typeParameter.hasModifier(JetTokens.REIFIED_KEYWORD), typeParameter.getVariance(), JetPsiUtil.safeName(typeParameter.getName()), @@ -1041,7 +1041,7 @@ public class DescriptorResolver { JetPropertyAccessor setter = property.getSetter(); PropertySetterDescriptorImpl setterDescriptor = null; if (setter != null) { - List annotations = + Annotations annotations = annotationResolver.resolveAnnotationsWithoutArguments(scope, setter.getModifierList(), trace); JetParameter parameter = setter.getParameter(); @@ -1109,7 +1109,7 @@ public class DescriptorResolver { PropertyGetterDescriptorImpl getterDescriptor; JetPropertyAccessor getter = property.getGetter(); if (getter != null) { - List annotations = + Annotations annotations = annotationResolver.resolveAnnotationsWithoutArguments(scope, getter.getModifierList(), trace); JetType outType = propertyDescriptor.getType(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptHeaderResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptHeaderResolver.java index 47e7116df87..0bf36a9c0c9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptHeaderResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptHeaderResolver.java @@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.PackageFragmentDescriptor; import org.jetbrains.jet.lang.descriptors.ScriptDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl; import org.jetbrains.jet.lang.parsing.JetScriptDefinition; import org.jetbrains.jet.lang.parsing.JetScriptDefinitionProvider; @@ -43,7 +43,6 @@ import org.jetbrains.jet.lang.types.ref.JetTypeName; import javax.inject.Inject; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; @@ -114,7 +113,7 @@ public class ScriptHeaderResolver { int index, @NotNull ScriptDescriptor script) { JetType type = resolveTypeName(scriptParameter.getType()); - return new ValueParameterDescriptorImpl(script, index, Collections.emptyList(), scriptParameter.getName(), type, false, null); + return new ValueParameterDescriptorImpl(script, index, Annotations.EMPTY, scriptParameter.getName(), type, false, null); } public void processScriptHierarchy(@NotNull JetScript script, @NotNull JetScope outerScope) { 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 a22b6ba626f..9b3da2c34ed 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeResolver.java @@ -20,7 +20,7 @@ import jet.Function0; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter; @@ -76,7 +76,7 @@ public class TypeResolver { JetType cachedType = c.trace.getBindingContext().get(BindingContext.TYPE, typeReference); if (cachedType != null) return type(cachedType); - List annotations = annotationResolver.getResolvedAnnotations(typeReference.getAnnotations(), c.trace); + Annotations annotations = annotationResolver.getResolvedAnnotations(typeReference.getAnnotations(), c.trace); JetTypeElement typeElement = typeReference.getTypeElement(); PossiblyBareType type = resolveTypeElement(c, annotations, typeElement); @@ -91,7 +91,7 @@ public class TypeResolver { @NotNull private PossiblyBareType resolveTypeElement( final TypeResolutionContext c, - final List annotations, + final Annotations annotations, JetTypeElement typeElement ) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ArgumentTypeResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ArgumentTypeResolver.java index ca6cae39d2e..91f2d1d64e8 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ArgumentTypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ArgumentTypeResolver.java @@ -20,7 +20,7 @@ import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.evaluate.ConstantExpressionEvaluator; import org.jetbrains.jet.lang.psi.*; @@ -213,7 +213,7 @@ public class ArgumentTypeResolver { ) { if (expression.getFunctionLiteral().getValueParameterList() == null) { return expectedTypeIsUnknown ? PLACEHOLDER_FUNCTION_TYPE : KotlinBuiltIns.getInstance().getFunctionType( - Collections.emptyList(), null, Collections.emptyList(), DONT_CARE); + Annotations.EMPTY, null, Collections.emptyList(), DONT_CARE); } List valueParameters = expression.getValueParameters(); TemporaryBindingTrace temporaryTrace = TemporaryBindingTrace.create( @@ -226,7 +226,7 @@ public class ArgumentTypeResolver { JetType returnType = resolveTypeRefWithDefault(functionLiteral.getReturnTypeRef(), scope, temporaryTrace, DONT_CARE); assert returnType != null; JetType receiverType = resolveTypeRefWithDefault(functionLiteral.getReceiverTypeRef(), scope, temporaryTrace, null); - return KotlinBuiltIns.getInstance().getFunctionType(Collections.emptyList(), receiverType, parameterTypes, + return KotlinBuiltIns.getInstance().getFunctionType(Annotations.EMPTY, receiverType, parameterTypes, returnType); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java index 34d8a253ce4..955672de4be 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java @@ -24,22 +24,14 @@ import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.Call; import org.jetbrains.jet.lang.psi.CallKey; import org.jetbrains.jet.lang.psi.JetExpression; -import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.resolve.TraceUtil; import org.jetbrains.jet.lang.resolve.calls.context.BasicCallResolutionContext; -import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext; import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition; import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; -import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument; -import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionCandidate; import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import java.util.Collections; import java.util.List; -import java.util.Map; import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_TYPE_PARAMETER; import static org.jetbrains.jet.lang.types.TypeUtils.DONT_CARE; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/util/ExpressionAsFunctionDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/util/ExpressionAsFunctionDescriptor.java index db5ec4d956a..3025860f699 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/util/ExpressionAsFunctionDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/util/ExpressionAsFunctionDescriptor.java @@ -17,20 +17,21 @@ package org.jetbrains.jet.lang.resolve.calls.util; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; +import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; +import org.jetbrains.jet.lang.descriptors.Modality; +import org.jetbrains.jet.lang.descriptors.Visibility; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl; import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.resolve.name.Name; -import java.util.Collections; - public class ExpressionAsFunctionDescriptor extends FunctionDescriptorImpl { private final JetExpression expression; public ExpressionAsFunctionDescriptor(DeclarationDescriptor containingDeclaration, Name name, JetExpression expression) { - super(containingDeclaration, Collections.emptyList(), name, Kind.DECLARATION); + super(containingDeclaration, Annotations.EMPTY, name, Kind.DECLARATION); this.expression = expression; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassDescriptor.java index f45786776b1..9c778461c4d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorBase; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.AnnotationResolver; @@ -74,7 +75,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc private final ClassKind kind; private final boolean isInner; - private final NotNullLazyValue> annotations; + private final NotNullLazyValue annotations; private final NullableLazyValue classObjectDescriptor; private final LazyClassMemberScope unsubstitutedMemberScope; @@ -119,9 +120,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc this.isInner = isInnerClass(modifierList); StorageManager storageManager = resolveSession.getStorageManager(); - this.annotations = storageManager.createLazyValue(new Function0>() { + this.annotations = storageManager.createLazyValue(new Function0() { @Override - public List invoke() { + public Annotations invoke() { return resolveAnnotations(); } }); @@ -293,12 +294,12 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { return annotations.invoke(); } @NotNull - private List resolveAnnotations() { + private Annotations resolveAnnotations() { JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo(); JetModifierList modifierList = classInfo.getModifierList(); if (modifierList != null) { @@ -307,7 +308,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc return annotationResolver.resolveAnnotationsWithArguments(scopeForDeclaration, modifierList, resolveSession.getTrace()); } else { - return Collections.emptyList(); + return Annotations.EMPTY; } } @@ -449,8 +450,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc @NotNull @Override - public List getAnnotations() { - return Collections.emptyList(); // TODO + public Annotations getAnnotations() { + return Annotations.EMPTY; // TODO } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyPackageDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyPackageDescriptor.java index f4b1b3dc08e..c66350ca715 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyPackageDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyPackageDescriptor.java @@ -19,18 +19,16 @@ package org.jetbrains.jet.lang.resolve.lazy.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorImpl; import org.jetbrains.jet.lang.resolve.lazy.ForceResolveUtil; import org.jetbrains.jet.lang.resolve.lazy.LazyDescriptor; import org.jetbrains.jet.lang.resolve.lazy.ResolveSession; import org.jetbrains.jet.lang.resolve.lazy.declarations.PackageMemberDeclarationProvider; import org.jetbrains.jet.lang.resolve.name.FqName; -import org.jetbrains.jet.lang.resolve.scopes.*; +import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.TypeSubstitutor; -import java.util.Collections; - public class LazyPackageDescriptor extends DeclarationDescriptorImpl implements LazyDescriptor, PackageFragmentDescriptor { private final ResolveSession resolveSession; private final ModuleDescriptor module; @@ -44,7 +42,7 @@ public class LazyPackageDescriptor extends DeclarationDescriptorImpl implements @NotNull ResolveSession resolveSession, @NotNull PackageMemberDeclarationProvider declarationProvider ) { - super(Collections.emptyList(), fqName.shortNameOrSpecial()); + super(Annotations.EMPTY, fqName.shortNameOrSpecial()); this.resolveSession = resolveSession; this.module = module; this.fqName = fqName; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/DeferredType.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/DeferredType.java index 5eff0d5d689..4056ea6ab50 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/DeferredType.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/DeferredType.java @@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.types; import jet.Function0; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.storage.LockBasedStorageManager; @@ -87,7 +87,7 @@ public class DeferredType implements LazyType { @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { return getActualType().getAnnotations(); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 78a6fe5aa71..c3c9dab4b03 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -25,6 +25,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.PlatformToKotlinClassMap; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor; import org.jetbrains.jet.lang.diagnostics.Errors; import org.jetbrains.jet.lang.evaluate.ConstantExpressionEvaluator; @@ -505,7 +506,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { //noinspection ConstantConditions JetType type = KotlinBuiltIns.getInstance().getKFunctionType( - Collections.emptyList(), + Annotations.EMPTY, receiverType, DescriptorUtils.getValueParametersTypes(descriptor.getValueParameters()), descriptor.getReturnType(), @@ -514,7 +515,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { AnonymousFunctionDescriptor functionDescriptor = new AnonymousFunctionDescriptor( context.scope.getContainingDeclaration(), - Collections.emptyList(), + Annotations.EMPTY, CallableMemberDescriptor.Kind.DECLARATION); FunctionDescriptorUtil.initializeFromFunctionType(functionDescriptor, type, null, Modality.FINAL, Visibilities.PUBLIC); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.java index 40f4e9f9c5e..b0eea36468d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.java @@ -24,7 +24,7 @@ import jet.Function0; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.*; @@ -119,7 +119,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor { JetType receiver = DescriptorUtils.getReceiverParameterType(functionDescriptor.getReceiverParameter()); List valueParametersTypes = DescriptorUtils.getValueParametersTypes(functionDescriptor.getValueParameters()); JetType resultType = KotlinBuiltIns.getInstance().getFunctionType( - Collections.emptyList(), receiver, valueParametersTypes, safeReturnType); + Annotations.EMPTY, receiver, valueParametersTypes, safeReturnType); if (!noExpectedType(expectedType) && KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(expectedType)) { // all checks were done before return JetTypeInfo.create(resultType, context.dataFlowInfo); @@ -176,7 +176,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor { JetFunctionLiteral functionLiteral = expression.getFunctionLiteral(); JetTypeReference receiverTypeRef = functionLiteral.getReceiverTypeRef(); AnonymousFunctionDescriptor functionDescriptor = new AnonymousFunctionDescriptor( - context.scope.getContainingDeclaration(), Collections.emptyList(), CallableMemberDescriptor.Kind.DECLARATION); + context.scope.getContainingDeclaration(), Annotations.EMPTY, CallableMemberDescriptor.Kind.DECLARATION); List valueParameterDescriptors = createValueParameterDescriptors(context, functionLiteral, functionDescriptor, functionTypeExpected); @@ -224,7 +224,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor { if (functionTypeExpected && !hasDeclaredValueParameters && expectedValueParameters.size() == 1) { ValueParameterDescriptor valueParameterDescriptor = expectedValueParameters.get(0); ValueParameterDescriptor it = new ValueParameterDescriptorImpl( - functionDescriptor, 0, Collections.emptyList(), Name.identifier("it"), + functionDescriptor, 0, Annotations.EMPTY, Name.identifier("it"), valueParameterDescriptor.getType(), valueParameterDescriptor.hasDefaultValue(), valueParameterDescriptor.getVarargElementType() ); valueParameterDescriptors.add(it); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java index 97e60c3c873..7b6a78f30bc 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingUtils.java @@ -23,7 +23,7 @@ import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl; @@ -32,11 +32,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.calls.CallResolver; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; -import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition; -import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem; -import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemStatus; -import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintsUtil; -import org.jetbrains.jet.lang.resolve.calls.inference.InferenceErrorData; +import org.jetbrains.jet.lang.resolve.calls.inference.*; import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallWithTrace; @@ -90,26 +86,25 @@ public class ControlStructureTypingUtils { ) { assert argumentNames.size() == isArgumentNullable.size(); - List noAnnotations = Collections.emptyList(); Name specialFunctionName = Name.identifierNoValidate(""); SimpleFunctionDescriptorImpl function = new SimpleFunctionDescriptorImpl( ErrorUtils.getErrorModule(),//todo hack to avoid returning true in 'isError(DeclarationDescriptor)' - noAnnotations, specialFunctionName, CallableMemberDescriptor.Kind.DECLARATION); + Annotations.EMPTY, specialFunctionName, CallableMemberDescriptor.Kind.DECLARATION); TypeParameterDescriptor typeParameter = TypeParameterDescriptorImpl.createWithDefaultBound( - function, noAnnotations, false, Variance.INVARIANT, + function, Annotations.EMPTY, false, Variance.INVARIANT, Name.identifierNoValidate(""), 0); JetType type = new JetTypeImpl(typeParameter.getTypeConstructor(), JetScope.EMPTY); JetType nullableType = new JetTypeImpl( - noAnnotations, typeParameter.getTypeConstructor(), true, Collections.emptyList(), JetScope.EMPTY); + Annotations.EMPTY, typeParameter.getTypeConstructor(), true, Collections.emptyList(), JetScope.EMPTY); List valueParameters = Lists.newArrayList(); for (int i = 0; i < argumentNames.size(); i++) { JetType argumentType = isArgumentNullable.get(i) ? nullableType : type; ValueParameterDescriptorImpl valueParameter = new ValueParameterDescriptorImpl( - function, i, noAnnotations, Name.identifier(argumentNames.get(i)), argumentType, false, null); + function, i, Annotations.EMPTY, Name.identifier(argumentNames.get(i)), argumentType, false, null); valueParameters.add(valueParameter); } function.initialize( diff --git a/compiler/tests/org/jetbrains/jet/types/TypeUnifierTest.java b/compiler/tests/org/jetbrains/jet/types/TypeUnifierTest.java index 2b1340b97b0..b860cf3b9bc 100644 --- a/compiler/tests/org/jetbrains/jet/types/TypeUnifierTest.java +++ b/compiler/tests/org/jetbrains/jet/types/TypeUnifierTest.java @@ -27,7 +27,7 @@ import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; import org.jetbrains.jet.di.InjectorForTests; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.jet.lang.psi.JetPsiFactory; import org.jetbrains.jet.lang.psi.JetTypeProjection; @@ -41,7 +41,6 @@ import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; -import java.util.Collections; import java.util.Map; import java.util.Set; @@ -73,7 +72,7 @@ public class TypeUnifierTest extends JetLiteFixture { private static TypeParameterDescriptor createTypeVariable(String name) { return TypeParameterDescriptorImpl.createWithDefaultBound( - KotlinBuiltIns.getInstance().getBuiltInsModule(), Collections.emptyList(), false, Variance.INVARIANT, + KotlinBuiltIns.getInstance().getBuiltInsModule(), Annotations.EMPTY, false, Variance.INVARIANT, Name.identifier(name), 0); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaMethodDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaMethodDescriptor.java index a7184e2bc49..9d66bfcb045 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaMethodDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaMethodDescriptor.java @@ -18,16 +18,14 @@ package org.jetbrains.jet.lang.resolve.java.descriptor; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.resolve.name.Name; -import java.util.List; - public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implements JavaCallableMemberDescriptor { public JavaMethodDescriptor( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name ) { super(containingDeclaration, annotations, name, Kind.DECLARATION); diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaPackageFragmentDescriptorImpl.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaPackageFragmentDescriptorImpl.java index 181f2a07143..6ea314568c7 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaPackageFragmentDescriptorImpl.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaPackageFragmentDescriptorImpl.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor; import org.jetbrains.jet.lang.descriptors.ModuleDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorImpl; import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver; import org.jetbrains.jet.lang.resolve.java.resolver.JavaPackageFragmentProvider; @@ -31,8 +31,6 @@ import org.jetbrains.jet.lang.resolve.java.scope.JavaPackageFragmentScope; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.types.TypeSubstitutor; -import java.util.Collections; - public class JavaPackageFragmentDescriptorImpl extends DeclarationDescriptorImpl implements JavaPackageFragmentDescriptor { @Nullable public static JavaPackageFragmentDescriptorImpl create( @@ -54,7 +52,7 @@ public class JavaPackageFragmentDescriptorImpl extends DeclarationDescriptorImpl @NotNull FqName fqName, @NotNull NullableFunction scopeFactory ) { - super(Collections.emptyList(), fqName.shortNameOrSpecial()); + super(Annotations.EMPTY, fqName.shortNameOrSpecial()); this.provider = provider; this.fqName = fqName; this.memberScope = scopeFactory.fun(this); diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaPropertyDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaPropertyDescriptor.java index dcdb13c0b57..81c3a25fb5c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaPropertyDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaPropertyDescriptor.java @@ -20,16 +20,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.Modality; import org.jetbrains.jet.lang.descriptors.Visibility; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl; import org.jetbrains.jet.lang.resolve.name.Name; -import java.util.List; - public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements JavaCallableMemberDescriptor { public JavaPropertyDescriptor( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Visibility visibility, boolean isVar, @NotNull Name name diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/annotationUtils.kt b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/annotationUtils.kt index 33305fd597f..846f4263fcb 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/annotationUtils.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/annotationUtils.kt @@ -17,14 +17,16 @@ package org.jetbrains.jet.lang.resolve.java.lazy import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotation -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.jet.lang.resolve.java.lazy.descriptors.LazyJavaAnnotationDescriptor import org.jetbrains.jet.lang.resolve.java.structure.JavaAnnotationOwner import org.jetbrains.jet.lang.resolve.name.FqName import org.jetbrains.jet.lang.resolve.java.resolver.JavaAnnotationResolver +import org.jetbrains.jet.lang.descriptors.annotations.Annotations +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationsImpl +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor +import org.jetbrains.jet.lang.resolve.java.lazy.descriptors.LazyJavaAnnotationDescriptor -fun LazyJavaResolverContextWithTypes.resolveAnnotations(javaAnnotations: Collection): List - = javaAnnotations.flatMap { +fun LazyJavaResolverContextWithTypes.resolveAnnotations(javaAnnotations: Collection): Annotations + = AnnotationsImpl(javaAnnotations.flatMap { jAnnotation -> // TODO: we resolve all annotations, which slightly compromises our laziness val fqName = jAnnotation.getFqName() @@ -32,7 +34,7 @@ fun LazyJavaResolverContextWithTypes.resolveAnnotations(javaAnnotations: Collect listOf() } else listOf(LazyJavaAnnotationDescriptor(this, jAnnotation)) - } + }) private fun GlobalJavaResolverContext.hasAnnotation(owner: JavaAnnotationOwner, annotationFqName: FqName): Boolean = owner.findAnnotation(annotationFqName) != null || externalAnnotationResolver.findExternalAnnotation(owner, annotationFqName) != null diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassDescriptor.kt index 9ab85046e75..d93f5f7d8bf 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -9,12 +9,10 @@ import org.jetbrains.jet.lang.descriptors.ConstructorDescriptor import org.jetbrains.jet.lang.types.JetType import org.jetbrains.jet.lang.descriptors.ClassDescriptor import org.jetbrains.jet.lang.types.TypeConstructor -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor import org.jetbrains.jet.lang.resolve.java.resolver.JavaClassResolver import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor import java.util.Collections import org.jetbrains.jet.lang.resolve.java.lazy.LazyJavaResolverContextWithTypes -import org.jetbrains.jet.lang.resolve.DescriptorFactory import org.jetbrains.jet.lang.resolve.java.lazy.child import org.jetbrains.jet.lang.resolve.java.resolver.TypeUsage import org.jetbrains.jet.lang.resolve.java.lazy.resolveAnnotations @@ -33,6 +31,7 @@ import org.jetbrains.jet.lang.descriptors.Modality import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler import org.jetbrains.jet.lang.resolve.scopes.WritableScope +import org.jetbrains.jet.lang.descriptors.annotations.Annotations class LazyJavaClassDescriptor( private val outerC: LazyJavaResolverContextWithTypes, @@ -95,7 +94,7 @@ class LazyJavaClassDescriptor( override fun getConstructors() = _scopeForMemberLookup._constructors() private val _annotations = c.storageManager.createLazyValue { c.resolveAnnotations(jClass.getAnnotations()) } - override fun getAnnotations(): List = _annotations() + override fun getAnnotations() = _annotations() private val _functionTypeForSamInterface = c.storageManager.createNullableLazyValue { val samInterfaceMethod = SingleAbstractMethodUtils.getSamInterfaceMethod(jClass); @@ -160,7 +159,7 @@ class LazyJavaClassDescriptor( override fun getSupertypes(): Collection = _supertypes() - override fun getAnnotations() = Collections.emptyList() + override fun getAnnotations() = Annotations.EMPTY override fun isFinal() = !getModality().isOverridable() diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassMemberScope.kt index 16c8038f13b..6a2220d1d79 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -33,6 +33,7 @@ import org.jetbrains.jet.lang.resolve.java.lazy.types.toAttributes import org.jetbrains.jet.lang.resolve.DescriptorUtils import org.jetbrains.jet.lang.descriptors.impl.EnumEntrySyntheticClassDescriptor import org.jetbrains.jet.lang.types.TypeUtils +import org.jetbrains.jet.lang.descriptors.annotations.Annotations public class LazyJavaClassMemberScope( c: LazyJavaResolverContextWithTypes, @@ -65,7 +66,7 @@ public class LazyJavaClassMemberScope( } private fun resolveConstructor(constructor: JavaMethod, classDescriptor: ClassDescriptor, isStaticClass: Boolean): ConstructorDescriptor { - val constructorDescriptor = ConstructorDescriptorImpl(classDescriptor, Collections.emptyList(), isPrimary = false) + val constructorDescriptor = ConstructorDescriptorImpl(classDescriptor, Annotations.EMPTY, isPrimary = false) val valueParameters = resolveValueParameters(c, constructorDescriptor, constructor.getValueParameters()) val effectiveSignature = c.externalSignatureResolver.resolveAlternativeMethodSignature( @@ -96,7 +97,7 @@ public class LazyJavaClassMemberScope( return null val classDescriptor = getContainingDeclaration() - val constructorDescriptor = ConstructorDescriptorImpl(classDescriptor, Collections.emptyList(), isPrimary = true) + val constructorDescriptor = ConstructorDescriptorImpl(classDescriptor, Annotations.EMPTY, isPrimary = true) val typeParameters = classDescriptor.getTypeConstructor().getParameters() val valueParameters = if (isAnnotation) createAnnotationConstructorParameters(constructorDescriptor) else Collections.emptyList() @@ -130,7 +131,7 @@ public class LazyJavaClassMemberScope( result.add(ValueParameterDescriptorImpl( constructor, index, - Collections.emptyList(), + Annotations.EMPTY, method.getName(), // Parameters of annotation constructors in Java are never nullable TypeUtils.makeNotNullable(returnType), diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaPackageFragment.kt b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaPackageFragment.kt index 1d875d8e747..885276d2e17 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaPackageFragment.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/descriptors/LazyJavaPackageFragment.kt @@ -15,6 +15,7 @@ import org.jetbrains.jet.lang.types.TypeSubstitutor import org.jetbrains.jet.lang.resolve.java.descriptor.JavaPackageFragmentDescriptor import org.jetbrains.jet.lang.resolve.java.JavaDescriptorResolver import org.jetbrains.jet.lang.descriptors.PackageFragmentProvider +import org.jetbrains.jet.lang.descriptors.annotations.Annotations fun LazyPackageFragmentForJavaPackage( c: LazyJavaResolverContext, @@ -37,7 +38,7 @@ class LazyJavaPackageFragment( val _kind: JavaPackageFragmentDescriptor.Kind, val _fqName: FqName, createMemberScope: LazyJavaPackageFragment.() -> LazyJavaPackageFragmentScope -) : DeclarationDescriptorNonRootImpl(containingDeclaration, listOf(), _fqName.shortNameOrSpecial()), +) : DeclarationDescriptorNonRootImpl(containingDeclaration, Annotations.EMPTY, _fqName.shortNameOrSpecial()), JavaPackageFragmentDescriptor, LazyJavaDescriptor { private val _memberScope = createMemberScope() diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/types/LazyJavaType.kt b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/types/LazyJavaType.kt index d1a0530f3f4..36bba761f99 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/types/LazyJavaType.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/lazy/types/LazyJavaType.kt @@ -19,12 +19,12 @@ package org.jetbrains.jet.lang.resolve.java.lazy.types import org.jetbrains.jet.storage.StorageManager import org.jetbrains.jet.lang.types.TypeConstructor import org.jetbrains.jet.lang.types.TypeProjection -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor import org.jetbrains.jet.lang.resolve.scopes.JetScope import org.jetbrains.jet.lang.types.AbstractJetType import org.jetbrains.jet.lang.types.ErrorUtils import org.jetbrains.kotlin.util.inn import org.jetbrains.jet.lang.types.LazyType +import org.jetbrains.jet.lang.descriptors.annotations.Annotations abstract class LazyJavaType(storageManager: StorageManager) : AbstractJetType(), LazyType { @@ -47,7 +47,7 @@ abstract class LazyJavaType(storageManager: StorageManager) : AbstractJetType(), override fun isError()= getConstructor().getDeclarationDescriptor().inn({ d -> ErrorUtils.isError(d)}, false) - override fun getAnnotations(): List = listOf() + override fun getAnnotations() = Annotations.EMPTY override fun toString(): String? { if (!_typeConstructor.isComputed()) { diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaAnnotationResolver.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaAnnotationResolver.java index 4eefd94f908..95113b8885c 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaAnnotationResolver.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaAnnotationResolver.java @@ -22,6 +22,8 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationsImpl; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames; import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap; @@ -82,17 +84,17 @@ public final class JavaAnnotationResolver { } @NotNull - public List resolveAnnotations(@NotNull JavaAnnotationOwner owner, @NotNull PostponedTasks tasks) { + public Annotations resolveAnnotations(@NotNull JavaAnnotationOwner owner, @NotNull PostponedTasks tasks) { List result = new ArrayList(); resolveAnnotations(owner.getAnnotations(), tasks, result); resolveAnnotations(externalAnnotationResolver.findExternalAnnotations(owner), tasks, result); - return result; + return new AnnotationsImpl(result); } @NotNull - public List resolveAnnotations(@NotNull JavaAnnotationOwner owner) { + public Annotations resolveAnnotations(@NotNull JavaAnnotationOwner owner) { PostponedTasks postponedTasks = new PostponedTasks(); - List annotations = resolveAnnotations(owner, postponedTasks); + Annotations annotations = resolveAnnotations(owner, postponedTasks); postponedTasks.performTasks(); return annotations; } diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java index 348cfe34cf1..dad8b040d59 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaConstructorResolver.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.resolver; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl; import org.jetbrains.jet.lang.resolve.java.JavaVisibilities; @@ -108,7 +108,7 @@ public final class JavaConstructorResolver { ConstructorDescriptorImpl constructorDescriptor = new ConstructorDescriptorImpl( containingClass, - Collections.emptyList(), + Annotations.EMPTY, true); List typeParameters = containingClass.getTypeConstructor().getParameters(); @@ -158,7 +158,7 @@ public final class JavaConstructorResolver { result.add(new ValueParameterDescriptorImpl( constructorDescriptor, index, - Collections.emptyList(), + Annotations.EMPTY, method.getName(), // Parameters of annotation constructors in Java are never nullable TypeUtils.makeNotNullable(typeTransformer.transformToType(returnType, typeVariableResolver)), @@ -193,7 +193,7 @@ public final class JavaConstructorResolver { ConstructorDescriptorImpl constructorDescriptor = new ConstructorDescriptorImpl( classDescriptor, - Collections.emptyList(), // TODO + Annotations.EMPTY, // TODO false); List typeParameters = classDescriptor.getTypeConstructor().getParameters(); diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaTypeParameterResolver.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaTypeParameterResolver.java index 4994915d3af..5c4d910dadf 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaTypeParameterResolver.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaTypeParameterResolver.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.resolver; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.jet.lang.resolve.java.structure.JavaClassifierType; import org.jetbrains.jet.lang.resolve.java.structure.JavaTypeParameter; @@ -28,7 +28,10 @@ import org.jetbrains.jet.lang.types.Variance; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import javax.inject.Inject; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; public final class JavaTypeParameterResolver { @NotNull @@ -63,7 +66,7 @@ public final class JavaTypeParameterResolver { private void addTypeParameter(@NotNull JavaTypeParameter typeParameter) { TypeParameterDescriptorImpl descriptor = TypeParameterDescriptorImpl.createForFurtherModification( owner, - Collections.emptyList(), // TODO + Annotations.EMPTY, // TODO false, Variance.INVARIANT, typeParameter.getName(), diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaTypeTransformer.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaTypeTransformer.java index c8043d90c40..6fee605ed86 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaTypeTransformer.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/resolver/JavaTypeTransformer.java @@ -20,7 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap; import org.jetbrains.jet.lang.resolve.java.structure.*; import org.jetbrains.jet.lang.resolve.name.FqName; @@ -212,7 +212,7 @@ public class JavaTypeTransformer { } return new JetTypeImpl( - Collections.emptyList(), + Annotations.EMPTY, classData.getTypeConstructor(), nullable, arguments, diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java index 9e8b3c5d53d..5bc5c00ba5a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve.java.sam; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl; import org.jetbrains.jet.lang.resolve.java.descriptor.JavaClassDescriptor; @@ -113,7 +113,7 @@ public class SingleAbstractMethodUtils { parameterTypes.add(parameter.getType()); } return KotlinBuiltIns.getInstance().getFunctionType( - Collections.emptyList(), null, parameterTypes, returnType); + Annotations.EMPTY, null, parameterTypes, returnType); } private static boolean isSamInterface(@NotNull ClassDescriptor klass) { @@ -148,7 +148,7 @@ public class SingleAbstractMethodUtils { assert parameterType != null : "couldn't substitute type: " + parameterTypeUnsubstituted + ", substitutor = " + typeParameters.substitutor; ValueParameterDescriptor parameter = new ValueParameterDescriptorImpl( - result, 0, Collections.emptyList(), Name.identifier("function"), parameterType, false, null); + result, 0, Annotations.EMPTY, Name.identifier("function"), parameterType, false, null); JetType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE); assert returnType != null : "couldn't substitute type: " + samInterface.getDefaultType() + diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/kotlin/AnnotationDescriptorDeserializer.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/kotlin/AnnotationDescriptorDeserializer.java index 8b61997b588..0f51239759e 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/kotlin/AnnotationDescriptorDeserializer.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/kotlin/AnnotationDescriptorDeserializer.java @@ -26,6 +26,8 @@ import org.jetbrains.jet.descriptors.serialization.descriptors.AnnotationDeseria import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationsImpl; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.constants.EnumValue; @@ -96,20 +98,20 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer @NotNull @Override - public List loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto) { + public Annotations loadClassAnnotations(@NotNull ClassDescriptor descriptor, @NotNull ProtoBuf.Class classProto) { KotlinJvmBinaryClass kotlinClass = findKotlinClassByDescriptor(descriptor); if (kotlinClass == null) { // This means that the resource we're constructing the descriptor from is no longer present: KotlinClassFinder had found the // class earlier, but it can't now errorReporter.reportAnnotationLoadingError("Kotlin class for loading class annotations is not found: " + descriptor, null); - return Collections.emptyList(); + return Annotations.EMPTY; } try { return loadClassAnnotationsFromClass(kotlinClass); } catch (IOException e) { errorReporter.reportAnnotationLoadingError("Error loading member annotations from Kotlin class: " + kotlinClass, e); - return Collections.emptyList(); + return Annotations.EMPTY; } } @@ -128,7 +130,7 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer } @NotNull - private List loadClassAnnotationsFromClass(@NotNull KotlinJvmBinaryClass kotlinClass) throws IOException { + private Annotations loadClassAnnotationsFromClass(@NotNull KotlinJvmBinaryClass kotlinClass) throws IOException { final List result = new ArrayList(); kotlinClass.loadClassAnnotations(new KotlinJvmBinaryClass.AnnotationVisitor() { @@ -143,7 +145,7 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer } }); - return result; + return new AnnotationsImpl(result); } private static boolean ignoreAnnotation(@NotNull JvmClassName className) { @@ -221,20 +223,20 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer @NotNull @Override - public List loadCallableAnnotations( + public Annotations loadCallableAnnotations( @NotNull ClassOrPackageFragmentDescriptor container, @NotNull ProtoBuf.Callable proto, @NotNull NameResolver nameResolver, @NotNull AnnotatedCallableKind kind ) { MemberSignature signature = getCallableSignature(proto, nameResolver, kind); - if (signature == null) return Collections.emptyList(); + if (signature == null) return Annotations.EMPTY; return findClassAndLoadMemberAnnotations(container, proto, nameResolver, kind, signature); } @NotNull - private List findClassAndLoadMemberAnnotations( + private Annotations findClassAndLoadMemberAnnotations( @NotNull ClassOrPackageFragmentDescriptor container, @NotNull ProtoBuf.Callable proto, @NotNull NameResolver nameResolver, @@ -244,11 +246,11 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer KotlinJvmBinaryClass kotlinClass = findClassWithMemberAnnotations(container, proto, nameResolver, kind); if (kotlinClass == null) { errorReporter.reportAnnotationLoadingError("Kotlin class for loading member annotations is not found: " + container, null); - return Collections.emptyList(); + return Annotations.EMPTY; } - List annotations = memberAnnotations.invoke(kotlinClass).get(signature); - return annotations == null ? Collections.emptyList() : annotations; + Annotations annotations = new AnnotationsImpl(memberAnnotations.invoke(kotlinClass).get(signature)); + return annotations == null ? Annotations.EMPTY : annotations; } @Nullable @@ -500,7 +502,7 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer @NotNull @Override - public List loadValueParameterAnnotations( + public Annotations loadValueParameterAnnotations( @NotNull ClassOrPackageFragmentDescriptor container, @NotNull ProtoBuf.Callable callable, @NotNull NameResolver nameResolver, @@ -516,6 +518,6 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer } } - return Collections.emptyList(); + return Annotations.EMPTY; } } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ModuleDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ModuleDescriptorImpl.java index 7b6e9d7bf30..6f715d61a7f 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ModuleDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ModuleDescriptorImpl.java @@ -22,7 +22,7 @@ import com.intellij.openapi.diagnostic.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.PlatformToKotlinClassMap; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.CompositePackageFragmentProvider; import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.PackageViewDescriptorImpl; @@ -31,7 +31,9 @@ import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.TypeSubstitutor; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; public class ModuleDescriptorImpl extends DeclarationDescriptorImpl implements ModuleDescriptor { private static final Logger LOG = Logger.getInstance(ModuleDescriptorImpl.class); @@ -48,7 +50,7 @@ public class ModuleDescriptorImpl extends DeclarationDescriptorImpl implements M @NotNull List defaultImports, @NotNull PlatformToKotlinClassMap platformToKotlinClassMap ) { - super(Collections.emptyList(), name); + super(Annotations.EMPTY, name); if (!name.isSpecial()) { throw new IllegalArgumentException("module name must be special: " + name); } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptor.java index 4e288ccc165..3bdc285b5b7 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/ScriptDescriptor.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.descriptors; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.*; import org.jetbrains.jet.lang.resolve.DescriptorFactory; import org.jetbrains.jet.lang.resolve.name.Name; @@ -61,7 +62,7 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl { @NotNull JetScope scriptScope, @NotNull Name className ) { - super(containingDeclaration, Collections.emptyList(), NAME); + super(containingDeclaration, Annotations.EMPTY, NAME); this.priority = priority; classDescriptor = new ClassDescriptorImpl(containingDeclaration, className, Modality.FINAL, @@ -80,7 +81,7 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl { scriptCodeDescriptor.initialize(implicitReceiver, valueParameters, returnType); PropertyDescriptorImpl propertyDescriptor = new PropertyDescriptorImpl(classDescriptor, - Collections.emptyList(), + Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, false, @@ -155,7 +156,7 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl { public void setValueParameters(@NotNull List valueParameters) { this.valueParameters = valueParameters; ConstructorDescriptorImpl constructorDescriptor = - new ConstructorDescriptorImpl(classDescriptor, Collections.emptyList(), true) + new ConstructorDescriptorImpl(classDescriptor, Annotations.EMPTY, true) .initialize(Collections.emptyList(), valueParameters, Visibilities.PUBLIC); constructorDescriptor.setReturnType(classDescriptor.getDefaultType()); @@ -164,7 +165,7 @@ public class ScriptDescriptor extends DeclarationDescriptorNonRootImpl { for (ValueParameterDescriptor parameter : valueParameters) { PropertyDescriptorImpl propertyDescriptor = new PropertyDescriptorImpl(classDescriptor, - Collections.emptyList(), + Annotations.EMPTY, Modality.FINAL, Visibilities.PUBLIC, false, diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/Annotated.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/Annotated.java index b477e5bb832..69110545fec 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/Annotated.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/Annotated.java @@ -17,12 +17,8 @@ package org.jetbrains.jet.lang.descriptors.annotations; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.ReadOnly; - -import java.util.List; public interface Annotated { - @ReadOnly @NotNull - List getAnnotations(); + Annotations getAnnotations(); } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotatedImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotatedImpl.java index 775aea27c21..95f01c60d88 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotatedImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotatedImpl.java @@ -18,18 +18,16 @@ package org.jetbrains.jet.lang.descriptors.annotations; import org.jetbrains.annotations.NotNull; -import java.util.List; - public abstract class AnnotatedImpl implements Annotated { - private final List annotations; + private final Annotations annotations; - public AnnotatedImpl(List annotations) { + public AnnotatedImpl(@NotNull Annotations annotations) { this.annotations = annotations; } @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { return annotations; } } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/Annotations.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/Annotations.java new file mode 100644 index 00000000000..2a10a1edeca --- /dev/null +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/Annotations.java @@ -0,0 +1,44 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.lang.descriptors.annotations; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.ReadOnly; + +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +public interface Annotations extends Iterable { + Annotations EMPTY = new Annotations() { + @NotNull + @Override + public List getAnnotationDescriptors() { + return Collections.emptyList(); + } + + @NotNull + @Override + public Iterator iterator() { + return getAnnotationDescriptors().iterator(); + } + }; + + @NotNull + @ReadOnly + List getAnnotationDescriptors(); +} diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotationsImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotationsImpl.java new file mode 100644 index 00000000000..c2cb73eb1bc --- /dev/null +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/annotations/AnnotationsImpl.java @@ -0,0 +1,42 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.lang.descriptors.annotations; + +import org.jetbrains.annotations.NotNull; + +import java.util.Iterator; +import java.util.List; + +public class AnnotationsImpl implements Annotations { + private final List annotations; + + public AnnotationsImpl(@NotNull List annotations) { + this.annotations = annotations; + } + + @NotNull + @Override + public List getAnnotationDescriptors() { + return annotations; + } + + @NotNull + @Override + public Iterator iterator() { + return getAnnotationDescriptors().iterator(); + } +} diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AbstractLazyTypeParameterDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AbstractLazyTypeParameterDescriptor.java index a114738e8ac..8777dba7bce 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AbstractLazyTypeParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AbstractLazyTypeParameterDescriptor.java @@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.LazyScopeAdapter; @@ -181,7 +182,7 @@ public abstract class AbstractLazyTypeParameterDescriptor implements TypeParamet @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { return AbstractLazyTypeParameterDescriptor.this.getAnnotations(); } @@ -251,8 +252,8 @@ public abstract class AbstractLazyTypeParameterDescriptor implements TypeParamet @NotNull @Override - public List getAnnotations() { - return Collections.emptyList(); // TODO + public Annotations getAnnotations() { + return Annotations.EMPTY; // TODO } @NotNull diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AbstractReceiverParameterDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AbstractReceiverParameterDescriptor.java index 3066a6fdd84..29ce4e61883 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AbstractReceiverParameterDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AbstractReceiverParameterDescriptor.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.TransientReceiver; import org.jetbrains.jet.lang.types.JetType; @@ -34,7 +34,7 @@ public abstract class AbstractReceiverParameterDescriptor extends DeclarationDes private static final Name RECEIVER_PARAMETER_NAME = Name.special(""); public AbstractReceiverParameterDescriptor() { - super(Collections.emptyList(), RECEIVER_PARAMETER_NAME); + super(Annotations.EMPTY, RECEIVER_PARAMETER_NAME); } @Nullable diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AnonymousFunctionDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AnonymousFunctionDescriptor.java index 0ba01680c4f..5116f2b2f17 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AnonymousFunctionDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/AnonymousFunctionDescriptor.java @@ -18,15 +18,13 @@ package org.jetbrains.jet.lang.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; -import java.util.List; - public class AnonymousFunctionDescriptor extends SimpleFunctionDescriptorImpl { public AnonymousFunctionDescriptor( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Kind kind ) { super(containingDeclaration, annotations, Name.special(""), kind); diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ClassDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ClassDescriptorImpl.java index 31c7752bc2f..80cbc747718 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ClassDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ClassDescriptorImpl.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.JetType; @@ -29,7 +30,6 @@ import org.jetbrains.jet.storage.LockBasedStorageManager; import java.util.Collection; import java.util.Collections; -import java.util.List; import java.util.Set; public class ClassDescriptorImpl extends ClassDescriptorBase { @@ -49,7 +49,7 @@ public class ClassDescriptorImpl extends ClassDescriptorBase { super(LockBasedStorageManager.NO_LOCKS, containingDeclaration, name); this.modality = modality; - this.typeConstructor = new TypeConstructorImpl(this, Collections.emptyList(), false, getName().asString(), + this.typeConstructor = new TypeConstructorImpl(this, Annotations.EMPTY, false, getName().asString(), Collections.emptyList(), supertypes); } @@ -69,8 +69,8 @@ public class ClassDescriptorImpl extends ClassDescriptorBase { @NotNull @Override - public List getAnnotations() { - return Collections.emptyList(); + public Annotations getAnnotations() { + return Annotations.EMPTY; } @Override diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java index 9f8756dc48f..58707d745f0 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.name.Name; @@ -35,16 +36,16 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements private static final Name NAME = Name.special(""); - public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull List annotations, boolean isPrimary) { + public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull Annotations annotations, boolean isPrimary) { this(containingDeclaration, annotations, isPrimary, Kind.DECLARATION); } - public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull List annotations, boolean isPrimary, Kind kind) { + public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull Annotations annotations, boolean isPrimary, Kind kind) { super(containingDeclaration, annotations, NAME, kind); this.isPrimary = isPrimary; } - public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull ConstructorDescriptor original, @NotNull List annotations, boolean isPrimary) { + public ConstructorDescriptorImpl(@NotNull ClassDescriptor containingDeclaration, @NotNull ConstructorDescriptor original, @NotNull Annotations annotations, boolean isPrimary) { super(containingDeclaration, original, annotations, NAME, Kind.DECLARATION); this.isPrimary = isPrimary; } @@ -108,7 +109,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements return new ConstructorDescriptorImpl( (ClassDescriptor) newOwner, this, - Collections.emptyList(), // TODO + Annotations.EMPTY, // TODO isPrimary); } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/DeclarationDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/DeclarationDescriptorImpl.java index dcc59d91e39..0a9860370dc 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/DeclarationDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/DeclarationDescriptorImpl.java @@ -20,18 +20,16 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotatedImpl; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.renderer.DescriptorRenderer; -import java.util.List; - public abstract class DeclarationDescriptorImpl extends AnnotatedImpl implements DeclarationDescriptor { @NotNull private final Name name; - public DeclarationDescriptorImpl(@NotNull List annotations, @NotNull Name name) { + public DeclarationDescriptorImpl(@NotNull Annotations annotations, @NotNull Name name) { super(annotations); this.name = name; } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/DeclarationDescriptorNonRootImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/DeclarationDescriptorNonRootImpl.java index 2a59f9bf75d..dc8e8efb8d6 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/DeclarationDescriptorNonRootImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/DeclarationDescriptorNonRootImpl.java @@ -19,11 +19,9 @@ package org.jetbrains.jet.lang.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorNonRoot; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; -import java.util.List; - public abstract class DeclarationDescriptorNonRootImpl extends DeclarationDescriptorImpl implements DeclarationDescriptorNonRoot { @@ -33,7 +31,7 @@ public abstract class DeclarationDescriptorNonRootImpl public DeclarationDescriptorNonRootImpl( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name) { super(annotations, name); diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/EnumEntrySyntheticClassDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/EnumEntrySyntheticClassDescriptor.java index 460c8fb78f2..4ac390363cc 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/EnumEntrySyntheticClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/EnumEntrySyntheticClassDescriptor.java @@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.DescriptorFactory; import org.jetbrains.jet.lang.resolve.OverridingUtil; import org.jetbrains.jet.lang.resolve.name.Name; @@ -146,9 +147,9 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { // TODO - return Collections.emptyList(); + return Annotations.EMPTY; } private class EnumEntryScope extends JetScopeImpl { diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/FunctionDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/FunctionDescriptorImpl.java index 5b62f40bf80..8083a1be1f8 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/FunctionDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/FunctionDescriptorImpl.java @@ -21,7 +21,7 @@ import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.DescriptorFactory; import org.jetbrains.jet.lang.resolve.OverridingUtil; import org.jetbrains.jet.lang.resolve.name.Name; @@ -50,7 +50,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo protected FunctionDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @NotNull Kind kind) { super(containingDeclaration, annotations, name); @@ -61,7 +61,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo protected FunctionDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, @NotNull FunctionDescriptor original, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @NotNull Kind kind) { super(containingDeclaration, annotations, name); diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/LazySubstitutingClassDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/LazySubstitutingClassDescriptor.java index 47e1f8d93d0..d22b04a647f 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/LazySubstitutingClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/LazySubstitutingClassDescriptor.java @@ -20,7 +20,7 @@ import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.SubstitutingScope; @@ -119,7 +119,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { return original.getAnnotations(); } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptorLite.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptorLite.java index 3c1a3447139..99bd0da72e8 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptorLite.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/MutableClassDescriptorLite.java @@ -21,6 +21,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; +import org.jetbrains.jet.lang.descriptors.annotations.AnnotationsImpl; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScope; @@ -33,12 +35,11 @@ import org.jetbrains.jet.storage.LockBasedStorageManager; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.List; public abstract class MutableClassDescriptorLite extends ClassDescriptorBase { - private List annotations = Lists.newArrayList(); + private Annotations annotations = new AnnotationsImpl(new ArrayList(0)); private List typeParameters; private Collection supertypes = Lists.newArrayList(); @@ -81,7 +82,7 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase { assert typeConstructor == null : typeConstructor; this.typeConstructor = new TypeConstructorImpl( this, - Collections.emptyList(), // TODO : pass annotations from the class? + Annotations.EMPTY, // TODO : pass annotations from the class? !getModality().isOverridable(), getName().asString(), typeParameters, @@ -181,14 +182,18 @@ public abstract class MutableClassDescriptorLite extends ClassDescriptorBase { @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { return annotations; } - public void setAnnotations(List annotations) { + public void setAnnotations(Annotations annotations) { this.annotations = annotations; } + public void addAnnotations(@NotNull List annotationDescriptors) { + this.annotations.getAnnotationDescriptors().addAll(annotationDescriptors); + } + private PackageLikeBuilder builder = null; public PackageLikeBuilder getBuilder() { if (builder == null) { diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/MutablePackageFragmentDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/MutablePackageFragmentDescriptor.java index 91d8644fc38..c35179e9196 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/MutablePackageFragmentDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/MutablePackageFragmentDescriptor.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler; @@ -27,8 +27,6 @@ import org.jetbrains.jet.lang.resolve.scopes.WritableScope; import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl; import org.jetbrains.jet.lang.types.TypeSubstitutor; -import java.util.Collections; - public class MutablePackageFragmentDescriptor extends DeclarationDescriptorImpl implements PackageFragmentDescriptor { private final PackageFragmentProvider provider; @@ -42,7 +40,7 @@ public class MutablePackageFragmentDescriptor extends DeclarationDescriptorImpl @NotNull ModuleDescriptor module, @NotNull FqName fqName ) { - super(Collections.emptyList(), fqName.shortNameOrSpecial()); + super(Annotations.EMPTY, fqName.shortNameOrSpecial()); this.provider = provider; this.module = module; this.fqName = fqName; diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PackageViewDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PackageViewDescriptorImpl.java index c389bd2ee9f..3df6f522d2c 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PackageViewDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PackageViewDescriptorImpl.java @@ -20,13 +20,12 @@ import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.scopes.ChainedScope; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.TypeSubstitutor; -import java.util.Collections; import java.util.List; public class PackageViewDescriptorImpl extends DeclarationDescriptorImpl implements PackageViewDescriptor { @@ -39,7 +38,7 @@ public class PackageViewDescriptorImpl extends DeclarationDescriptorImpl impleme @NotNull FqName fqName, @NotNull List fragments ) { - super(Collections.emptyList(), fqName.shortNameOrSpecial()); + super(Annotations.EMPTY, fqName.shortNameOrSpecial()); this.module = module; this.fqName = fqName; diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyAccessorDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyAccessorDescriptorImpl.java index a300b6427e5..317283fe9e5 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyAccessorDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyAccessorDescriptorImpl.java @@ -20,7 +20,7 @@ import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.TypeSubstitutor; @@ -41,7 +41,7 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript @NotNull Modality modality, @NotNull Visibility visibility, @NotNull PropertyDescriptor correspondingProperty, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, boolean hasBody, boolean isDefault, diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyDescriptorImpl.java index 71e578b3142..b84c82ff4b9 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyDescriptorImpl.java @@ -21,7 +21,7 @@ import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.DescriptorFactory; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.OverridingUtil; @@ -55,7 +55,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr private PropertyDescriptorImpl( @Nullable PropertyDescriptor original, @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Modality modality, @NotNull Visibility visibility, boolean isVar, @@ -72,7 +72,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr public PropertyDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Modality modality, @NotNull Visibility visibility, boolean isVar, @@ -84,7 +84,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr public PropertyDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Modality modality, @NotNull Visibility visibility, boolean isVar, @@ -251,7 +251,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr substitutedDescriptor.setType(outType, substitutedTypeParameters, substitutedExpectedThisObject, substitutedReceiverType); PropertyGetterDescriptorImpl newGetter = getter == null ? null : new PropertyGetterDescriptorImpl( - substitutedDescriptor, Lists.newArrayList(getter.getAnnotations()), + substitutedDescriptor, getter.getAnnotations(), DescriptorUtils.convertModality(getter.getModality(), false), convertVisibility(getter.getVisibility(), newVisibility), getter.hasBody(), getter.isDefault(), kind, getter.getOriginal()); if (newGetter != null) { @@ -259,7 +259,7 @@ public class PropertyDescriptorImpl extends VariableDescriptorImpl implements Pr newGetter.initialize(returnType != null ? substitutor.substitute(returnType, Variance.OUT_VARIANCE) : null); } PropertySetterDescriptorImpl newSetter = setter == null ? null : new PropertySetterDescriptorImpl( - substitutedDescriptor, Lists.newArrayList(setter.getAnnotations()), DescriptorUtils.convertModality(setter.getModality(), false), + substitutedDescriptor, setter.getAnnotations(), DescriptorUtils.convertModality(setter.getModality(), false), convertVisibility(setter.getVisibility(), newVisibility), setter.hasBody(), setter.isDefault(), kind, setter.getOriginal()); if (newSetter != null) { List substitutedValueParameters = FunctionDescriptorImpl.getSubstitutedValueParameters(newSetter, setter, substitutor); diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyGetterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyGetterDescriptorImpl.java index 1871ed91c17..8141c17fcfa 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyGetterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertyGetterDescriptorImpl.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; @@ -35,7 +35,7 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl public PropertyGetterDescriptorImpl( @NotNull PropertyDescriptor correspondingProperty, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Modality modality, @NotNull Visibility visibility, boolean hasBody, @@ -47,7 +47,7 @@ public class PropertyGetterDescriptorImpl extends PropertyAccessorDescriptorImpl public PropertyGetterDescriptorImpl( @NotNull PropertyDescriptor correspondingProperty, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Modality modality, @NotNull Visibility visibility, boolean hasBody, diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertySetterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertySetterDescriptorImpl.java index f06ec7ef988..9ef3bd80832 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertySetterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/PropertySetterDescriptorImpl.java @@ -20,6 +20,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; @@ -36,7 +37,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl public PropertySetterDescriptorImpl( @NotNull PropertyDescriptor correspondingProperty, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Modality modality, @NotNull Visibility visibility, boolean hasBody, @@ -48,7 +49,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl public PropertySetterDescriptorImpl( @NotNull PropertyDescriptor correspondingProperty, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Modality modality, @NotNull Visibility visibility, boolean hasBody, @@ -75,7 +76,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl @NotNull JetType type ) { return new ValueParameterDescriptorImpl( - setterDescriptor, 0, Collections.emptyList(), Name.special(""), type, false, null + setterDescriptor, 0, Annotations.EMPTY, Name.special(""), type, false, null ); } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ScriptCodeDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ScriptCodeDescriptor.java index 62878ba5176..f459259b551 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ScriptCodeDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ScriptCodeDescriptor.java @@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; @@ -28,7 +28,7 @@ import java.util.List; public class ScriptCodeDescriptor extends FunctionDescriptorImpl { public ScriptCodeDescriptor(@NotNull ScriptDescriptor containingDeclaration) { - super(containingDeclaration, Collections.emptyList(), Name.special(""), Kind.DECLARATION); + super(containingDeclaration, Annotations.EMPTY, Name.special(""), Kind.DECLARATION); setVisibility(Visibilities.LOCAL); } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/SimpleFunctionDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/SimpleFunctionDescriptorImpl.java index daba8bf062b..c543008dd06 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/SimpleFunctionDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/SimpleFunctionDescriptorImpl.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeSubstitutor; @@ -34,7 +34,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme public SimpleFunctionDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @NotNull Kind kind ) { @@ -44,7 +44,7 @@ public class SimpleFunctionDescriptorImpl extends FunctionDescriptorImpl impleme protected SimpleFunctionDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, @NotNull SimpleFunctionDescriptor original, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @NotNull Kind kind) { super(containingDeclaration, original, annotations, name, kind); diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/TypeParameterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/TypeParameterDescriptorImpl.java index 3c3127b81e5..e46273e5d49 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/TypeParameterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/TypeParameterDescriptorImpl.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptorVisitor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; @@ -33,7 +33,6 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.renderer.DescriptorRenderer; import java.util.Collections; -import java.util.List; import java.util.Set; import static org.jetbrains.jet.storage.LockBasedStorageManager.NO_LOCKS; @@ -41,7 +40,7 @@ import static org.jetbrains.jet.storage.LockBasedStorageManager.NO_LOCKS; public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImpl implements TypeParameterDescriptor { public static TypeParameterDescriptor createWithDefaultBound( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, boolean reified, @NotNull Variance variance, @NotNull Name name, @@ -54,7 +53,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp public static TypeParameterDescriptorImpl createForFurtherModification( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, boolean reified, @NotNull Variance variance, @NotNull Name name, @@ -78,7 +77,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp private TypeParameterDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, boolean reified, @NotNull Variance variance, @NotNull Name name, @@ -220,7 +219,7 @@ public class TypeParameterDescriptorImpl extends DeclarationDescriptorNonRootImp //checkInitialized(); if (defaultType == null) { defaultType = new JetTypeImpl( - Collections.emptyList(), + Annotations.EMPTY, getTypeConstructor(), TypeUtils.hasNullableLowerBound(this), Collections.emptyList(), diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ValueParameterDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ValueParameterDescriptorImpl.java index d8ff557aa12..81470d0c2ad 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ValueParameterDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ValueParameterDescriptorImpl.java @@ -16,18 +16,16 @@ package org.jetbrains.jet.lang.descriptors.impl; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeSubstitutor; import java.util.Collections; -import java.util.List; import java.util.Set; public class ValueParameterDescriptorImpl extends VariableDescriptorImpl implements ValueParameterDescriptor { @@ -45,7 +43,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme public ValueParameterDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, int index, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @NotNull JetType outType, boolean declaresDefaultValue, @@ -61,7 +59,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme public ValueParameterDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, @NotNull ValueParameterDescriptor original, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull JetType outType, @Nullable JetType varargElementType ) { @@ -140,7 +138,7 @@ public class ValueParameterDescriptorImpl extends VariableDescriptorImpl impleme @NotNull @Override public ValueParameterDescriptor copy(@NotNull DeclarationDescriptor newOwner, @NotNull Name newName) { - return new ValueParameterDescriptorImpl(newOwner, index, Lists.newArrayList(getAnnotations()), newName, getType(), declaresDefaultValue(), varargElementType); + return new ValueParameterDescriptorImpl(newOwner, index, getAnnotations(), newName, getType(), declaresDefaultValue(), varargElementType); } @NotNull diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/VariableDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/VariableDescriptorImpl.java index a5aaebcf886..9109a7a04a9 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/VariableDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/VariableDescriptorImpl.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.descriptors.impl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; @@ -32,7 +32,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo public VariableDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name, @Nullable JetType outType) { super(containingDeclaration, annotations, name); @@ -42,7 +42,7 @@ public abstract class VariableDescriptorImpl extends DeclarationDescriptorNonRoo protected VariableDescriptorImpl( @NotNull DeclarationDescriptor containingDeclaration, - @NotNull List annotations, + @NotNull Annotations annotations, @NotNull Name name ) { diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorFactory.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorFactory.java index 7eada0cedca..42205b7b708 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorFactory.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorFactory.java @@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.resolve; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.*; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver; @@ -37,7 +37,7 @@ public class DescriptorFactory { private static class DefaultConstructorDescriptor extends ConstructorDescriptorImpl { public DefaultConstructorDescriptor(@NotNull ClassDescriptor containingClass) { - super(containingClass, Collections.emptyList(), true); + super(containingClass, Annotations.EMPTY, true); initialize(Collections.emptyList(), Collections.emptyList(), getDefaultConstructorVisibility(containingClass), true); } @@ -54,7 +54,7 @@ public class DescriptorFactory { @NotNull public static PropertySetterDescriptorImpl createSetter(@NotNull PropertyDescriptor propertyDescriptor, boolean isDefault) { PropertySetterDescriptorImpl setterDescriptor = new PropertySetterDescriptorImpl( - propertyDescriptor, Collections.emptyList(), propertyDescriptor.getModality(), + propertyDescriptor, Annotations.EMPTY, propertyDescriptor.getModality(), propertyDescriptor.getVisibility(), !isDefault, isDefault, CallableMemberDescriptor.Kind.DECLARATION); setterDescriptor.initializeDefault(); @@ -69,7 +69,7 @@ public class DescriptorFactory { @NotNull public static PropertyGetterDescriptorImpl createGetter(@NotNull PropertyDescriptor propertyDescriptor, boolean isDefault) { return new PropertyGetterDescriptorImpl( - propertyDescriptor, Collections.emptyList(), propertyDescriptor.getModality(), + propertyDescriptor, Annotations.EMPTY, propertyDescriptor.getModality(), propertyDescriptor.getVisibility(), !isDefault, isDefault, CallableMemberDescriptor.Kind.DECLARATION); } @@ -89,7 +89,7 @@ public class DescriptorFactory { @NotNull JetType returnType ) { SimpleFunctionDescriptorImpl values = - new SimpleFunctionDescriptorImpl(classObject, Collections.emptyList(), VALUES_METHOD_NAME, + new SimpleFunctionDescriptorImpl(classObject, Annotations.EMPTY, VALUES_METHOD_NAME, CallableMemberDescriptor.Kind.SYNTHESIZED); return values.initialize(null, classObject.getThisAsReceiverParameter(), Collections.emptyList(), Collections.emptyList(), @@ -103,12 +103,12 @@ public class DescriptorFactory { @NotNull JetType returnType ) { SimpleFunctionDescriptorImpl values = - new SimpleFunctionDescriptorImpl(classObject, Collections.emptyList(), VALUE_OF_METHOD_NAME, + new SimpleFunctionDescriptorImpl(classObject, Annotations.EMPTY, VALUE_OF_METHOD_NAME, CallableMemberDescriptor.Kind.SYNTHESIZED); ValueParameterDescriptor parameterDescriptor = new ValueParameterDescriptorImpl( values, 0, - Collections.emptyList(), + Annotations.EMPTY, Name.identifier("value"), KotlinBuiltIns.getInstance().getStringType(), false, diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/constants/IntegerValueTypeConstant.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/constants/IntegerValueTypeConstant.java index aacc8e0e45b..4355203267f 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/constants/IntegerValueTypeConstant.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/constants/IntegerValueTypeConstant.java @@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.resolve.constants; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.types.ErrorUtils; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetTypeImpl; @@ -37,7 +37,7 @@ public class IntegerValueTypeConstant extends CompileTimeConstantemptyList(), getValue(), + Annotations.EMPTY, getValue(), false, Collections.emptyList(), ErrorUtils.createErrorScope("Scope for number value type (" + getValue().toString() + ")", true)); } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/constants/IntegerValueTypeConstructor.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/constants/IntegerValueTypeConstructor.java index 1b824e582dc..0032cb75697 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/constants/IntegerValueTypeConstructor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/constants/IntegerValueTypeConstructor.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeConstructor; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; @@ -81,8 +81,8 @@ public class IntegerValueTypeConstructor implements TypeConstructor { @NotNull @Override - public List getAnnotations() { - return Collections.emptyList(); + public Annotations getAnnotations() { + return Annotations.EMPTY; } public Long getValue() { diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/CommonSupertypes.java b/core/descriptors/src/org/jetbrains/jet/lang/types/CommonSupertypes.java index a862f226796..3e55e4b2adf 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/CommonSupertypes.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/CommonSupertypes.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.types.checker.JetTypeChecker; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; @@ -169,7 +169,7 @@ public class CommonSupertypes { if (declarationDescriptor instanceof ClassDescriptor) { newScope = ((ClassDescriptor) declarationDescriptor).getMemberScope(newProjections); } - return new JetTypeImpl(Collections.emptyList(), constructor, nullable, newProjections, newScope); + return new JetTypeImpl(Annotations.EMPTY, constructor, nullable, newProjections, newScope); } @NotNull diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/ErrorUtils.java b/core/descriptors/src/org/jetbrains/jet/lang/types/ErrorUtils.java index 2da3c995984..7dab43cffb4 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/ErrorUtils.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/ErrorUtils.java @@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.PlatformToKotlinClassMap; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.jet.lang.resolve.ImportPath; @@ -244,7 +245,7 @@ public class ErrorUtils { private static final JetType ERROR_PROPERTY_TYPE = createErrorType(""); private static final VariableDescriptor ERROR_PROPERTY = new PropertyDescriptorImpl( ERROR_CLASS, - Collections.emptyList(), + Annotations.EMPTY, Modality.OPEN, Visibilities.INTERNAL, true, @@ -287,7 +288,7 @@ public class ErrorUtils { @NotNull private static TypeConstructor createErrorTypeConstructorWithCustomDebugName(@NotNull String debugName) { - return new TypeConstructorImpl(ERROR_CLASS, Collections.emptyList(), false, debugName, + return new TypeConstructorImpl(ERROR_CLASS, Annotations.EMPTY, false, debugName, Collections.emptyList(), Collections.singleton(KotlinBuiltIns.getInstance().getAnyType())); } @@ -319,7 +320,7 @@ public class ErrorUtils { public static TypeParameterDescriptor createErrorTypeParameter(int index, @NotNull String debugMessage) { return TypeParameterDescriptorImpl.createWithDefaultBound( ERROR_CLASS, - Collections.emptyList(), + Annotations.EMPTY, false, Variance.INVARIANT, Name.special(""), @@ -366,8 +367,8 @@ public class ErrorUtils { @NotNull @Override - public List getAnnotations() { - return Collections.emptyList(); + public Annotations getAnnotations() { + return Annotations.EMPTY; } @Override diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/IntersectionTypeConstructor.java b/core/descriptors/src/org/jetbrains/jet/lang/types/IntersectionTypeConstructor.java index 5c83bb93c5e..67967f4fe41 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/IntersectionTypeConstructor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/IntersectionTypeConstructor.java @@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotatedImpl; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import java.util.*; @@ -30,7 +30,7 @@ public class IntersectionTypeConstructor extends AnnotatedImpl implements TypeCo private final Set intersectedTypes; private final int hashCode; - public IntersectionTypeConstructor(List annotations, Collection typesToIntersect) { + public IntersectionTypeConstructor(Annotations annotations, Collection typesToIntersect) { super(annotations); this.intersectedTypes = Sets.newLinkedHashSet(typesToIntersect); this.hashCode = intersectedTypes.hashCode(); diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/JetTypeImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/types/JetTypeImpl.java index 3cf429ab915..56a27127881 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/JetTypeImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/JetTypeImpl.java @@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.types; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.ClassDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import java.util.Collections; @@ -30,9 +30,9 @@ public final class JetTypeImpl extends AbstractJetType { private final List arguments; private final boolean nullable; private final JetScope memberScope; - private final List annotations; + private final Annotations annotations; - public JetTypeImpl(List annotations, TypeConstructor constructor, boolean nullable, @NotNull List arguments, JetScope memberScope) { + public JetTypeImpl(Annotations annotations, TypeConstructor constructor, boolean nullable, @NotNull List arguments, JetScope memberScope) { this.annotations = annotations; if (memberScope instanceof ErrorUtils.ErrorScope) { @@ -46,11 +46,11 @@ public final class JetTypeImpl extends AbstractJetType { } public JetTypeImpl(TypeConstructor constructor, JetScope memberScope) { - this(Collections.emptyList(), constructor, false, Collections.emptyList(), memberScope); + this(Annotations.EMPTY, constructor, false, Collections.emptyList(), memberScope); } public JetTypeImpl(@NotNull ClassDescriptor classDescriptor) { - this(Collections.emptyList(), + this(Annotations.EMPTY, classDescriptor.getTypeConstructor(), false, Collections.emptyList(), @@ -59,7 +59,7 @@ public final class JetTypeImpl extends AbstractJetType { @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { return annotations; } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/PackageType.java b/core/descriptors/src/org/jetbrains/jet/lang/types/PackageType.java index 7872df63f57..c461dcf40ef 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/PackageType.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/PackageType.java @@ -17,7 +17,7 @@ package org.jetbrains.jet.lang.types; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.JetScope; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue; @@ -80,7 +80,7 @@ public class PackageType implements JetType { @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { throwException(); return null; } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeConstructorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeConstructorImpl.java index 8668ed5a16c..40bb7152c57 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeConstructorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeConstructorImpl.java @@ -21,7 +21,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotatedImpl; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import java.util.ArrayList; import java.util.Collection; @@ -39,7 +39,7 @@ public class TypeConstructorImpl extends AnnotatedImpl implements TypeConstructo public TypeConstructorImpl( @Nullable ClassifierDescriptor classifierDescriptor, - @NotNull List annotations, + @NotNull Annotations annotations, boolean isFinal, @NotNull String debugName, @NotNull List parameters, diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java index b84ff4832d1..da20557d229 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -30,7 +30,7 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintPosition; import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl; import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstructor; @@ -86,7 +86,7 @@ public class TypeUtils { @NotNull @Override - public List getAnnotations() { + public Annotations getAnnotations() { throw new IllegalStateException(name); } @@ -199,10 +199,7 @@ public class TypeUtils { } - List noAnnotations = Collections.emptyList(); - TypeConstructor constructor = new IntersectionTypeConstructor( - noAnnotations, - resultingTypes); + TypeConstructor constructor = new IntersectionTypeConstructor(Annotations.EMPTY, resultingTypes); JetScope[] scopes = new JetScope[resultingTypes.size()]; int i = 0; @@ -212,7 +209,7 @@ public class TypeUtils { } return new JetTypeImpl( - noAnnotations, + Annotations.EMPTY, constructor, allNullable, Collections.emptyList(), @@ -360,7 +357,7 @@ public class TypeUtils { TypeConstructor typeConstructor = classDescriptor.getTypeConstructor(); List arguments = getDefaultTypeProjections(typeConstructor.getParameters()); return new JetTypeImpl( - Collections.emptyList(), + Annotations.EMPTY, typeConstructor, false, arguments, @@ -767,7 +764,7 @@ public class TypeUtils { @Override @NotNull - public List getAnnotations() { + public Annotations getAnnotations() { return delegate.getAnnotations(); } } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/error/ErrorClassDescriptor.java b/core/descriptors/src/org/jetbrains/jet/lang/types/error/ErrorClassDescriptor.java index 24d13601c08..6ab176ccd90 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/error/ErrorClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/error/ErrorClassDescriptor.java @@ -18,7 +18,7 @@ package org.jetbrains.jet.lang.types.error; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.ConstructorDescriptorImpl; import org.jetbrains.jet.lang.resolve.name.Name; @@ -37,7 +37,7 @@ public final class ErrorClassDescriptor extends ClassDescriptorImpl { super(getErrorModule(), Name.special(""), Modality.OPEN, Collections.emptyList()); ConstructorDescriptorImpl errorConstructor = - new ConstructorDescriptorImpl(this, Collections.emptyList(), true); + new ConstructorDescriptorImpl(this, Annotations.EMPTY, true); errorConstructor.initialize( Collections.emptyList(), // TODO diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/error/ErrorSimpleFunctionDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/types/error/ErrorSimpleFunctionDescriptorImpl.java index a91b011e236..6d17dc6c44b 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/error/ErrorSimpleFunctionDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/error/ErrorSimpleFunctionDescriptorImpl.java @@ -18,22 +18,19 @@ package org.jetbrains.jet.lang.types.error; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.FunctionDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.ErrorUtils; -import java.util.Collections; - public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorImpl { // used for diagnostic only @NotNull private final ErrorUtils.ErrorScope ownerScope; public ErrorSimpleFunctionDescriptorImpl(ErrorUtils.ErrorScope ownerScope) { - super(ErrorUtils.getErrorClass(), Collections.emptyList(), Name.special(""), Kind.DECLARATION); + super(ErrorUtils.getErrorClass(), Annotations.EMPTY, Name.special(""), Kind.DECLARATION); this.ownerScope = ownerScope; } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/BuiltinsPackageFragment.java b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/BuiltinsPackageFragment.java index f001cb7e4c2..02481b35529 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/BuiltinsPackageFragment.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/BuiltinsPackageFragment.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.descriptors.serialization.*; import org.jetbrains.jet.descriptors.serialization.descriptors.DeserializedPackageMemberScope; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.DeclarationDescriptorImpl; import org.jetbrains.jet.lang.descriptors.impl.MutablePackageFragmentDescriptor; import org.jetbrains.jet.lang.resolve.name.FqName; @@ -33,7 +33,7 @@ class BuiltinsPackageFragment extends DeclarationDescriptorImpl implements Packa private final PackageFragmentProvider packageFragmentProvider; public BuiltinsPackageFragment(@NotNull StorageManager storageManager, @NotNull ModuleDescriptor module) { - super(Collections.emptyList(), KotlinBuiltIns.BUILT_INS_PACKAGE_NAME); + super(Annotations.EMPTY, KotlinBuiltIns.BUILT_INS_PACKAGE_NAME); this.module = module; nameResolver = NameSerializationUtil.deserializeNameResolver(getStream(BuiltInsSerializationUtil.getNameTableFilePath(getFqName()))); diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/InlineUtil.java b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/InlineUtil.java index 44a365df03d..bd0f65dabd0 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/InlineUtil.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/InlineUtil.java @@ -23,11 +23,10 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.Annotated; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.constants.EnumValue; -import java.util.List; - public class InlineUtil { public static boolean DEFAULT_INLINE_FLAG = false; @@ -49,7 +48,7 @@ public class InlineUtil { } @NotNull - public static InlineStrategy getInlineType(@Nullable List annotations) { + public static InlineStrategy getInlineType(@Nullable Annotations annotations) { KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance(); ClassDescriptor annotationClass = builtIns.getInlineClassAnnotation(); AnnotationDescriptor annotation = getAnnotation(annotations, annotationClass); @@ -73,7 +72,7 @@ public class InlineUtil { } @Nullable - private static AnnotationDescriptor getAnnotation(@Nullable List annotations, @NotNull ClassDescriptor annotationClass) { + private static AnnotationDescriptor getAnnotation(@Nullable Annotations annotations, @NotNull ClassDescriptor annotationClass) { if (annotations != null) { for (AnnotationDescriptor annotation : annotations) { if (annotationClass.equals(annotation.getType().getConstructor().getDeclarationDescriptor())) { diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java index 13834dbeaa8..91d53cbe373 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/lang/KotlinBuiltIns.java @@ -23,6 +23,7 @@ import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.PlatformToKotlinClassMap; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.descriptors.impl.ValueParameterDescriptorImpl; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.ImportPath; @@ -677,7 +678,7 @@ public class KotlinBuiltIns { public JetType getArrayType(@NotNull Variance projectionType, @NotNull JetType argument) { List types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument)); return new JetTypeImpl( - Collections.emptyList(), + Annotations.EMPTY, getArray().getTypeConstructor(), false, types, @@ -695,7 +696,7 @@ public class KotlinBuiltIns { Variance projectionType = Variance.INVARIANT; List types = Collections.singletonList(new TypeProjectionImpl(projectionType, argument)); return new JetTypeImpl( - Collections.emptyList(), + Annotations.EMPTY, getEnum().getTypeConstructor(), false, types, @@ -720,7 +721,7 @@ public class KotlinBuiltIns { @NotNull public JetType getFunctionType( - @NotNull List annotations, + @NotNull Annotations annotations, @Nullable JetType receiverType, @NotNull List parameterTypes, @NotNull JetType returnType @@ -735,7 +736,7 @@ public class KotlinBuiltIns { @NotNull public JetType getKFunctionType( - @NotNull List annotations, + @NotNull Annotations annotations, @Nullable JetType receiverType, @NotNull List parameterTypes, @NotNull JetType returnType, @@ -865,7 +866,7 @@ public class KotlinBuiltIns { for (int i = 0; i < parameterTypes.size(); i++) { TypeProjection parameterType = parameterTypes.get(i); ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl( - functionDescriptor, i, Collections.emptyList(), + functionDescriptor, i, Annotations.EMPTY, Name.identifier("p" + (i + 1)), parameterType.getType(), false, null); valueParameters.add(valueParameterDescriptor); } @@ -931,12 +932,10 @@ public class KotlinBuiltIns { } static boolean containsAnnotation(DeclarationDescriptor descriptor, ClassDescriptor annotationClass) { - List annotations = descriptor.getOriginal().getAnnotations(); - if (annotations != null) { - for (AnnotationDescriptor annotation : annotations) { - if (annotationClass.equals(annotation.getType().getConstructor().getDeclarationDescriptor())) { - return true; - } + Annotations annotations = descriptor.getOriginal().getAnnotations(); + for (AnnotationDescriptor annotation : annotations) { + if (annotationClass.equals(annotation.getType().getConstructor().getDeclarationDescriptor())) { + return true; } } return false; diff --git a/idea/src/org/jetbrains/jet/plugin/project/ResolveElementCache.java b/idea/src/org/jetbrains/jet/plugin/project/ResolveElementCache.java index ec434a15dae..afefb5351e9 100644 --- a/idea/src/org/jetbrains/jet/plugin/project/ResolveElementCache.java +++ b/idea/src/org/jetbrains/jet/plugin/project/ResolveElementCache.java @@ -216,7 +216,7 @@ public class ResolveElementCache { Annotated descriptor = analyzer.resolveToDescriptor(declaration); // Activate annotation resolving - descriptor.getAnnotations(); + descriptor.getAnnotations().getAnnotationDescriptors(); } } diff --git a/js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java b/js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java index 20b40db85e6..8c879d1bdec 100644 --- a/js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java +++ b/js/js.translator/src/org/jetbrains/k2js/translate/general/JetTestFunctionDetector.java @@ -20,6 +20,7 @@ import com.google.common.collect.Lists; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor; +import org.jetbrains.jet.lang.descriptors.annotations.Annotations; import org.jetbrains.jet.lang.psi.JetClass; import org.jetbrains.jet.lang.psi.JetDeclaration; import org.jetbrains.jet.lang.psi.JetFile; @@ -45,15 +46,13 @@ public class JetTestFunctionDetector { if (functionDescriptor == null) { return false; } - List annotations = functionDescriptor.getAnnotations(); - if (annotations != null) { - for (AnnotationDescriptor annotation : annotations) { - // TODO ideally we should find the fully qualified name here... - JetType type = annotation.getType(); - String name = type.toString(); - if (name.equals("Test")) { - return true; - } + Annotations annotations = functionDescriptor.getAnnotations(); + for (AnnotationDescriptor annotation : annotations) { + // TODO ideally we should find the fully qualified name here... + JetType type = annotation.getType(); + String name = type.toString(); + if (name.equals("Test")) { + return true; } }