From 4f53a541156107bb167d6f0e387515dc0504ae00 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 25 Apr 2018 19:16:28 +0200 Subject: [PATCH] Drop Experimental.Impact, simplify related code and tests See https://github.com/Kotlin/KEEP/issues/95#issuecomment-383889404 Drop Experimental.changesMayBreak, Experimental.Impact, the concept of signature/body usage, same module exemption. Make the majority of tests single-module because there is now no difference in the checker between usages from the same module or from another module --- .../jetbrains/kotlin/diagnostics/Errors.java | 6 +- .../rendering/DefaultErrorMessages.java | 17 +-- ...entalMarkerDeclarationAnnotationChecker.kt | 15 +-- .../checkers/ExperimentalUsageChecker.kt | 120 ++++-------------- ...talAndUseExperimentalWithSameAnnotation.kt | 2 +- .../cli/jvm/experimentalDeprecated.args | 8 +- .../cli/jvm/experimentalDeprecated.kt | 24 ++-- .../cli/jvm/experimentalDeprecated.out | 8 +- .../jvm/experimentalDeprecatedWarning.args | 4 +- .../cli/jvm/experimentalDeprecatedWarning.kt | 12 +- .../cli/jvm/experimentalDeprecatedWarning.out | 4 +- .../testData/cli/jvm/experimentalNested.kt | 2 +- .../cli/jvm/experimentalRuntimeScope.args | 8 -- .../cli/jvm/experimentalRuntimeScope.kt | 7 - .../cli/jvm/experimentalRuntimeScope.out | 3 - .../experimental/annotation.kt | 22 ++-- .../experimental/annotation.txt | 24 +--- .../experimental/bodyUsageInSameModule.kt | 104 --------------- .../experimental/bodyUsages.kt | 14 +- .../experimental/bodyUsages.txt | 20 +-- .../experimental/bodyUsagesAndInline.kt | 83 ++++++++++++ ...SameModule.txt => bodyUsagesAndInline.txt} | 17 +-- .../experimental/classMembers.kt | 8 +- .../experimental/classMembers.txt | 24 +--- .../classMembersOverlyExperimental.kt | 4 +- .../classMembersOverlyExperimental.txt | 10 +- .../compilationVsLinkageVsRuntime.kt | 76 ----------- .../compilationVsLinkageVsRuntime.txt | 58 --------- .../testsWithStdLib/experimental/constVal.kt | 7 +- .../testsWithStdLib/experimental/constVal.txt | 24 +--- .../experimental/deeplyNestedClass.kt | 8 +- .../experimental/deeplyNestedClass.txt | 24 +--- .../testsWithStdLib/experimental/errors.kt | 4 +- .../testsWithStdLib/experimental/errors.txt | 10 +- .../experimental/experimentalWithNoImpact.kt | 4 - .../experimental/experimentalWithNoImpact.txt | 8 -- ...correctTargetsForExperimentalAnnotation.kt | 8 +- ...orrectTargetsForExperimentalAnnotation.txt | 8 +- .../experimental/incorrectUseExperimental.kt | 29 +---- .../experimental/incorrectUseExperimental.txt | 24 +--- .../indirectBodyUsageInAnotherModule.kt | 52 -------- .../indirectBodyUsageInAnotherModule.txt | 36 ------ .../testsWithStdLib/experimental/override.kt | 5 +- .../testsWithStdLib/experimental/override.txt | 17 +-- .../testsWithStdLib/experimental/scripts.kt | 8 +- .../testsWithStdLib/experimental/scripts.txt | 76 ++++------- .../testsWithStdLib/experimental/topLevel.kt | 6 +- .../testsWithStdLib/experimental/topLevel.txt | 24 +--- .../experimental/useExperimentalOnFile.kt | 16 +-- .../experimental/useExperimentalOnFile.txt | 20 +-- ...imentalOnFileWithVeryExperimentalMarker.kt | 30 +++++ ...mentalOnFileWithVeryExperimentalMarker.txt | 24 ++++ .../useExperimentalOnWholeModule.kt | 2 +- .../useExperimentalOnWholeModule.txt | 2 +- .../experimental/useExperimentalTargets.kt | 4 +- .../experimental/useExperimentalTargets.txt | 38 +++--- .../useExperimentalWithSeveralAnnotations.kt | 8 +- .../useExperimentalWithSeveralAnnotations.txt | 14 +- .../jsExperimentalModule/output.txt | 4 +- .../jvmExperimentalModule/output.txt | 4 +- .../moduleProtoBuf/experimental/main.kt | 2 +- .../DiagnosticsTestWithStdLibGenerated.java | 30 ++--- ...ticsTestWithStdLibUsingJavacGenerated.java | 30 ++--- .../kotlin/cli/CliTestGenerated.java | 5 - .../kotlin/annotations/Experimental.kt | 48 +------ .../kotlin-stdlib-runtime-merged.txt | 9 -- 66 files changed, 350 insertions(+), 1026 deletions(-) delete mode 100644 compiler/testData/cli/jvm/experimentalRuntimeScope.args delete mode 100644 compiler/testData/cli/jvm/experimentalRuntimeScope.kt delete mode 100644 compiler/testData/cli/jvm/experimentalRuntimeScope.out delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt rename compiler/testData/diagnostics/testsWithStdLib/experimental/{bodyUsageInSameModule.txt => bodyUsagesAndInline.txt} (52%) delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.kt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.txt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.kt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.txt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.kt delete mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 9e667b68598..9d12d432d4d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -234,16 +234,14 @@ public interface Errors { DiagnosticFactory1 ILLEGAL_KOTLIN_VERSION_STRING_VALUE = DiagnosticFactory1.create(ERROR); DiagnosticFactory1 NEWER_VERSION_IN_SINCE_KOTLIN = DiagnosticFactory1.create(WARNING); - DiagnosticFactory2 EXPERIMENTAL_API_USAGE = DiagnosticFactory2.create(WARNING); - DiagnosticFactory2 EXPERIMENTAL_API_USAGE_ERROR = DiagnosticFactory2.create(ERROR); + DiagnosticFactory1 EXPERIMENTAL_API_USAGE = DiagnosticFactory1.create(WARNING); + DiagnosticFactory1 EXPERIMENTAL_API_USAGE_ERROR = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 EXPERIMENTAL_OVERRIDE = DiagnosticFactory2.create(WARNING); DiagnosticFactory2 EXPERIMENTAL_OVERRIDE_ERROR = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 USE_EXPERIMENTAL_WITHOUT_ARGUMENTS = DiagnosticFactory0.create(WARNING); DiagnosticFactory1 USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER = DiagnosticFactory1.create(WARNING); - DiagnosticFactory1 USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT = DiagnosticFactory1.create(ERROR); - DiagnosticFactory0 EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT = DiagnosticFactory0.create(ERROR); DiagnosticFactory1 EXPERIMENTAL_ANNOTATION_WITH_WRONG_TARGET = DiagnosticFactory1.create(ERROR); // Const diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index f70d8917da6..0e1deb8106c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -15,7 +15,6 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic; import org.jetbrains.kotlin.diagnostics.DiagnosticFactory; import org.jetbrains.kotlin.diagnostics.Errors; import org.jetbrains.kotlin.metadata.deserialization.VersionRequirement; -import org.jetbrains.kotlin.name.FqName; import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData; import org.jetbrains.kotlin.types.KotlinTypeKt; import org.jetbrains.kotlin.util.OperatorNameConventions; @@ -23,7 +22,6 @@ import org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.ServiceLoader; @@ -142,25 +140,14 @@ public class DefaultErrorMessages { MAP.put(ILLEGAL_KOTLIN_VERSION_STRING_VALUE, "Invalid @{0} annotation value (should be ''major.minor'' or ''major.minor.patch'')", TO_STRING); MAP.put(NEWER_VERSION_IN_SINCE_KOTLIN, "The version is greater than the specified API version {0}", STRING); - RenderingContext.Key getExperimentalFqName = new RenderingContext.Key("getExperimentalFqName") { - @Override - public FqName compute(@NotNull Collection objectsToRender) { - return (FqName) CollectionsKt.first(objectsToRender); - } - }; - DiagnosticParameterRenderer renderUseExperimental = (useExperimentalAllowed, c) -> - useExperimentalAllowed ? " or ''@UseExperimental(" + c.get(getExperimentalFqName) + "::class)''" : ""; - MAP.put(EXPERIMENTAL_API_USAGE, "This declaration is experimental and its usage should be marked with ''@{0}''{1}", TO_STRING, renderUseExperimental); - MAP.put(EXPERIMENTAL_API_USAGE_ERROR, "This declaration is experimental and its usage must be marked with ''@{0}''{1}", TO_STRING, renderUseExperimental); + MAP.put(EXPERIMENTAL_API_USAGE, "This declaration is experimental and its usage should be marked with ''@{0}'' or ''@UseExperimental({0}::class)''", TO_STRING); + MAP.put(EXPERIMENTAL_API_USAGE_ERROR, "This declaration is experimental and its usage must be marked with ''@{0}'' or ''@UseExperimental({0}::class)''", TO_STRING); MAP.put(EXPERIMENTAL_OVERRIDE, "This declaration overrides experimental member of supertype ''{1}'' and should be annotated with ''@{0}''", TO_STRING, NAME); MAP.put(EXPERIMENTAL_OVERRIDE_ERROR, "This declaration overrides experimental member of supertype ''{1}'' and must be annotated with ''@{0}''", TO_STRING, NAME); MAP.put(USE_EXPERIMENTAL_WITHOUT_ARGUMENTS, "@UseExperimental without any arguments has no effect"); MAP.put(USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER, "Annotation ''{0}'' is not an experimental API marker, therefore its usage in @UseExperimental is ignored", TO_STRING); - MAP.put(USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT, - "Experimental annotation ''{0}'' has impact other than COMPILATION, therefore its usage in @UseExperimental is forbidden", TO_STRING); - MAP.put(EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT, "Experimental annotation with changesMayBreak = [] is not allowed"); MAP.put(EXPERIMENTAL_ANNOTATION_WITH_WRONG_TARGET, "Experimental annotation cannot be used on the following code elements: {0}. Please remove these targets", STRING); MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalMarkerDeclarationAnnotationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalMarkerDeclarationAnnotationChecker.kt index 5cfaec492b1..4132096d006 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalMarkerDeclarationAnnotationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalMarkerDeclarationAnnotationChecker.kt @@ -34,8 +34,6 @@ object ExperimentalMarkerDeclarationAnnotationChecker : AdditionalAnnotationChec checkUseExperimentalUsage(annotationClasses, trace, entry) } ExperimentalUsageChecker.EXPERIMENTAL_FQ_NAME -> { - val impact = (annotation.allValueArguments[ExperimentalUsageChecker.IMPACT] as? ArrayValue)?.value - checkExperimentalUsage(impact, trace, entry) isAnnotatedWithExperimental = true } } @@ -54,31 +52,22 @@ object ExperimentalMarkerDeclarationAnnotationChecker : AdditionalAnnotationChec for (annotationClass in annotationClasses) { val classDescriptor = - (annotationClass as? KClassValue)?.value?.constructor?.declarationDescriptor as? ClassDescriptor - ?: continue + (annotationClass as? KClassValue)?.value?.constructor?.declarationDescriptor as? ClassDescriptor ?: continue val experimentality = with(ExperimentalUsageChecker) { classDescriptor.loadExperimentalityForMarkerAnnotation() } if (experimentality == null) { trace.report(Errors.USE_EXPERIMENTAL_ARGUMENT_IS_NOT_MARKER.on(entry, classDescriptor.fqNameSafe)) - } else if (!experimentality.isCompilationOnly) { - trace.report(Errors.USE_EXPERIMENTAL_ARGUMENT_HAS_NON_COMPILATION_IMPACT.on(entry, experimentality.annotationFqName)) } } } - private fun checkExperimentalUsage(impact: List>?, trace: BindingTrace, entry: KtAnnotationEntry) { - if (impact != null && impact.isEmpty()) { - trace.report(Errors.EXPERIMENTAL_ANNOTATION_WITH_NO_IMPACT.on(entry)) - } - } - private fun checkMarkerTargets(entries: List, trace: BindingTrace) { val targetEntry = entries.associate { entry -> entry to trace.bindingContext.get(BindingContext.ANNOTATION, entry) } .entries .firstOrNull { (_, descriptor) -> descriptor != null && descriptor.fqName == KotlinBuiltIns.FQ_NAMES.target } - ?: return + ?: return val (entry, descriptor) = targetEntry val allowedTargets = AnnotationChecker.loadAnnotationTargets(descriptor!!) ?: return val wrongTargets = allowedTargets.intersect(WRONG_TARGETS_FOR_MARKER) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalUsageChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalUsageChecker.kt index f969b5de5f0..1ed8c36b182 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalUsageChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalUsageChecker.kt @@ -26,7 +26,9 @@ import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.KtAnnotated +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtNamedDeclaration import org.jetbrains.kotlin.resolve.* import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker import org.jetbrains.kotlin.resolve.calls.checkers.CallCheckerContext @@ -44,20 +46,11 @@ import org.jetbrains.kotlin.utils.addIfNotNull class ExperimentalUsageChecker(project: Project) : CallChecker { private val moduleAnnotationsResolver = ModuleAnnotationsResolver.getInstance(project) - internal data class Experimentality( - val markerDescriptor: ClassDescriptor, - val annotationFqName: FqName, - val severity: Severity, - val impact: List - ) { - val isCompilationOnly: Boolean get() = impact.all(Impact.COMPILATION::equals) - + internal data class Experimentality(val annotationFqName: FqName, val severity: Severity) { enum class Severity { WARNING, ERROR } - enum class Impact { COMPILATION, LINKAGE_OR_RUNTIME } companion object { val DEFAULT_SEVERITY = Severity.ERROR - val DEFAULT_IMPACT = listOf(Impact.COMPILATION, Impact.LINKAGE_OR_RUNTIME) } } @@ -74,11 +67,6 @@ class ExperimentalUsageChecker(project: Project) : CallChecker { private val WARNING_LEVEL = Name.identifier("WARNING") private val ERROR_LEVEL = Name.identifier("ERROR") - internal val IMPACT = Name.identifier("changesMayBreak") - private val COMPILATION_IMPACT = Name.identifier("COMPILATION") - private val LINKAGE_IMPACT = Name.identifier("LINKAGE") - private val RUNTIME_IMPACT = Name.identifier("RUNTIME") - private fun checkExperimental( descriptor: DeclarationDescriptor, element: PsiElement, @@ -88,14 +76,13 @@ class ExperimentalUsageChecker(project: Project) : CallChecker { val experimentalities = descriptor.loadExperimentalities(moduleAnnotationsResolver) if (experimentalities.isNotEmpty()) { checkExperimental( - experimentalities, element, context.trace.bindingContext, context.languageVersionSettings, - context.moduleDescriptor - ) { experimentality, isBodyUsageOfSourceOnlyExperimentality -> - val diagnostic = when (experimentality.severity) { + experimentalities, element, context.trace.bindingContext, context.languageVersionSettings + ) { (annotationFqName, severity) -> + val diagnostic = when (severity) { Experimentality.Severity.WARNING -> Errors.EXPERIMENTAL_API_USAGE Experimentality.Severity.ERROR -> Errors.EXPERIMENTAL_API_USAGE_ERROR } - context.trace.report(diagnostic.on(element, experimentality.annotationFqName, isBodyUsageOfSourceOnlyExperimentality)) + context.trace.report(diagnostic.on(element, annotationFqName)) } } } @@ -105,28 +92,19 @@ class ExperimentalUsageChecker(project: Project) : CallChecker { element: PsiElement, bindingContext: BindingContext, languageVersionSettings: LanguageVersionSettings, - module: ModuleDescriptor, - report: (experimentality: Experimentality, isBodyUsageOfCompilationExperimentality: Boolean) -> Unit + report: (Experimentality) -> Unit ) { - val isBodyUsageExceptPublicInline = element.isBodyUsage(bindingContext, allowPublicInline = false) - val isBodyUsage = isBodyUsageExceptPublicInline || element.isBodyUsage(bindingContext, allowPublicInline = true) - for (experimentality in experimentalities) { - val isBodyUsageOfCompilationExperimentality = - experimentality.isCompilationOnly && isBodyUsage - - val isBodyUsageInSameModule = - experimentality.markerDescriptor.module == module && isBodyUsageExceptPublicInline - val annotationFqName = experimentality.annotationFqName val isExperimentalityAccepted = - isBodyUsageInSameModule || - (isBodyUsageOfCompilationExperimentality && - element.hasContainerAnnotatedWithUseExperimental(annotationFqName, bindingContext, languageVersionSettings)) || - element.propagates(annotationFqName, bindingContext, languageVersionSettings) + element.hasContainerAnnotatedWithUseExperimental( + annotationFqName, bindingContext, languageVersionSettings + ) || element.propagates( + annotationFqName, bindingContext, languageVersionSettings + ) if (!isExperimentalityAccepted) { - report(experimentality, isBodyUsageOfCompilationExperimentality) + report(experimentality) } } } @@ -162,46 +140,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker { else -> Experimentality.DEFAULT_SEVERITY } - val impact = (experimental.allValueArguments[IMPACT] as? ArrayValue)?.value?.mapNotNull { impact -> - when ((impact as? EnumValue)?.enumEntryName) { - COMPILATION_IMPACT -> Experimentality.Impact.COMPILATION - LINKAGE_IMPACT, RUNTIME_IMPACT -> Experimentality.Impact.LINKAGE_OR_RUNTIME - else -> null - } - } ?: Experimentality.DEFAULT_IMPACT - - return Experimentality(this, fqNameSafe, severity, impact) - } - - // Returns true if this element appears in the body of some function and is not visible in any non-local declaration signature. - // If that's the case, one can opt-in to using the corresponding experimental API by annotating this element (or any of its - // enclosing declarations) with @UseExperimental(X::class), not requiring propagation of the experimental annotation to the call sites. - // (Note that this is allowed only if X's impact is [COMPILATION].) - private fun PsiElement.isBodyUsage(bindingContext: BindingContext, allowPublicInline: Boolean): Boolean { - return anyParentMatches { element, parent -> - element == (parent as? KtDeclarationWithBody)?.bodyExpression?.takeIf { - allowPublicInline || !parent.isPublicInline(bindingContext) - } || - element == (parent as? KtDeclarationWithInitializer)?.initializer || - element == (parent as? KtClassInitializer)?.body || - element == (parent as? KtParameter)?.defaultValue || - element == (parent as? KtSuperTypeCallEntry)?.valueArgumentList || - element == (parent as? KtDelegatedSuperTypeEntry)?.delegateExpression || - element == (parent as? KtPropertyDelegate)?.expression - } - } - - private fun PsiElement.isPublicInline(bindingContext: BindingContext): Boolean { - val descriptor = when (this) { - is KtFunction -> bindingContext.get(BindingContext.FUNCTION, this) - is KtPropertyAccessor -> bindingContext.get(BindingContext.PROPERTY_ACCESSOR, this) - else -> null - } - return descriptor != null && descriptor.isInline && descriptor.effectiveVisibility().let { - it == EffectiveVisibility.Public || - it == EffectiveVisibility.ProtectedBound || - it is EffectiveVisibility.Protected - } + return Experimentality(fqNameSafe, severity) } // Checks whether any of the non-local enclosing declarations is annotated with annotationFqName, effectively requiring @@ -263,18 +202,14 @@ class ExperimentalUsageChecker(project: Project) : CallChecker { // module annotations. For now, we only check deprecations because this is needed to correctly retire unneeded compiler arguments. val deprecationResolver = DeprecationResolver(LockBasedStorageManager(), languageVersionSettings) - fun checkAnnotation(fqName: String, allowNonCompilationImpact: Boolean): Boolean { + fun checkAnnotation(fqName: String): Boolean { val descriptor = module.resolveClassByFqName(FqName(fqName), NoLookupLocation.FOR_NON_TRACKED_SCOPE) val experimentality = descriptor?.loadExperimentalityForMarkerAnnotation() val message = when { descriptor == null -> - "Experimental API marker $fqName is unresolved. " + - "Please make sure it's present in the module dependencies" + "Experimental API marker $fqName is unresolved. Please make sure it's present in the module dependencies" experimentality == null -> "Class $fqName is not an experimental API marker annotation" - !allowNonCompilationImpact && !experimentality.impact.all(Experimentality.Impact.COMPILATION::equals) -> - "Experimental API marker $fqName has impact other than COMPILATION, " + - "therefore it can't be used with -Xuse-experimental" else -> { for (deprecation in deprecationResolver.getDeprecations(descriptor)) { val report = when (deprecation.deprecationLevel) { @@ -292,12 +227,8 @@ class ExperimentalUsageChecker(project: Project) : CallChecker { return false } - val validExperimental = - languageVersionSettings.getFlag(AnalysisFlag.experimental) - .filter { checkAnnotation(it, allowNonCompilationImpact = true) } - val validUseExperimental = - languageVersionSettings.getFlag(AnalysisFlag.useExperimental) - .filter { checkAnnotation(it, allowNonCompilationImpact = false) } + val validExperimental = languageVersionSettings.getFlag(AnalysisFlag.experimental).filter(::checkAnnotation) + val validUseExperimental = languageVersionSettings.getFlag(AnalysisFlag.useExperimental).filter(::checkAnnotation) for (fqName in validExperimental.intersect(validUseExperimental)) { reportError("'-Xuse-experimental=$fqName' has no effect because '-Xexperimental=$fqName' is used") @@ -323,21 +254,18 @@ class ExperimentalUsageChecker(project: Project) : CallChecker { member.loadExperimentalities(moduleAnnotationsResolver).map { experimentality -> experimentality to member } }.toMap() - val module = descriptor.module - for ((experimentality, member) in experimentalOverridden) { checkExperimental( - listOf(experimentality), declaration, context.trace.bindingContext, context.languageVersionSettings, module - ) { _, _ -> - val diagnostic = when (experimentality.severity) { + listOf(experimentality), declaration, context.trace.bindingContext, context.languageVersionSettings + ) { (annotationFqName, severity) -> + val diagnostic = when (severity) { Experimentality.Severity.WARNING -> Errors.EXPERIMENTAL_OVERRIDE Experimentality.Severity.ERROR -> Errors.EXPERIMENTAL_OVERRIDE_ERROR } val reportOn = (declaration as? KtNamedDeclaration)?.nameIdentifier ?: declaration - context.trace.report(diagnostic.on(reportOn, experimentality.annotationFqName, member.containingDeclaration)) + context.trace.report(diagnostic.on(reportOn, annotationFqName, member.containingDeclaration)) } } } } - } diff --git a/compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.kt b/compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.kt index bed1964610a..652dc8678a1 100644 --- a/compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.kt +++ b/compiler/testData/cli/jvm/experimentalAndUseExperimentalWithSameAnnotation.kt @@ -1,4 +1,4 @@ package org.test -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION]) +@Experimental annotation class ExperimentalAPI diff --git a/compiler/testData/cli/jvm/experimentalDeprecated.args b/compiler/testData/cli/jvm/experimentalDeprecated.args index 31514313583..b0dfe4977f8 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecated.args +++ b/compiler/testData/cli/jvm/experimentalDeprecated.args @@ -4,7 +4,7 @@ $TEMP_DIR$ -Xskip-runtime-version-check -language-version 1.3 --Xexperimental=org.test.BinaryError --Xexperimental=org.test.BinaryHidden --Xuse-experimental=org.test.SourceError --Xuse-experimental=org.test.SourceHidden +-Xexperimental=org.test.Error1 +-Xexperimental=org.test.Hidden1 +-Xuse-experimental=org.test.Error2 +-Xuse-experimental=org.test.Hidden2 diff --git a/compiler/testData/cli/jvm/experimentalDeprecated.kt b/compiler/testData/cli/jvm/experimentalDeprecated.kt index a150c9e38c9..e29c9c463a2 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecated.kt +++ b/compiler/testData/cli/jvm/experimentalDeprecated.kt @@ -1,17 +1,17 @@ package org.test -@Deprecated("BinaryError", level = DeprecationLevel.ERROR) -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME]) -annotation class BinaryError +@Deprecated("Error1", level = DeprecationLevel.ERROR) +@Experimental +annotation class Error1 -@Deprecated("BinaryHidden", level = DeprecationLevel.HIDDEN) -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME]) -annotation class BinaryHidden +@Deprecated("Error2", level = DeprecationLevel.ERROR) +@Experimental +annotation class Error2 -@Deprecated("SourceError", level = DeprecationLevel.ERROR) -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION]) -annotation class SourceError +@Deprecated("Hidden1", level = DeprecationLevel.HIDDEN) +@Experimental +annotation class Hidden1 -@Deprecated("SourceHidden", level = DeprecationLevel.HIDDEN) -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION]) -annotation class SourceHidden +@Deprecated("Hidden2", level = DeprecationLevel.HIDDEN) +@Experimental +annotation class Hidden2 diff --git a/compiler/testData/cli/jvm/experimentalDeprecated.out b/compiler/testData/cli/jvm/experimentalDeprecated.out index a129a589ed3..9efde113798 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecated.out +++ b/compiler/testData/cli/jvm/experimentalDeprecated.out @@ -1,6 +1,6 @@ warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features -error: experimental API marker org.test.BinaryError is deprecated. BinaryError -error: experimental API marker org.test.BinaryHidden is deprecated. BinaryHidden -error: experimental API marker org.test.SourceError is deprecated. SourceError -error: experimental API marker org.test.SourceHidden is deprecated. SourceHidden +error: experimental API marker org.test.Error1 is deprecated. Error1 +error: experimental API marker org.test.Hidden1 is deprecated. Hidden1 +error: experimental API marker org.test.Error2 is deprecated. Error2 +error: experimental API marker org.test.Hidden2 is deprecated. Hidden2 COMPILATION_ERROR diff --git a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.args b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.args index 165d96e5b33..83d37b2440a 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.args +++ b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.args @@ -4,5 +4,5 @@ $TEMP_DIR$ -Xskip-runtime-version-check -language-version 1.3 --Xuse-experimental=org.test.SourceWarning --Xexperimental=org.test.BinaryWarning +-Xuse-experimental=org.test.Warning1 +-Xexperimental=org.test.Warning2 diff --git a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt index 74c08cab1c5..88bf0c946f1 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt +++ b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.kt @@ -1,9 +1,9 @@ package org.test -@Deprecated("BinaryWarning", level = DeprecationLevel.WARNING) -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME]) -annotation class BinaryWarning +@Deprecated("Warning1", level = DeprecationLevel.WARNING) +@Experimental +annotation class Warning1 -@Deprecated("SourceWarning", level = DeprecationLevel.WARNING) -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION]) -annotation class SourceWarning +@Deprecated("Warning2", level = DeprecationLevel.WARNING) +@Experimental +annotation class Warning2 diff --git a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out index 8fb650a9ae3..ec7d5b5b3db 100644 --- a/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out +++ b/compiler/testData/cli/jvm/experimentalDeprecatedWarning.out @@ -1,4 +1,4 @@ warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features -warning: experimental API marker org.test.BinaryWarning is deprecated. BinaryWarning -warning: experimental API marker org.test.SourceWarning is deprecated. SourceWarning +warning: experimental API marker org.test.Warning2 is deprecated. Warning2 +warning: experimental API marker org.test.Warning1 is deprecated. Warning1 OK diff --git a/compiler/testData/cli/jvm/experimentalNested.kt b/compiler/testData/cli/jvm/experimentalNested.kt index 025420f7ca8..d577cb31f28 100644 --- a/compiler/testData/cli/jvm/experimentalNested.kt +++ b/compiler/testData/cli/jvm/experimentalNested.kt @@ -1,7 +1,7 @@ package org.test class Outer { - @Experimental(Experimental.Level.ERROR, [Experimental.Impact.LINKAGE]) + @Experimental annotation class Nested } diff --git a/compiler/testData/cli/jvm/experimentalRuntimeScope.args b/compiler/testData/cli/jvm/experimentalRuntimeScope.args deleted file mode 100644 index 59115f70bb5..00000000000 --- a/compiler/testData/cli/jvm/experimentalRuntimeScope.args +++ /dev/null @@ -1,8 +0,0 @@ -$TESTDATA_DIR$/experimentalRuntimeScope.kt --d -$TEMP_DIR$ --Xskip-runtime-version-check --language-version -1.3 --Xexperimental=org.test.Experimental1 --Xuse-experimental=org.test.Experimental2 diff --git a/compiler/testData/cli/jvm/experimentalRuntimeScope.kt b/compiler/testData/cli/jvm/experimentalRuntimeScope.kt deleted file mode 100644 index fa330fdc079..00000000000 --- a/compiler/testData/cli/jvm/experimentalRuntimeScope.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.test - -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.LINKAGE]) -annotation class Experimental1 - -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.RUNTIME]) -annotation class Experimental2 diff --git a/compiler/testData/cli/jvm/experimentalRuntimeScope.out b/compiler/testData/cli/jvm/experimentalRuntimeScope.out deleted file mode 100644 index 7929d5e6ce6..00000000000 --- a/compiler/testData/cli/jvm/experimentalRuntimeScope.out +++ /dev/null @@ -1,3 +0,0 @@ -warning: language version 1.3 is experimental, there are no backwards compatibility guarantees for new language and library features -error: experimental API marker org.test.Experimental2 has impact other than COMPILATION, therefore it can't be used with -Xuse-experimental -COMPILATION_ERROR diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.kt index 28378dcb339..39a6cfbbd28 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.kt @@ -1,11 +1,10 @@ // !API_VERSION: 1.3 // !DIAGNOSTICS: -UNUSED_PARAMETER -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS, AnnotationTarget.VALUE_PARAMETER) annotation class ExperimentalAPI @@ -15,7 +14,6 @@ annotation class ExperimentalAPI AnnotationTarget.VALUE_PARAMETER) annotation class EAnno -// MODULE: usage1(api) // FILE: usage-propagate.kt package usage1 @@ -61,7 +59,6 @@ val inProperty = @EAnno fun() {} val inPropertyAccessor: () -> Unit get() = @EAnno fun() {} -// MODULE: usage2(api) // FILE: usage-use.kt package usage2 @@ -69,28 +66,28 @@ package usage2 import api.* @UseExperimental(ExperimentalAPI::class) -@EAnno fun function() {} +@EAnno fun function() {} @UseExperimental(ExperimentalAPI::class) -fun parameter(@EAnno p: String) {} +fun parameter(@EAnno p: String) {} @UseExperimental(ExperimentalAPI::class) -fun parameterType(p: @EAnno String) {} +fun parameterType(p: @EAnno String) {} @UseExperimental(ExperimentalAPI::class) -fun returnType(): @EAnno Unit {} +fun returnType(): @EAnno Unit {} @UseExperimental(ExperimentalAPI::class) -@EAnno val property = "" +@EAnno val property = "" @UseExperimental(ExperimentalAPI::class) -@EAnno typealias Typealias = Unit +@EAnno typealias Typealias = Unit @UseExperimental(ExperimentalAPI::class) -@EAnno class Klass +@EAnno class Klass @UseExperimental(ExperimentalAPI::class) -annotation class AnnotationArgument(val p: EAnno) +annotation class AnnotationArgument(val p: EAnno) fun insideBody() { @UseExperimental(ExperimentalAPI::class) @EAnno fun local() {} @@ -105,7 +102,6 @@ val inPropertyAccessor: () -> Unit @UseExperimental(ExperimentalAPI::class) get() = @EAnno fun() {} -// MODULE: usage3(api) // FILE: usage-none.kt package usage3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.txt index 364e34116fa..9622fde9182 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.txt @@ -1,4 +1,3 @@ -// -- Module: -- package package api { @@ -10,7 +9,7 @@ package api { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS, AnnotationTarget.VALUE_PARAMETER}) public final annotation class ExperimentalAPI : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS, AnnotationTarget.VALUE_PARAMETER}) public final annotation class ExperimentalAPI : kotlin.Annotation { public constructor ExperimentalAPI() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -18,13 +17,6 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage1 { @api.ExperimentalAPI public val inProperty: () -> kotlin.Unit @api.ExperimentalAPI public val inPropertyAccessor: () -> kotlin.Unit @@ -53,13 +45,6 @@ package usage1 { @api.ExperimentalAPI @api.EAnno public typealias Typealias = kotlin.Unit } - -// -- Module: -- -package - -package api { -} - package usage2 { @kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public val inProperty: () -> kotlin.Unit public val inPropertyAccessor: () -> kotlin.Unit @@ -88,13 +73,6 @@ package usage2 { @kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) @api.EAnno public typealias Typealias = kotlin.Unit } - -// -- Module: -- -package - -package api { -} - package usage3 { public val inProperty: () -> kotlin.Unit public val inPropertyAccessor: () -> kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.kt deleted file mode 100644 index a4c7cf54297..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.kt +++ /dev/null @@ -1,104 +0,0 @@ -// !DIAGNOSTICS: -NOTHING_TO_INLINE -// !API_VERSION: 1.3 -// FILE: api.kt - -package api - -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) -annotation class ExperimentalCompilationAPI - -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.LINKAGE]) -annotation class ExperimentalLinkageAPI - -@ExperimentalCompilationAPI -fun compilation() {} - -@ExperimentalLinkageAPI -fun linkage() {} - -// FILE: usage.kt - -package usage - -import api.* - -fun use1() { - compilation() - linkage() -} - -val use2 = compilation() -val use3 = linkage() - -// FILE: inline-usage.kt - -package usage - -import api.* - -inline fun inlineUse1() { - compilation() - linkage() -} - -inline var inlineUse2: Unit - get() { - compilation() - linkage() - } - set(value) { - compilation() - linkage() - } - -var inlineUse3: Unit - inline get() { - compilation() - linkage() - } - @ExperimentalCompilationAPI - @ExperimentalLinkageAPI - inline set(value) { - compilation() - linkage() - } - -@ExperimentalCompilationAPI -@ExperimentalLinkageAPI -inline fun inlineUse4() { - compilation() - linkage() -} - -// FILE: private-inline-usage.kt - -package usage - -import api.* - -private inline fun privateInline1() { - compilation() - linkage() -} - -internal inline fun privateInline2() { - compilation() - linkage() -} - -private inline var privateInline3: Unit - get() { - compilation() - linkage() - } - set(value) { - compilation() - linkage() - } - -internal class InternalClass { - inline fun privateInline4() { - compilation() - linkage() - } -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.kt index fbb3f6588b6..8b94e01a6d7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.kt @@ -1,18 +1,16 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) -annotation class ExperimentalCompilationAPI +@Experimental(Experimental.Level.WARNING) +annotation class ExperimentalAPI interface I -@ExperimentalCompilationAPI +@ExperimentalAPI class Impl : I -// MODULE: usage(api) // FILE: usage.kt package usage @@ -21,12 +19,12 @@ import api.* open class Base(val i: I) -@UseExperimental(ExperimentalCompilationAPI::class) +@UseExperimental(ExperimentalAPI::class) class Derived : Base(Impl()) -@UseExperimental(ExperimentalCompilationAPI::class) +@UseExperimental(ExperimentalAPI::class) class Delegated : I by Impl() -@UseExperimental(ExperimentalCompilationAPI::class) +@UseExperimental(ExperimentalAPI::class) val delegatedProperty by Impl() operator fun I.getValue(x: Any?, y: Any?) = null diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.txt index 1a13d3232f9..4f34d72a93a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.txt @@ -1,10 +1,9 @@ -// -- Module: -- package package api { - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) public final annotation class ExperimentalCompilationAPI : kotlin.Annotation { - public constructor ExperimentalCompilationAPI() + @kotlin.Experimental(level = Level.WARNING) public final annotation class ExperimentalAPI : kotlin.Annotation { + public constructor ExperimentalAPI() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -16,7 +15,7 @@ package api { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @api.ExperimentalCompilationAPI public final class Impl : api.I { + @api.ExperimentalAPI public final class Impl : api.I { public constructor Impl() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -24,15 +23,8 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage { - @kotlin.UseExperimental(markerClass = {api.ExperimentalCompilationAPI::class}) public val delegatedProperty: kotlin.Nothing? + @kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public val delegatedProperty: kotlin.Nothing? public operator fun api.I.getValue(/*0*/ x: kotlin.Any?, /*1*/ y: kotlin.Any?): kotlin.Nothing? public open class Base { @@ -43,14 +35,14 @@ package usage { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.UseExperimental(markerClass = {api.ExperimentalCompilationAPI::class}) public final class Delegated : api.I { + @kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public final class Delegated : api.I { public constructor Delegated() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.UseExperimental(markerClass = {api.ExperimentalCompilationAPI::class}) public final class Derived : usage.Base { + @kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public final class Derived : usage.Base { public constructor Derived() public final override /*1*/ /*fake_override*/ val i: api.I public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt new file mode 100644 index 00000000000..66656a94da0 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt @@ -0,0 +1,83 @@ +// !DIAGNOSTICS: -NOTHING_TO_INLINE +// !USE_EXPERIMENTAL: kotlin.Experimental +// FILE: api.kt + +package api + +@Experimental(Experimental.Level.WARNING) +annotation class API + +@API +fun f() {} + +// FILE: usage.kt + +package usage + +import api.* + +fun use1() { + f() +} + +val use2 = f() + +// FILE: inline-usage.kt + +package usage + +import api.* + +inline fun inlineUse1() { + f() +} + +inline var inlineUse2: Unit + get() { + f() + } + set(value) { + f() + } + +var inlineUse3: Unit + inline get() { + f() + } + @API + inline set(value) { + f() + } + +@API +inline fun inlineUse4() { + f() +} + +// FILE: private-inline-usage.kt + +package usage + +import api.* + +private inline fun privateInline1() { + f() +} + +internal inline fun privateInline2() { + f() +} + +private inline var privateInline3: Unit + get() { + f() + } + set(value) { + f() + } + +internal class InternalClass { + inline fun privateInline4() { + f() + } +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.txt similarity index 52% rename from compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.txt rename to compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.txt index 730ed72b620..a2ea8b6b93f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.txt @@ -1,18 +1,10 @@ package package api { - @api.ExperimentalCompilationAPI public fun compilation(): kotlin.Unit - @api.ExperimentalLinkageAPI public fun linkage(): kotlin.Unit + @api.API public fun f(): kotlin.Unit - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) public final annotation class ExperimentalCompilationAPI : kotlin.Annotation { - public constructor ExperimentalCompilationAPI() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - @kotlin.Experimental(changesMayBreak = {Impact.LINKAGE}, level = Level.WARNING) public final annotation class ExperimentalLinkageAPI : kotlin.Annotation { - public constructor ExperimentalLinkageAPI() + @kotlin.Experimental(level = Level.WARNING) public final annotation class API : kotlin.Annotation { + public constructor API() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String @@ -24,9 +16,8 @@ package usage { public var inlineUse3: kotlin.Unit private var privateInline3: kotlin.Unit public val use2: kotlin.Unit - public val use3: kotlin.Unit public inline fun inlineUse1(): kotlin.Unit - @api.ExperimentalCompilationAPI @api.ExperimentalLinkageAPI public inline fun inlineUse4(): kotlin.Unit + @api.API public inline fun inlineUse4(): kotlin.Unit private inline fun privateInline1(): kotlin.Unit internal inline fun privateInline2(): kotlin.Unit public fun use1(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt index d7063cceb33..499a95711a8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt @@ -1,10 +1,9 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) annotation class ExperimentalAPI @@ -19,7 +18,6 @@ class C { @ExperimentalAPI fun C.extension() {} -// MODULE: usage1(api) // FILE: usage-propagate.kt package usage1 @@ -47,7 +45,6 @@ class Use { } } -// MODULE: usage2(api) // FILE: usage-use.kt package usage2 @@ -66,7 +63,7 @@ fun useAll() { @UseExperimental(ExperimentalAPI::class) class Use { - fun useAll(c: C) { + fun useAll(c: C) { c.function() c.property C.Nested() @@ -75,7 +72,6 @@ class Use { } } -// MODULE: usage3(api) // FILE: usage-none.kt package usage3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.txt index 0941b579621..fa5680dddc9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.txt @@ -1,4 +1,3 @@ -// -- Module: -- package package api { @@ -27,7 +26,7 @@ package api { } } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI : kotlin.Annotation { public constructor ExperimentalAPI() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -35,13 +34,6 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage1 { @api.ExperimentalAPI public fun useAll(): kotlin.Unit @@ -54,13 +46,6 @@ package usage1 { } } - -// -- Module: -- -package - -package api { -} - package usage2 { @kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public fun useAll(): kotlin.Unit @@ -73,13 +58,6 @@ package usage2 { } } - -// -- Module: -- -package - -package api { -} - package usage3 { public fun use(): kotlin.Unit } diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.kt index 048df38d35d..5a0df9542d8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.kt @@ -1,10 +1,9 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY) annotation class ExperimentalAPI @@ -23,7 +22,6 @@ class C { } } -// MODULE: usage(api) // FILE: usage.kt package usage diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.txt index e7d9690bbc4..b49e39c8179 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.txt @@ -1,4 +1,3 @@ -// -- Module: -- package package api { @@ -20,7 +19,7 @@ package api { } } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public final annotation class ExperimentalAPI : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY}) public final annotation class ExperimentalAPI : kotlin.Annotation { public constructor ExperimentalAPI() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -28,13 +27,6 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage { public fun use(): kotlin.Unit } diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.kt deleted file mode 100644 index e0bbeedc1a6..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.kt +++ /dev/null @@ -1,76 +0,0 @@ -// !API_VERSION: 1.3 -// MODULE: api -// FILE: api.kt - -package api - -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) -annotation class ExperimentalCompilationAPI - -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.LINKAGE]) -annotation class ExperimentalLinkageAPI - -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.RUNTIME]) -annotation class ExperimentalRuntimeAPI - -@ExperimentalCompilationAPI -fun compilation() {} - -@ExperimentalLinkageAPI -fun linkage() {} - -@ExperimentalRuntimeAPI -fun runtime() {} - -// MODULE: usage1(api) -// FILE: usage.kt - -package usage1 - -import api.* - -@UseExperimental(ExperimentalCompilationAPI::class) -@ExperimentalLinkageAPI -@ExperimentalRuntimeAPI -fun use() { - compilation() - linkage() - runtime() -} - -@ExperimentalLinkageAPI -@ExperimentalRuntimeAPI -fun useUse() { - use() -} - -@ExperimentalCompilationAPI -@ExperimentalLinkageAPI -@ExperimentalRuntimeAPI -fun recursiveUse() { - compilation() - linkage() - runtime() - recursiveUse() -} - -// MODULE: usage2(api,usage1) -// FILE: usage-no-annotation.txt - -package usage2 - -import api.* - -fun use1() { - usage1.use() -} - -@ExperimentalLinkageAPI -fun use2() { - usage1.use() -} - -@ExperimentalRuntimeAPI -fun use3() { - usage1.use() -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.txt deleted file mode 100644 index 26784527c7f..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.txt +++ /dev/null @@ -1,58 +0,0 @@ -// -- Module: -- -package - -package api { - @api.ExperimentalCompilationAPI public fun compilation(): kotlin.Unit - @api.ExperimentalLinkageAPI public fun linkage(): kotlin.Unit - @api.ExperimentalRuntimeAPI public fun runtime(): kotlin.Unit - - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) public final annotation class ExperimentalCompilationAPI : kotlin.Annotation { - public constructor ExperimentalCompilationAPI() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - @kotlin.Experimental(changesMayBreak = {Impact.LINKAGE}, level = Level.WARNING) public final annotation class ExperimentalLinkageAPI : kotlin.Annotation { - public constructor ExperimentalLinkageAPI() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - @kotlin.Experimental(changesMayBreak = {Impact.RUNTIME}, level = Level.WARNING) public final annotation class ExperimentalRuntimeAPI : kotlin.Annotation { - public constructor ExperimentalRuntimeAPI() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} - - -// -- Module: -- -package - -package api { -} - -package usage1 { - @api.ExperimentalCompilationAPI @api.ExperimentalLinkageAPI @api.ExperimentalRuntimeAPI public fun recursiveUse(): kotlin.Unit - @kotlin.UseExperimental(markerClass = {api.ExperimentalCompilationAPI::class}) @api.ExperimentalLinkageAPI @api.ExperimentalRuntimeAPI public fun use(): kotlin.Unit - @api.ExperimentalLinkageAPI @api.ExperimentalRuntimeAPI public fun useUse(): kotlin.Unit -} - - -// -- Module: -- -package - -package api { -} - -package usage1 { -} - -package usage2 { - public fun use1(): kotlin.Unit - @api.ExperimentalLinkageAPI public fun use2(): kotlin.Unit - @api.ExperimentalRuntimeAPI public fun use3(): kotlin.Unit -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt index c0ecb79b872..2e0db195270 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt @@ -1,10 +1,9 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION) annotation class ExperimentalAPI @@ -13,7 +12,6 @@ const val MEANING = 42 annotation class Anno(val value: Int) -// MODULE: usage1(api) // FILE: usage-propagate.kt package usage1 @@ -24,7 +22,6 @@ import api.* @Anno(MEANING) fun usage() {} -// MODULE: usage2(api) // FILE: usage-use.kt @file:UseExperimental(ExperimentalAPI::class) @@ -32,10 +29,10 @@ package usage2 import api.* +// TODO: there should be no warning here @Anno(MEANING) fun usage() {} -// MODULE: usage3(api) // FILE: usage-none.kt package usage3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.txt index 1941f52f733..c04082be358 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.txt @@ -1,4 +1,3 @@ -// -- Module: -- package package api { @@ -12,7 +11,7 @@ package api { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI : kotlin.Annotation { public constructor ExperimentalAPI() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -20,35 +19,14 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage1 { @api.ExperimentalAPI @api.Anno(value = 42) public fun usage(): kotlin.Unit } - -// -- Module: -- -package - -package api { -} - package usage2 { @api.Anno(value = 42) public fun usage(): kotlin.Unit } - -// -- Module: -- -package - -package api { -} - package usage3 { @api.Anno(value = 42) public fun usage(): kotlin.Unit } diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt index 62cac35f0e1..942b9cb6f1a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt @@ -1,10 +1,9 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) annotation class ExperimentalAPI @@ -17,7 +16,6 @@ class C { } } -// MODULE: usage1(api) // FILE: usage-propagate.kt package usage1 @@ -32,7 +30,6 @@ fun use1() { @ExperimentalAPI fun use2(f: C.D.E.F) = f.hashCode() -// MODULE: usage2(api) // FILE: usage-use.kt package usage2 @@ -45,9 +42,8 @@ fun use1() { } @UseExperimental(ExperimentalAPI::class) -fun use2(f: C.D.E.F) = f.hashCode() +fun use2(f: C.D.E.F) = f.hashCode() -// MODULE: usage3(api) // FILE: usage-none.kt package usage3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.txt index 306bb5b8103..3d4eeda281f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.txt @@ -1,4 +1,3 @@ -// -- Module: -- package package api { @@ -31,7 +30,7 @@ package api { } } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI : kotlin.Annotation { public constructor ExperimentalAPI() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -39,37 +38,16 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage1 { @api.ExperimentalAPI public fun use1(): kotlin.Unit @api.ExperimentalAPI public fun use2(/*0*/ f: api.C.D.E.F): kotlin.Int } - -// -- Module: -- -package - -package api { -} - package usage2 { @kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public fun use1(): kotlin.Unit @kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public fun use2(/*0*/ f: api.C.D.E.F): kotlin.Int } - -// -- Module: -- -package - -package api { -} - package usage3 { public fun use1(): kotlin.Unit public fun use2(/*0*/ f: api.C.D.E.F): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/errors.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/errors.kt index 34a133d1514..657f28ca34e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/errors.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/errors.kt @@ -1,10 +1,9 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION]) +@Experimental annotation class E open class Base { @@ -12,7 +11,6 @@ open class Base { open fun foo() {} } -// MODULE: usage(api) // FILE: usage.kt package usage diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/errors.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/errors.txt index 3d15c7be340..434d6cef32a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/errors.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/errors.txt @@ -1,4 +1,3 @@ -// -- Module: -- package package api { @@ -11,7 +10,7 @@ package api { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.ERROR) public final annotation class E : kotlin.Annotation { + @kotlin.Experimental public final annotation class E : kotlin.Annotation { public constructor E() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -19,13 +18,6 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage { public fun test(/*0*/ b: api.Base): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.kt deleted file mode 100644 index f87efbbd9b4..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.kt +++ /dev/null @@ -1,4 +0,0 @@ -// !API_VERSION: 1.3 - -@Experimental(Experimental.Level.WARNING, []) -annotation class ExperimentalAPI diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.txt deleted file mode 100644 index f5c268070ed..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.txt +++ /dev/null @@ -1,8 +0,0 @@ -package - -@kotlin.Experimental(changesMayBreak = {}, level = Level.WARNING) public final annotation class ExperimentalAPI : kotlin.Annotation { - public constructor ExperimentalAPI() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt index c766f404c31..9751e751d79 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt @@ -5,19 +5,19 @@ package api import kotlin.annotation.AnnotationTarget.* -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.RUNTIME]) +@Experimental(Experimental.Level.WARNING) @Target(CLASS, ANNOTATION_CLASS, TYPE_PARAMETER, PROPERTY, FIELD, LOCAL_VARIABLE, VALUE_PARAMETER, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, TYPE, TYPEALIAS) annotation class E1 -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.RUNTIME]) +@Experimental(Experimental.Level.WARNING) @Target(FILE) annotation class E2 -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.RUNTIME]) +@Experimental(Experimental.Level.WARNING) @Target(EXPRESSION) annotation class E3 -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.RUNTIME]) +@Experimental(Experimental.Level.WARNING) @Target(FILE, EXPRESSION) annotation class E4 diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.txt index cd8c439ea0b..598dc4b7c06 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.txt @@ -2,28 +2,28 @@ package package api { - @kotlin.Experimental(changesMayBreak = {Impact.RUNTIME}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPE, AnnotationTarget.TYPEALIAS}) public final annotation class E1 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPE, AnnotationTarget.TYPEALIAS}) public final annotation class E1 : kotlin.Annotation { public constructor E1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.RUNTIME}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FILE}) public final annotation class E2 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FILE}) public final annotation class E2 : kotlin.Annotation { public constructor E2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.RUNTIME}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class E3 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class E3 : kotlin.Annotation { public constructor E3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.RUNTIME}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FILE, AnnotationTarget.EXPRESSION}) public final annotation class E4 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FILE, AnnotationTarget.EXPRESSION}) public final annotation class E4 : kotlin.Annotation { public constructor E4() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.kt index 1dae7242b15..fb23eeeca8d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.kt @@ -1,32 +1,7 @@ // !API_VERSION: 1.3 -// MODULE: api -// FILE: api.kt - -package api - -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.RUNTIME]) -@Target(AnnotationTarget.PROPERTY) -annotation class BinaryExperimental - -@BinaryExperimental -val x = "" - -// MODULE: usage(api) -// FILE: usage.kt - -import api.* @UseExperimental -fun use1(): String { - return x -} - -@UseExperimental(BinaryExperimental::class) -fun use2(): String { - return x -} +fun f1() {} @UseExperimental(UseExperimental::class) -fun use3(): String { - return x -} +fun f2() {} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.txt index e2c9bed2db9..b18c745498d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.txt @@ -1,24 +1,4 @@ -// -- Module: -- package -package api { - @api.BinaryExperimental public val x: kotlin.String = "" - - @kotlin.Experimental(changesMayBreak = {Impact.RUNTIME}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.PROPERTY}) public final annotation class BinaryExperimental : kotlin.Annotation { - public constructor BinaryExperimental() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} - - -// -- Module: -- -package - -@kotlin.UseExperimental(markerClass = {}) public fun use1(): kotlin.String -@kotlin.UseExperimental(markerClass = {api.BinaryExperimental::class}) public fun use2(): kotlin.String -@kotlin.UseExperimental(markerClass = {kotlin.UseExperimental::class}) public fun use3(): kotlin.String - -package api { -} +@kotlin.UseExperimental(markerClass = {}) public fun f1(): kotlin.Unit +@kotlin.UseExperimental(markerClass = {kotlin.UseExperimental::class}) public fun f2(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.kt deleted file mode 100644 index e37b1bf1af0..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.kt +++ /dev/null @@ -1,52 +0,0 @@ -// !DIAGNOSTICS: -NOTHING_TO_INLINE -// !API_VERSION: 1.3 -// MODULE: api -// FILE: api.kt - -package api - -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) -annotation class ExperimentalCompilationAPI - -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.LINKAGE]) -annotation class ExperimentalLinkageAPI - -@ExperimentalCompilationAPI -fun compilation() {} - -@ExperimentalLinkageAPI -fun linkage() {} - -// MODULE: usage(api) -// FILE: usage.kt - -package usage - -import api.* - -@ExperimentalCompilationAPI -@ExperimentalLinkageAPI -fun use() { - compilation() - linkage() -} - -fun indirectUseNoAnnotation() { - use() -} - -@ExperimentalCompilationAPI -fun indirectUseOptInCompilation() { - use() -} - -@ExperimentalLinkageAPI -fun indirectUseOptInLinkage() { - use() -} - -@ExperimentalCompilationAPI -@ExperimentalLinkageAPI -fun indirectUseOptInBoth() { - use() -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.txt deleted file mode 100644 index 71fadb57711..00000000000 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.txt +++ /dev/null @@ -1,36 +0,0 @@ -// -- Module: -- -package - -package api { - @api.ExperimentalCompilationAPI public fun compilation(): kotlin.Unit - @api.ExperimentalLinkageAPI public fun linkage(): kotlin.Unit - - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) public final annotation class ExperimentalCompilationAPI : kotlin.Annotation { - public constructor ExperimentalCompilationAPI() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - @kotlin.Experimental(changesMayBreak = {Impact.LINKAGE}, level = Level.WARNING) public final annotation class ExperimentalLinkageAPI : kotlin.Annotation { - public constructor ExperimentalLinkageAPI() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} - - -// -- Module: -- -package - -package api { -} - -package usage { - public fun indirectUseNoAnnotation(): kotlin.Unit - @api.ExperimentalCompilationAPI @api.ExperimentalLinkageAPI public fun indirectUseOptInBoth(): kotlin.Unit - @api.ExperimentalCompilationAPI public fun indirectUseOptInCompilation(): kotlin.Unit - @api.ExperimentalLinkageAPI public fun indirectUseOptInLinkage(): kotlin.Unit - @api.ExperimentalCompilationAPI @api.ExperimentalLinkageAPI public fun use(): kotlin.Unit -} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/override.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/override.kt index c97d0bf527f..74b8b2930c5 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/override.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/override.kt @@ -1,10 +1,9 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) annotation class E open class Base { @@ -16,7 +15,6 @@ class DerivedInSameModule : Base() { override fun foo() {} } -// MODULE: usage1(api) // FILE: usage-propagate.kt package usage1 @@ -35,7 +33,6 @@ class Derived2 : Base() { override fun foo() {} } -// MODULE: usage2(api) // FILE: usage-none.kt package usage2 diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/override.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/override.txt index 4969e4efa5c..e77abeb327a 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/override.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/override.txt @@ -1,4 +1,3 @@ -// -- Module: -- package package api { @@ -19,7 +18,7 @@ package api { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) public final annotation class E : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) public final annotation class E : kotlin.Annotation { public constructor E() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -27,13 +26,6 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage1 { public open class Derived : api.Base { @@ -61,13 +53,6 @@ package usage1 { } } - -// -- Module: -- -package - -package api { -} - package usage2 { public final class Derived : api.Base { diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/scripts.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/scripts.kt index 4974178bbc4..f6b19839a77 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/scripts.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/scripts.kt @@ -1,17 +1,15 @@ // !API_VERSION: 1.3 // !DIAGNOSTICS: -UNUSED_VARIABLE -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) annotation class ExperimentalAPI @ExperimentalAPI fun function(): String = "" -// MODULE: usage1(api) // FILE: usage-propagate.kts import api.* @@ -24,7 +22,6 @@ fun use() { function() use() -// MODULE: usage2(api) // FILE: usage-use.kts @file:UseExperimental(ExperimentalAPI::class) @@ -34,10 +31,9 @@ fun use() { function() } -function() +function() use() -// MODULE: usage3(api) // FILE: usage-none.kts import api.* diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/scripts.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/scripts.txt index db8c572ec7a..ca5d14c675e 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/scripts.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/scripts.txt @@ -1,51 +1,3 @@ -// -- Module: -- -package - -package api { - @api.ExperimentalAPI public fun function(): kotlin.String - - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) public final annotation class ExperimentalAPI : kotlin.Annotation { - public constructor ExperimentalAPI() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} - - -// -- Module: -- -package - -public final class Usage_propagate : kotlin.script.templates.standard.ScriptTemplateWithArgs { - public constructor Usage_propagate(/*0*/ args: kotlin.Array) - public final override /*1*/ /*fake_override*/ val args: kotlin.Array - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - @api.ExperimentalAPI public final fun use(): kotlin.Unit -} - -package api { -} - - -// -- Module: -- -package - -public final class Usage_use : kotlin.script.templates.standard.ScriptTemplateWithArgs { - public constructor Usage_use(/*0*/ args: kotlin.Array) - public final override /*1*/ /*fake_override*/ val args: kotlin.Array - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - public final fun use(): kotlin.Unit -} - -package api { -} - - -// -- Module: -- package public final class Usage_none : kotlin.script.templates.standard.ScriptTemplateWithArgs { @@ -57,5 +9,31 @@ public final class Usage_none : kotlin.script.templates.standard.ScriptTemplateW public final fun use(): kotlin.Unit } -package api { +public final class Usage_propagate : kotlin.script.templates.standard.ScriptTemplateWithArgs { + public constructor Usage_propagate(/*0*/ args: kotlin.Array) + public final override /*1*/ /*fake_override*/ val args: kotlin.Array + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + @api.ExperimentalAPI public final fun use(): kotlin.Unit +} + +public final class Usage_use : kotlin.script.templates.standard.ScriptTemplateWithArgs { + public constructor Usage_use(/*0*/ args: kotlin.Array) + public final override /*1*/ /*fake_override*/ val args: kotlin.Array + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + public final fun use(): kotlin.Unit +} + +package api { + @api.ExperimentalAPI public fun function(): kotlin.String + + @kotlin.Experimental(level = Level.WARNING) public final annotation class ExperimentalAPI : kotlin.Annotation { + public constructor ExperimentalAPI() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.kt index 7d08e06237c..42dbb4c17e7 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.kt @@ -1,11 +1,10 @@ // !API_VERSION: 1.3 // !DIAGNOSTICS: -UNUSED_VARIABLE -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS, AnnotationTarget.VALUE_PARAMETER) annotation class ExperimentalAPI @@ -19,7 +18,6 @@ val property: String = "" @ExperimentalAPI typealias Typealias = String -// MODULE: usage1(api) // FILE: usage-propagate.kt package usage1 @@ -42,7 +40,6 @@ class Use { } } -// MODULE: usage2(api) // FILE: usage-use.kt package usage2 @@ -67,7 +64,6 @@ class Use { } } -// MODULE: usage3(api) // FILE: usage-none.kt package usage3 diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.txt index abffa7f71be..d60b25ae6fa 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.txt @@ -1,11 +1,10 @@ -// -- Module: -- package package api { @api.ExperimentalAPI public val property: kotlin.String = "" @api.ExperimentalAPI public fun function(): kotlin.String - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS, AnnotationTarget.VALUE_PARAMETER}) public final annotation class ExperimentalAPI : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE, AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS, AnnotationTarget.VALUE_PARAMETER}) public final annotation class ExperimentalAPI : kotlin.Annotation { public constructor ExperimentalAPI() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -14,13 +13,6 @@ package api { @api.ExperimentalAPI public typealias Typealias = kotlin.String } - -// -- Module: -- -package - -package api { -} - package usage1 { @api.ExperimentalAPI public fun useAll(): kotlin.Unit @@ -33,13 +25,6 @@ package usage1 { } } - -// -- Module: -- -package - -package api { -} - package usage2 { public fun useAll(): kotlin.Unit @@ -52,13 +37,6 @@ package usage2 { } } - -// -- Module: -- -package - -package api { -} - package usage3 { public fun use(): kotlin.Unit } diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.kt index edf108eb7b9..8b20fdbf2e9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.kt @@ -1,27 +1,25 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.FUNCTION) -annotation class CompilationExperimentalAPI +annotation class ExperimentalAPI1 -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.RUNTIME]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.FUNCTION) -annotation class RuntimeExperimentalAPI +annotation class ExperimentalAPI2 -@CompilationExperimentalAPI +@ExperimentalAPI1 fun compilation() {} -@RuntimeExperimentalAPI +@ExperimentalAPI2 fun runtime() {} -// MODULE: usage(api) // FILE: usage.kt -@file:UseExperimental(CompilationExperimentalAPI::class) +@file:UseExperimental(ExperimentalAPI1::class) package usage import api.* diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.txt index f11b7621003..1e0dee68665 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.txt @@ -1,32 +1,24 @@ -// -- Module: -- package package api { - @api.CompilationExperimentalAPI public fun compilation(): kotlin.Unit - @api.RuntimeExperimentalAPI public fun runtime(): kotlin.Unit + @api.ExperimentalAPI1 public fun compilation(): kotlin.Unit + @api.ExperimentalAPI2 public fun runtime(): kotlin.Unit - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class CompilationExperimentalAPI : kotlin.Annotation { - public constructor CompilationExperimentalAPI() + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI1 : kotlin.Annotation { + public constructor ExperimentalAPI1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.RUNTIME}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class RuntimeExperimentalAPI : kotlin.Annotation { - public constructor RuntimeExperimentalAPI() + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class ExperimentalAPI2 : kotlin.Annotation { + public constructor ExperimentalAPI2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } } - -// -- Module: -- -package - -package api { -} - package usage { public fun use(): kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.kt new file mode 100644 index 00000000000..bed00a78875 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.kt @@ -0,0 +1,30 @@ +// !API_VERSION: 1.3 +// FILE: api.kt + +package api + +@Experimental(Experimental.Level.WARNING) +annotation class ExperimentalAPI + +@ExperimentalAPI +@Experimental(Experimental.Level.WARNING) +annotation class VeryExperimentalAPI + +@ExperimentalAPI +@VeryExperimentalAPI +fun f() {} + +@ExperimentalAPI +fun g() {} + +// FILE: usage.kt + +@file:UseExperimental(ExperimentalAPI::class, VeryExperimentalAPI::class) +package usage + +import api.* + +fun usage() { + f() + g() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.txt new file mode 100644 index 00000000000..9b62008bbe6 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.txt @@ -0,0 +1,24 @@ +package + +package api { + @api.ExperimentalAPI @api.VeryExperimentalAPI public fun f(): kotlin.Unit + @api.ExperimentalAPI public fun g(): kotlin.Unit + + @kotlin.Experimental(level = Level.WARNING) public final annotation class ExperimentalAPI : kotlin.Annotation { + public constructor ExperimentalAPI() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @api.ExperimentalAPI @kotlin.Experimental(level = Level.WARNING) public final annotation class VeryExperimentalAPI : kotlin.Annotation { + public constructor VeryExperimentalAPI() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +package usage { + public fun usage(): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.kt index 36f4e1eebe1..c327e2a75ab 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.kt @@ -5,7 +5,7 @@ package api -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.ERROR) annotation class ExperimentalAPI @ExperimentalAPI diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.txt index d1862fe539f..30ea99595c0 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.txt @@ -4,7 +4,7 @@ package package api { @api.ExperimentalAPI public fun function(): kotlin.String - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.ERROR) public final annotation class ExperimentalAPI : kotlin.Annotation { + @kotlin.Experimental(level = Level.ERROR) public final annotation class ExperimentalAPI : kotlin.Annotation { public constructor ExperimentalAPI() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalTargets.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalTargets.kt index 02cc218815e..b96f66066ac 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalTargets.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalTargets.kt @@ -1,18 +1,16 @@ // !API_VERSION: 1.3 // !DIAGNOSTICS: -UNUSED_PARAMETER -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.CLASS) annotation class E @E open class Foo(val s: String = "") -// MODULE: usage(api) // FILE: usage.kt import api.* diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalTargets.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalTargets.txt index 89a30efe897..d6195ed2db8 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalTargets.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalTargets.txt @@ -1,26 +1,3 @@ -// -- Module: -- -package - -package api { - - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS}) public final annotation class E : kotlin.Annotation { - public constructor E() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - @api.E public open class Foo { - public constructor Foo(/*0*/ s: kotlin.String = ...) - public final val s: kotlin.String - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} - - -// -- Module: -- package @kotlin.UseExperimental(markerClass = {api.E::class}) public val property: kotlin.String @@ -44,4 +21,19 @@ public final class Constructor { } package api { + + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS}) public final annotation class E : kotlin.Annotation { + public constructor E() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + @api.E public open class Foo { + public constructor Foo(/*0*/ s: kotlin.String = ...) + public final val s: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } } diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalWithSeveralAnnotations.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalWithSeveralAnnotations.kt index 2d2bd7e8d9f..bba7affe7a6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalWithSeveralAnnotations.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalWithSeveralAnnotations.kt @@ -1,18 +1,17 @@ // !API_VERSION: 1.3 -// MODULE: api // FILE: api.kt package api -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.FUNCTION) annotation class E1 -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.FUNCTION) annotation class E2 -@Experimental(Experimental.Level.WARNING, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.WARNING) @Target(AnnotationTarget.FUNCTION) annotation class E3 @@ -25,7 +24,6 @@ fun e2() {} @E3 fun e3() {} -// MODULE: usage(api) // FILE: usage.kt package usage diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalWithSeveralAnnotations.txt b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalWithSeveralAnnotations.txt index 8b8c650e95d..3104caafb70 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalWithSeveralAnnotations.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalWithSeveralAnnotations.txt @@ -1,4 +1,3 @@ -// -- Module: -- package package api { @@ -6,21 +5,21 @@ package api { @api.E2 public fun e2(): kotlin.Unit @api.E3 public fun e3(): kotlin.Unit - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class E1 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class E1 : kotlin.Annotation { public constructor E1() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class E2 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class E2 : kotlin.Annotation { public constructor E2() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } - @kotlin.Experimental(changesMayBreak = {Impact.COMPILATION}, level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class E3 : kotlin.Annotation { + @kotlin.Experimental(level = Level.WARNING) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.FUNCTION}) public final annotation class E3 : kotlin.Annotation { public constructor E3() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int @@ -28,13 +27,6 @@ package api { } } - -// -- Module: -- -package - -package api { -} - package usage { @kotlin.UseExperimental(markerClass = {api.E1::class, api.E2::class, api.E3::class}) public fun use1(): kotlin.Unit @kotlin.UseExperimental(markerClass = {api.E1::class, api.E3::class}) public fun use2(): kotlin.Unit diff --git a/compiler/testData/experimental/jsExperimentalModule/output.txt b/compiler/testData/experimental/jsExperimentalModule/output.txt index 47b9e72d0da..0ceee7a6fce 100644 --- a/compiler/testData/experimental/jsExperimentalModule/output.txt +++ b/compiler/testData/experimental/jsExperimentalModule/output.txt @@ -1,7 +1,7 @@ -compiler/testData/experimental/jsExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' +compiler/testData/experimental/jsExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@UseExperimental(lib.ExperimentalAPI::class)' fun fail(foo: Foo) { ^ -compiler/testData/experimental/jsExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' +compiler/testData/experimental/jsExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@UseExperimental(lib.ExperimentalAPI::class)' bar() ^ COMPILATION_ERROR diff --git a/compiler/testData/experimental/jvmExperimentalModule/output.txt b/compiler/testData/experimental/jvmExperimentalModule/output.txt index fe1e69c9ee1..80c78afe57d 100644 --- a/compiler/testData/experimental/jvmExperimentalModule/output.txt +++ b/compiler/testData/experimental/jvmExperimentalModule/output.txt @@ -1,7 +1,7 @@ -compiler/testData/experimental/jvmExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' +compiler/testData/experimental/jvmExperimentalModule/usage.kt:5:15: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@UseExperimental(lib.ExperimentalAPI::class)' fun fail(foo: Foo) { ^ -compiler/testData/experimental/jvmExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' +compiler/testData/experimental/jvmExperimentalModule/usage.kt:6:5: error: this declaration is experimental and its usage must be marked with '@lib.ExperimentalAPI' or '@UseExperimental(lib.ExperimentalAPI::class)' bar() ^ COMPILATION_ERROR diff --git a/compiler/testData/moduleProtoBuf/experimental/main.kt b/compiler/testData/moduleProtoBuf/experimental/main.kt index 286b6b564bb..e237bd95288 100644 --- a/compiler/testData/moduleProtoBuf/experimental/main.kt +++ b/compiler/testData/moduleProtoBuf/experimental/main.kt @@ -8,5 +8,5 @@ class B { annotation class C } -@Experimental(Experimental.Level.ERROR, [Experimental.Impact.COMPILATION]) +@Experimental(Experimental.Level.ERROR) annotation class D diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index c077ab0cca8..36466ed296f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -2077,16 +2077,16 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.kt"); } - @TestMetadata("bodyUsageInSameModule.kt") - public void testBodyUsageInSameModule() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.kt"); - } - @TestMetadata("bodyUsages.kt") public void testBodyUsages() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.kt"); } + @TestMetadata("bodyUsagesAndInline.kt") + public void testBodyUsagesAndInline() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt"); + } + @TestMetadata("classMembers.kt") public void testClassMembers() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt"); @@ -2097,11 +2097,6 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.kt"); } - @TestMetadata("compilationVsLinkageVsRuntime.kt") - public void testCompilationVsLinkageVsRuntime() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.kt"); - } - @TestMetadata("constVal.kt") public void testConstVal() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt"); @@ -2122,11 +2117,6 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalOnWholeModule.kt"); } - @TestMetadata("experimentalWithNoImpact.kt") - public void testExperimentalWithNoImpact() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.kt"); - } - @TestMetadata("incorrectTargetsForExperimentalAnnotation.kt") public void testIncorrectTargetsForExperimentalAnnotation() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt"); @@ -2137,11 +2127,6 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.kt"); } - @TestMetadata("indirectBodyUsageInAnotherModule.kt") - public void testIndirectBodyUsageInAnotherModule() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.kt"); - } - @TestMetadata("override.kt") public void testOverride() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/override.kt"); @@ -2172,6 +2157,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.kt"); } + @TestMetadata("useExperimentalOnFileWithVeryExperimentalMarker.kt") + public void testUseExperimentalOnFileWithVeryExperimentalMarker() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.kt"); + } + @TestMetadata("useExperimentalOnWholeModule.kt") public void testUseExperimentalOnWholeModule() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 5fe9b9da582..048d23513b4 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -2077,16 +2077,16 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/annotation.kt"); } - @TestMetadata("bodyUsageInSameModule.kt") - public void testBodyUsageInSameModule() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.kt"); - } - @TestMetadata("bodyUsages.kt") public void testBodyUsages() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.kt"); } + @TestMetadata("bodyUsagesAndInline.kt") + public void testBodyUsagesAndInline() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsagesAndInline.kt"); + } + @TestMetadata("classMembers.kt") public void testClassMembers() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt"); @@ -2097,11 +2097,6 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/classMembersOverlyExperimental.kt"); } - @TestMetadata("compilationVsLinkageVsRuntime.kt") - public void testCompilationVsLinkageVsRuntime() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/compilationVsLinkageVsRuntime.kt"); - } - @TestMetadata("constVal.kt") public void testConstVal() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/constVal.kt"); @@ -2122,11 +2117,6 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalOnWholeModule.kt"); } - @TestMetadata("experimentalWithNoImpact.kt") - public void testExperimentalWithNoImpact() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/experimentalWithNoImpact.kt"); - } - @TestMetadata("incorrectTargetsForExperimentalAnnotation.kt") public void testIncorrectTargetsForExperimentalAnnotation() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectTargetsForExperimentalAnnotation.kt"); @@ -2137,11 +2127,6 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/incorrectUseExperimental.kt"); } - @TestMetadata("indirectBodyUsageInAnotherModule.kt") - public void testIndirectBodyUsageInAnotherModule() throws Exception { - runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.kt"); - } - @TestMetadata("override.kt") public void testOverride() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/override.kt"); @@ -2172,6 +2157,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFile.kt"); } + @TestMetadata("useExperimentalOnFileWithVeryExperimentalMarker.kt") + public void testUseExperimentalOnFileWithVeryExperimentalMarker() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnFileWithVeryExperimentalMarker.kt"); + } + @TestMetadata("useExperimentalOnWholeModule.kt") public void testUseExperimentalOnWholeModule() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/useExperimentalOnWholeModule.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java index 64315d76fd5..113a36ad4d2 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/CliTestGenerated.java @@ -186,11 +186,6 @@ public class CliTestGenerated extends AbstractCliTest { runTest("compiler/testData/cli/jvm/experimentalNested.args"); } - @TestMetadata("experimentalRuntimeScope.args") - public void testExperimentalRuntimeScope() throws Exception { - runTest("compiler/testData/cli/jvm/experimentalRuntimeScope.args"); - } - @TestMetadata("experimentalUnresolved.args") public void testExperimentalUnresolved() throws Exception { runTest("compiler/testData/cli/jvm/experimentalUnresolved.args"); diff --git a/libraries/stdlib/experimental/kotlin/annotations/Experimental.kt b/libraries/stdlib/experimental/kotlin/annotations/Experimental.kt index 2b9eb149b33..0ed4de012eb 100644 --- a/libraries/stdlib/experimental/kotlin/annotations/Experimental.kt +++ b/libraries/stdlib/experimental/kotlin/annotations/Experimental.kt @@ -12,17 +12,14 @@ import kotlin.reflect.KClass /** * Signals that the annotated annotation class is a marker of an experimental API. Any declaration annotated with that marker is thus - * considered an experimental declaration and its call sites must accept the experimental aspect of it either by using [UseExperimental], + * considered an experimental declaration and its call sites should accept the experimental aspect of it either by using [UseExperimental], * or by being annotated with that marker themselves, effectively causing further propagation of that experimental aspect. */ @Target(ANNOTATION_CLASS) @Retention(BINARY) @SinceKotlin("1.3") -@Suppress("ANNOTATION_CLASS_WITH_BODY", "ANNOTATION_CLASS_MEMBER", "ReplaceArrayOfWithLiteral") -annotation class Experimental( - val level: Level = Level.ERROR, - val changesMayBreak: Array = arrayOf(Impact.COMPILATION, Impact.LINKAGE, Impact.RUNTIME) // arrayOf, not [] because of KT-22578 -) { +@Suppress("ANNOTATION_CLASS_MEMBER") +annotation class Experimental(val level: Level = Level.ERROR) { /** * Severity of the diagnostic that should be reported on usages of experimental API which did not explicitly accept the experimental aspect * of that API either by using [UseExperimental] or by being annotated with the corresponding marker annotation. @@ -33,46 +30,11 @@ annotation class Experimental( /** Specifies that an error should be reported on incorrect usages of this experimental API. */ ERROR, } - - /** - * Impact of the experimental API specifies what aspects may break after that API is changed. - */ - enum class Impact { - /** - * Signifies that changes in this experimental API can cause compilation errors or warnings in the client code. - * - * Non-signature usages (inside a function body, variable initializer, default argument value, etc.) of compilation-affecting - * experimental API are allowed either if the containing declaration is annotated with the experimental annotation marker - * and thus propagates the experimental aspect to its clients, or if there's a [UseExperimental] annotation entry with - * the corresponding annotation marker somewhere above that usage in the parse tree. Signature usages of compilation-affecting - * experimental API always require propagation (as long as the experimental API is declared in another module). - */ - COMPILATION, - /** - * Signifies that changes in this experimental API can cause linkage errors, i.e. exceptions at runtime - * if the client code was not recompiled after the change. - * - * Any usage of a linkage-affecting experimental API requires its containing declaration to be annotated with - * the corresponding annotation marker (except non-signature usages in annotation marker's module). - */ - LINKAGE, - /** - * Signifies that changes in this experimental API can cause changes in runtime behavior, including exceptions at runtime. - * - * Any usage of a runtime-affecting experimental API requires its containing declaration to be annotated with - * the corresponding annotation marker (except non-signature usages in the annotation marker's module). - */ - RUNTIME, - } } /** - * Allows to use experimental API denoted by the given markers in the annotated file, declaration, or expression. Each of the given markers - * must be an annotation class, whose impact ([Experimental.changesMayBreak]) is [Experimental.Impact.COMPILATION]. - * Any other given annotation classes have no effect and are ignored. - * - * Only allows non-signature usages of the experimental API, i.e. inside a function body, variable initializer, default argument value, etc. - * (Usages in declaration signatures must be propagated by annotating the affected signature with the marker annotation itself.) + * Allows to use experimental API denoted by the given markers in the annotated file, declaration, or expression. + * If a declaration is annotated with [UseExperimental], its usages are **not** required to opt-in to that experimental API. */ @Target(CLASS, PROPERTY, LOCAL_VARIABLE, VALUE_PARAMETER, CONSTRUCTOR, FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER, EXPRESSION, FILE) @Retention(SOURCE) diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt index 9e1601386d3..26179f66384 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt @@ -21,18 +21,9 @@ public final class kotlin/ExceptionsKt { } public abstract interface annotation class kotlin/Experimental : java/lang/annotation/Annotation { - public abstract fun changesMayBreak ()[Lkotlin/Experimental$Impact; public abstract fun level ()Lkotlin/Experimental$Level; } -public final class kotlin/Experimental$Impact : java/lang/Enum { - public static final field COMPILATION Lkotlin/Experimental$Impact; - public static final field LINKAGE Lkotlin/Experimental$Impact; - public static final field RUNTIME Lkotlin/Experimental$Impact; - public static fun valueOf (Ljava/lang/String;)Lkotlin/Experimental$Impact; - public static fun values ()[Lkotlin/Experimental$Impact; -} - public final class kotlin/Experimental$Level : java/lang/Enum { public static final field ERROR Lkotlin/Experimental$Level; public static final field WARNING Lkotlin/Experimental$Level;