diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt index 5c0b3adaf3e..c708df99423 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/kotlin/native.kt @@ -16,22 +16,21 @@ package org.jetbrains.kotlin.load.kotlin.nativeDeclarations -import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.DeclarationChecker -import org.jetbrains.kotlin.psi.JetDeclaration -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.diagnostics.DiagnosticSink -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor import org.jetbrains.kotlin.descriptors.ConstructorDescriptor +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.diagnostics.Errors -import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm +import org.jetbrains.kotlin.diagnostics.DiagnosticSink +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.JetDeclaration import org.jetbrains.kotlin.psi.JetDeclarationWithBody import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.resolve.annotations.hasInlineAnnotation -import org.jetbrains.kotlin.resolve.diagnostics.SuppressDiagnosticsByAnnotations +import org.jetbrains.kotlin.resolve.DeclarationChecker +import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.diagnostics.FUNCTION_NO_BODY_ERRORS +import org.jetbrains.kotlin.resolve.diagnostics.SuppressDiagnosticsByAnnotations +import org.jetbrains.kotlin.resolve.inline.InlineUtil +import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm private val NATIVE_ANNOTATION_CLASS_NAME = FqName("kotlin.jvm.native") private val EXTERNAL_ANNOTATION_CLASS_NAME = FqName("kotlin.external") @@ -66,7 +65,7 @@ public class NativeFunChecker : DeclarationChecker { diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY.on(declaration)) } - if (descriptor.hasInlineAnnotation()) { + if (InlineUtil.isInline(descriptor)) { diagnosticHolder.report(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_INLINED.on(declaration)) } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt index 527d68e41a2..7bb2de342dc 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt @@ -28,9 +28,9 @@ import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.DeclarationChecker import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.resolve.annotations.hasInlineAnnotation import org.jetbrains.kotlin.resolve.annotations.hasIntrinsicAnnotation import org.jetbrains.kotlin.resolve.annotations.hasPlatformStaticAnnotation +import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.jvm.annotations.hasJvmOverloadsAnnotation import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm @@ -41,7 +41,7 @@ public class LocalFunInlineChecker : DeclarationChecker { descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink, bindingContext: BindingContext) { - if (descriptor.hasInlineAnnotation() && + if (InlineUtil.isInline(descriptor) && declaration is JetNamedFunction && descriptor is FunctionDescriptor && descriptor.getVisibility() == Visibilities.LOCAL) { @@ -217,9 +217,10 @@ public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker { ) { if (descriptor.hasIntrinsicAnnotation()) return - if (descriptor is CallableDescriptor && !descriptor.hasInlineAnnotation()) { + if (descriptor is CallableDescriptor && !InlineUtil.isInline(descriptor)) { checkTypeParameterDescriptorsAreNotReified(descriptor.getTypeParameters(), diagnosticHolder) } + if (descriptor is ClassDescriptor) { checkTypeParameterDescriptorsAreNotReified(descriptor.getTypeConstructor().getParameters(), diagnosticHolder) } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetFlowInformationProvider.java b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetFlowInformationProvider.java index 594cca2b472..954cc9984fe 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetFlowInformationProvider.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/JetFlowInformationProvider.java @@ -795,7 +795,7 @@ public class JetFlowInformationProvider { public void markTailCalls() { final DeclarationDescriptor subroutineDescriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, subroutine); if (!(subroutineDescriptor instanceof FunctionDescriptor)) return; - if (!KotlinBuiltIns.isTailRecursive(subroutineDescriptor)) return; + if (!((FunctionDescriptor) subroutineDescriptor).isTailrec()) return; // finally blocks are copied which leads to multiple diagnostics reported on one instruction class KindAndCall { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/lexer/JetTokens.java b/compiler/frontend/src/org/jetbrains/kotlin/lexer/JetTokens.java index e98ffc57af8..47f016298cc 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/lexer/JetTokens.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/lexer/JetTokens.java @@ -216,11 +216,6 @@ public interface JetTokens { CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD }; - // Please synchronize this array with org.jetbrains.kotlin.descriptors.annotations.ANNOTATION_MODIFIERS_FQ_NAMES - JetModifierKeywordToken[] ANNOTATION_MODIFIERS_KEYWORDS_ARRAY = new JetModifierKeywordToken[] { - INLINE_KEYWORD, NOINLINE_KEYWORD, TAILREC_KEYWORD, EXTERNAL_KEYWORD, CROSSINLINE_KEYWORD - }; - TokenSet MODIFIER_KEYWORDS = TokenSet.create(MODIFIER_KEYWORDS_ARRAY); TokenSet VISIBILITY_MODIFIERS = TokenSet.create(PRIVATE_KEYWORD, PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java index 8ce55f494e2..8d4d8faf304 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolver.java @@ -18,14 +18,10 @@ package org.jetbrains.kotlin.resolve; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.annotations.*; import org.jetbrains.kotlin.diagnostics.Errors; -import org.jetbrains.kotlin.lexer.JetModifierKeywordToken; -import org.jetbrains.kotlin.lexer.JetTokens; import org.jetbrains.kotlin.psi.*; -import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt; import org.jetbrains.kotlin.resolve.calls.CallResolver; import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument; import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults; @@ -55,19 +51,14 @@ public class AnnotationResolver { @NotNull private TypeResolver typeResolver; @NotNull private final ConstantExpressionEvaluator constantExpressionEvaluator; - @NotNull private final List modifiersAnnotations; - public AnnotationResolver( @NotNull CallResolver callResolver, @NotNull ConstantExpressionEvaluator constantExpressionEvaluator, - @NotNull StorageManager storageManager, - @NotNull KotlinBuiltIns kotlinBuiltIns + @NotNull StorageManager storageManager ) { this.callResolver = callResolver; this.constantExpressionEvaluator = constantExpressionEvaluator; this.storageManager = storageManager; - - modifiersAnnotations = AnnotationUtilKt.buildMigrationAnnotationDescriptors(kotlinBuiltIns); } @@ -124,30 +115,7 @@ public class AnnotationResolver { } List annotationEntryElements = modifierList.getAnnotationEntries(); - - return resolveAndAppendAnnotationsFromModifiers( - resolveAnnotationEntries(scope, annotationEntryElements, trace, shouldResolveArguments), - modifierList - ); - } - - @NotNull - public Annotations resolveAndAppendAnnotationsFromModifiers( - @NotNull Annotations annotations, - @NotNull JetModifierList modifierList - ) { - List annotationFromModifiers = new ArrayList(); - - for (int i = 0; i < JetTokens.ANNOTATION_MODIFIERS_KEYWORDS_ARRAY.length; i++) { - JetModifierKeywordToken modifier = JetTokens.ANNOTATION_MODIFIERS_KEYWORDS_ARRAY[i]; - if (modifierList.hasModifier(modifier)) { - annotationFromModifiers.add(modifiersAnnotations.get(i)); - } - } - - if (annotationFromModifiers.isEmpty()) return annotations; - - return new CompositeAnnotations(annotations, new AnnotationsImpl(annotationFromModifiers)); + return resolveAnnotationEntries(scope, annotationEntryElements, trace, shouldResolveArguments); } private Annotations resolveAnnotationEntries( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt index b694f68498b..c7901b31ab4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationUtil.kt @@ -16,21 +16,14 @@ package org.jetbrains.kotlin.resolve.annotations -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.CallableDescriptor +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.DescriptorUtils -import org.jetbrains.kotlin.types.JetTypeImpl - -public fun DeclarationDescriptor.hasInlineAnnotation(): Boolean { - return getAnnotations().findAnnotation(FqName("kotlin.inline")) != null -} public fun DeclarationDescriptor.hasPlatformStaticAnnotation(): Boolean { return getAnnotations().findAnnotation(FqName("kotlin.platform.platformStatic")) != null || @@ -67,21 +60,4 @@ public fun AnnotationDescriptor.argumentValue(parameterName: String): Any? { return getAllValueArguments().entrySet() .singleOrNull { it.key.getName().asString() == parameterName } ?.value?.value -} - -public fun KotlinBuiltIns.buildMigrationAnnotationDescriptors(): List = - JetTokens.ANNOTATION_MODIFIERS_KEYWORDS_ARRAY.map { - modifierKeyword -> - - val name = Name.identifier(modifierKeyword.value) - val type = JetTypeImpl.create( - Annotations.EMPTY, - getBuiltInClassByNameNullable(name) ?: getAnnotationClassByName(name), - /* nullable = */false, /* arguments = */emptyList() - ) - - AnnotationDescriptorImpl( - type, - emptyMap(), SourceElement.NO_SOURCE - ) - } +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineUtil.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineUtil.java index a3869c6358b..ecf5d2e636d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineUtil.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/inline/InlineUtil.java @@ -22,7 +22,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; -import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor; import org.jetbrains.kotlin.psi.*; import org.jetbrains.kotlin.resolve.BindingContext; import org.jetbrains.kotlin.resolve.BindingTrace; @@ -31,14 +30,16 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt; import org.jetbrains.kotlin.resolve.calls.model.ArgumentMapping; import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; -import org.jetbrains.kotlin.resolve.constants.ConstantValue; -import org.jetbrains.kotlin.resolve.constants.EnumValue; - -import static kotlin.CollectionsKt.firstOrNull; public class InlineUtil { public static boolean isInlineLambdaParameter(@NotNull ParameterDescriptor valueParameterOrReceiver) { - return !KotlinBuiltIns.isNoinline(valueParameterOrReceiver) && + boolean isNoinlineParameter = false; + + if (valueParameterOrReceiver instanceof ValueParameterDescriptor) { + isNoinlineParameter = ((ValueParameterDescriptor) valueParameterOrReceiver).isNoinline(); + } + + return !isNoinlineParameter && KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(valueParameterOrReceiver.getOriginal().getType()); } @@ -48,20 +49,12 @@ public class InlineUtil { @NotNull public static InlineStrategy getInlineStrategy(@NotNull DeclarationDescriptor descriptor) { - AnnotationDescriptor annotation = descriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.inline); - if (annotation == null) { - return InlineStrategy.NOT_INLINE; - } - ConstantValue argument = firstOrNull(annotation.getAllValueArguments().values()); - if (argument == null) { + if (descriptor instanceof FunctionDescriptor && + ((FunctionDescriptor) descriptor).isInline()) { return InlineStrategy.AS_FUNCTION; } - assert argument instanceof EnumValue : "Inline annotation parameter should be enum entry but was: " + argument; - return InlineStrategy.valueOf(((EnumValue) argument).getValue().getName().asString()); - } - public static boolean hasOnlyLocalReturn(@NotNull ValueParameterDescriptor descriptor) { - return descriptor.getAnnotations().findAnnotation(KotlinBuiltIns.FQ_NAMES.crossinline) != null; + return InlineStrategy.NOT_INLINE; } public static boolean checkNonLocalReturnUsage( @@ -141,7 +134,7 @@ public class InlineUtil { public static boolean allowsNonLocalReturns(@NotNull CallableDescriptor lambda) { if (lambda instanceof ValueParameterDescriptor) { - if (hasOnlyLocalReturn((ValueParameterDescriptor) lambda)) { + if (((ValueParameterDescriptor) lambda).isCrossinline()) { //annotated return false; } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index f04e54fa381..7c4489459d7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -170,7 +170,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes }); if (modifierList != null) { - LazyAnnotations classAnnotations = new LazyAnnotations( + this.annotations = new LazyAnnotations( new LazyAnnotationsContext( c.getAnnotationResolver(), storageManager, @@ -184,9 +184,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes }, modifierList.getAnnotationEntries() ); - this.annotations = c.getAnnotationResolver().resolveAndAppendAnnotationsFromModifiers( - classAnnotations, modifierList - ); } else { this.annotations = Annotations.Companion.getEMPTY(); diff --git a/core/builtins/src/kotlin/Annotations.kt b/core/builtins/src/kotlin/Annotations.kt index 6eadfc1dc48..468b5bed1de 100644 --- a/core/builtins/src/kotlin/Annotations.kt +++ b/core/builtins/src/kotlin/Annotations.kt @@ -80,16 +80,6 @@ public annotation class Extension @Retention(SOURCE) public annotation class Suppress(vararg val names: String) -/** - * Enables the tail call optimization for the annotated function. If the annotated function - * calls itself recursively as the last operation it performs, it will be executed without - * growing the stack depth. Tail call optimization is currently only supported by the JVM - * backend. - */ -@Target(FUNCTION) -@Retention(SOURCE) -private annotation class tailrec - /** * Hides the annotated function, property or constructor from the overload resolution, * thus preventing its usages from newly compiled code, but keeps compiling it @@ -101,15 +91,6 @@ private annotation class tailrec @Deprecated("Use @Deprecated(\"...\", level = DeprecationLevel.HIDDEN) instead", replaceWith = ReplaceWith("@Deprecated(, level = DeprecationLevel.HIDDEN)")) public annotation class HiddenDeclaration -/** - * Marks annotated function as `external`, meaning that it's not implemented - * in Kotlin but rather in a different language (for example, in C/C++ using JNI or JavaScript). - */ -@Target(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER) -@Retention(SOURCE) -@MustBeDocumented -private annotation class external - /** * Suppresses errors about variance conflict */ diff --git a/core/builtins/src/kotlin/Inline.kt b/core/builtins/src/kotlin/Inline.kt deleted file mode 100644 index 2957e9ed7e4..00000000000 --- a/core/builtins/src/kotlin/Inline.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2010-2015 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 kotlin - -/** - * Annotates the parameter of a function annotated as [inline] and forbids inlining of - * function literals passed as arguments for this parameter. - */ -@Target(AnnotationTarget.VALUE_PARAMETER) -@Retention(AnnotationRetention.RUNTIME) -@MustBeDocumented -private annotation class noinline - -/** - * Enables inlining of the annotated function and the function literals that it takes as parameters into the - * calling functions. Inline functions can use reified type parameters, and lambdas passed to inline - * functions can contain non-local returns. - * See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/inline-functions.html) for more information. - * - * @see noinline - * @see crossinline - */ -@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) -@Retention(AnnotationRetention.RUNTIME) -@MustBeDocumented -private annotation class inline - -/** - * Forbids use of non-local control flow statements within lambdas passed as arguments for this parameter. - */ -@Target(AnnotationTarget.VALUE_PARAMETER) -@Retention(AnnotationRetention.RUNTIME) -@MustBeDocumented -private annotation class crossinline diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java index b24100d38bd..e8d752dd918 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/KotlinBuiltIns.java @@ -140,9 +140,6 @@ public abstract class KotlinBuiltIns { public final FqName deprecated = fqName("Deprecated"); public final FqName tailRecursive = fqName("tailrec"); - public final FqName inline = fqName("inline"); - public final FqName noinline = fqName("noinline"); - public final FqName crossinline = fqName("crossinline"); public final FqName extension = fqName("Extension"); public final FqName target = annotationName("Target"); public final FqName annotationTarget = annotationName("AnnotationTarget"); @@ -1025,15 +1022,6 @@ public abstract class KotlinBuiltIns { return containsAnnotation(declarationDescriptor, FQ_NAMES.deprecated); } - public static boolean isTailRecursive(@NotNull DeclarationDescriptor declarationDescriptor) { - return containsAnnotation(declarationDescriptor, FQ_NAMES.tailRecursive); - } - - /** Checks that the symbol represented by the descriptor is annotated with the {@code kotlin.noinline} annotation */ - public static boolean isNoinline(@NotNull DeclarationDescriptor descriptor) { - return containsAnnotation(descriptor, FQ_NAMES.noinline); - } - public static boolean isSuppressAnnotation(@NotNull AnnotationDescriptor annotationDescriptor) { return isConstructedFromGivenClass(annotationDescriptor.getType(), FQ_NAMES.suppress); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/annotationUtil.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/annotationUtil.kt index 8eb9e314ffe..1e92ef9c435 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/annotationUtil.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/annotations/annotationUtil.kt @@ -19,17 +19,12 @@ package org.jetbrains.kotlin.descriptors.annotations import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.SourceElement import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.constants.AnnotationValue import org.jetbrains.kotlin.resolve.constants.ArrayValue import org.jetbrains.kotlin.resolve.constants.StringValue import org.jetbrains.kotlin.types.Variance -// Please synchronize this set with JetTokens.ANNOTATION_MODIFIERS_KEYWORDS_ARRAY -public val ANNOTATION_MODIFIERS_FQ_NAMES: Set = - arrayOf("inline", "noinline", "tailrec", "external", "crossinline").map { FqName("kotlin.$it") }.toSet() - public fun KotlinBuiltIns.createDeprecatedAnnotation(message: String, replaceWith: String): AnnotationDescriptor { val deprecatedAnnotation = deprecatedAnnotation val parameters = deprecatedAnnotation.unsubstitutedPrimaryConstructor!!.valueParameters diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index af89e8f8d1e..46a67f86674 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.renderer import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.annotations.ANNOTATION_MODIFIERS_FQ_NAMES import org.jetbrains.kotlin.descriptors.annotations.Annotated import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget @@ -31,7 +30,6 @@ import org.jetbrains.kotlin.resolve.constants.AnnotationValue import org.jetbrains.kotlin.resolve.constants.ArrayValue import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.resolve.constants.KClassValue -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.ErrorUtils.UninferredParameterTypeConstructor @@ -347,7 +345,7 @@ internal class DescriptorRendererImpl( // See AnnotationResolver.resolveAndAppendAnnotationsFromModifiers for clarification // This hack can be removed when modifiers will be resolved without annotations - val sortedAnnotations = annotated.getAnnotations().getAllAnnotations().sortedBy { p -> p.annotation.isBuiltinModifier() } + val sortedAnnotations = annotated.getAnnotations().getAllAnnotations() for ((annotation, target) in sortedAnnotations) { val annotationClass = annotation.getType().getConstructor().getDeclarationDescriptor() as ClassDescriptor @@ -360,9 +358,6 @@ internal class DescriptorRendererImpl( builder.append(annotationsBuilder) } - private fun AnnotationDescriptor.isBuiltinModifier() - = (type.constructor.declarationDescriptor as ClassDescriptor).fqNameSafe in ANNOTATION_MODIFIERS_FQ_NAMES - override fun renderAnnotation(annotation: AnnotationDescriptor, target: AnnotationUseSiteTarget?): String { return StringBuilder { append('@') diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/InlineAnnotation.kt b/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/InlineAnnotation.kt deleted file mode 100644 index 72286f9eb16..00000000000 --- a/js/js.translator/src/org/jetbrains/kotlin/js/translate/utils/InlineAnnotation.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2010-2015 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.kotlin.js.translate.utils - -enum class InlineAnnotation(val fqName: String) { - INLINE("kotlin.inline"), - NO_INLINE("kotlin.noinline") -}