Do not require experimental propagation for body usages in same module

Unless it's a usage inside the body of an effectively public inline
function

 #KT-22759 In Progress
This commit is contained in:
Alexander Udalov
2018-01-02 18:49:34 +01:00
parent 6d4e8f3781
commit 29c35e6686
37 changed files with 511 additions and 50 deletions
@@ -227,7 +227,7 @@ class LazyTopDownAnalyzer(
checkClassifierUsages(
declarations, classifierUsageCheckers,
ClassifierUsageCheckerContext(trace, languageVersionSettings, deprecationResolver)
ClassifierUsageCheckerContext(trace, languageVersionSettings, deprecationResolver, moduleDescriptor)
)
return c
@@ -278,8 +278,9 @@ public class ModifiersChecker {
public void runDeclarationCheckers(@NotNull KtDeclaration declaration, @NotNull DeclarationDescriptor descriptor) {
DeclarationCheckerContext context =
new DeclarationCheckerContext(trace, languageVersionSettings, deprecationResolver, expectActualTracker);
DeclarationCheckerContext context = new DeclarationCheckerContext(
trace, languageVersionSettings, deprecationResolver, moduleDescriptor, expectActualTracker
);
for (DeclarationChecker checker : declarationCheckers) {
checker.check(declaration, descriptor, context);
}
@@ -301,19 +302,22 @@ public class ModifiersChecker {
private final LanguageVersionSettings languageVersionSettings;
private final ExpectActualTracker expectActualTracker;
private final DeprecationResolver deprecationResolver;
private final ModuleDescriptor moduleDescriptor;
public ModifiersChecker(
@NotNull AnnotationChecker annotationChecker,
@NotNull Iterable<DeclarationChecker> declarationCheckers,
@NotNull LanguageVersionSettings languageVersionSettings,
@NotNull ExpectActualTracker expectActualTracker,
@NotNull DeprecationResolver deprecationResolver
@NotNull DeprecationResolver deprecationResolver,
@NotNull ModuleDescriptor moduleDescriptor
) {
this.annotationChecker = annotationChecker;
this.declarationCheckers = declarationCheckers;
this.languageVersionSettings = languageVersionSettings;
this.expectActualTracker = expectActualTracker;
this.deprecationResolver = deprecationResolver;
this.moduleDescriptor = moduleDescriptor;
}
@NotNull
@@ -16,12 +16,12 @@
package org.jetbrains.kotlin.resolve.calls
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.getReturnTypeFromFunctionType
import org.jetbrains.kotlin.builtins.getValueParameterTypesFromFunctionType
import org.jetbrains.kotlin.builtins.isFunctionType
import org.jetbrains.kotlin.contracts.EffectSystem
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.BindingContext.CONSTRAINT_SYSTEM_COMPLETER
@@ -59,7 +59,7 @@ class CallCompleter(
private val candidateResolver: CandidateResolver,
private val dataFlowAnalyzer: DataFlowAnalyzer,
private val callCheckers: Iterable<CallChecker>,
private val builtIns: KotlinBuiltIns,
private val moduleDescriptor: ModuleDescriptor,
private val deprecationResolver: DeprecationResolver,
private val effectSystem: EffectSystem
) {
@@ -87,7 +87,7 @@ class CallCompleter(
if (calleeExpression != null && !calleeExpression.isFakeElement) calleeExpression
else resolvedCall.call.callElement
val callCheckerContext = CallCheckerContext(context, deprecationResolver)
val callCheckerContext = CallCheckerContext(context, deprecationResolver, moduleDescriptor)
for (callChecker in callCheckers) {
callChecker.check(resolvedCall, reportOn, callCheckerContext)
@@ -202,7 +202,7 @@ class CallCompleter(
updateSystemIfNeeded { builder ->
val returnTypeInSystem = builder.typeInSystem(returnType)
if (returnTypeInSystem != null) {
builder.addSubtypeConstraint(returnTypeInSystem, builtIns.unitType, EXPECTED_TYPE_POSITION.position())
builder.addSubtypeConstraint(returnTypeInSystem, moduleDescriptor.builtIns.unitType, EXPECTED_TYPE_POSITION.position())
val system = builder.build()
if (system.status.isSuccessful()) system else null
} else null
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.DeprecationResolver
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
@@ -39,6 +40,7 @@ interface CallChecker {
class CallCheckerContext @JvmOverloads constructor(
val resolutionContext: ResolutionContext<*>,
override val deprecationResolver: DeprecationResolver,
override val moduleDescriptor: ModuleDescriptor,
override val trace: BindingTrace = resolutionContext.trace
) : CheckerContext {
val scope: LexicalScope
@@ -65,7 +65,8 @@ class KotlinToResolvedCallTransformer(
private val deprecationResolver: DeprecationResolver,
private val expressionTypingServices: ExpressionTypingServices,
private val doubleColonExpressionResolver: DoubleColonExpressionResolver,
private val additionalDiagnosticReporter: AdditionalDiagnosticReporter
private val additionalDiagnosticReporter: AdditionalDiagnosticReporter,
private val moduleDescriptor: ModuleDescriptor
) {
companion object {
private val REPORT_MISSING_NEW_INFERENCE_DIAGNOSTIC
@@ -97,8 +98,8 @@ class KotlinToResolvedCallTransformer(
CallResolutionResult.Type.ERROR, CallResolutionResult.Type.COMPLETED -> {
val resultSubstitutor = baseResolvedCall.constraintSystem.buildResultingSubstitutor()
val ktPrimitiveCompleter = ResolvedAtomCompleter(
resultSubstitutor, context.trace, context, this,
expressionTypingServices, argumentTypeResolver, doubleColonExpressionResolver, deprecationResolver
resultSubstitutor, context.trace, context, this, expressionTypingServices, argumentTypeResolver,
doubleColonExpressionResolver, deprecationResolver, moduleDescriptor
)
for (subKtPrimitive in candidate.subResolvedAtoms) {
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.tower
import org.jetbrains.kotlin.builtins.replaceReturnType
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
import org.jetbrains.kotlin.psi.KtElement
@@ -53,9 +54,10 @@ class ResolvedAtomCompleter(
private val expressionTypingServices: ExpressionTypingServices,
private val argumentTypeResolver: ArgumentTypeResolver,
private val doubleColonExpressionResolver: DoubleColonExpressionResolver,
deprecationResolver: DeprecationResolver
deprecationResolver: DeprecationResolver,
moduleDescriptor: ModuleDescriptor
) {
private val callCheckerContext = CallCheckerContext(topLevelCallContext, deprecationResolver)
private val callCheckerContext = CallCheckerContext(topLevelCallContext, deprecationResolver, moduleDescriptor)
private fun complete(resolvedAtom: ResolvedAtom) {
when (resolvedAtom) {
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.DeprecationResolver
@@ -26,4 +27,6 @@ interface CheckerContext {
val languageVersionSettings: LanguageVersionSettings
val deprecationResolver: DeprecationResolver
val moduleDescriptor: ModuleDescriptor
}
@@ -35,7 +35,8 @@ interface ClassifierUsageChecker {
class ClassifierUsageCheckerContext(
override val trace: BindingTrace,
override val languageVersionSettings: LanguageVersionSettings,
override val deprecationResolver: DeprecationResolver
override val deprecationResolver: DeprecationResolver,
override val moduleDescriptor: ModuleDescriptor
) : CheckerContext
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.resolve.BindingTrace
@@ -31,5 +32,6 @@ class DeclarationCheckerContext(
override val trace: BindingTrace,
override val languageVersionSettings: LanguageVersionSettings,
override val deprecationResolver: DeprecationResolver,
override val moduleDescriptor: ModuleDescriptor,
val expectActualTracker: ExpectActualTracker
) : CheckerContext
@@ -17,10 +17,7 @@
package org.jetbrains.kotlin.resolve.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.name.FqName
@@ -37,6 +34,7 @@ import org.jetbrains.kotlin.resolve.constants.EnumValue
import org.jetbrains.kotlin.resolve.constants.KClassValue
import org.jetbrains.kotlin.resolve.descriptorUtil.annotationClass
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.utils.SmartSet
import org.jetbrains.kotlin.utils.addIfNotNull
@@ -54,7 +52,12 @@ object ExperimentalUsageChecker : CallChecker {
private val LINKAGE_IMPACT = Name.identifier("LINKAGE")
private val RUNTIME_IMPACT = Name.identifier("RUNTIME")
internal data class Experimentality(val annotationFqName: FqName, val severity: Severity, private val impact: List<Impact>) {
internal data class Experimentality(
val markerDescriptor: ClassDescriptor,
val annotationFqName: FqName,
val severity: Severity,
private val impact: List<Impact>
) {
val isCompilationOnly: Boolean get() = impact.all(Impact.COMPILATION::equals)
enum class Severity { WARNING, ERROR }
@@ -67,22 +70,33 @@ object ExperimentalUsageChecker : CallChecker {
}
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
checkExperimental(resolvedCall.resultingDescriptor, reportOn, context.trace)
checkExperimental(resolvedCall.resultingDescriptor, reportOn, context.trace, context.moduleDescriptor)
}
private fun checkExperimental(descriptor: DeclarationDescriptor, element: PsiElement, trace: BindingTrace) {
for (experimentality in descriptor.loadExperimentalities()) {
val (annotationFqName, severity) = experimentality
private fun checkExperimental(descriptor: DeclarationDescriptor, element: PsiElement, trace: BindingTrace, module: ModuleDescriptor) {
val experimentalities = descriptor.loadExperimentalities()
if (experimentalities.isEmpty()) return
val isBodyUsageExceptPublicInline = element.isBodyUsage(trace.bindingContext, allowPublicInline = false)
val isBodyUsage = isBodyUsageExceptPublicInline || element.isBodyUsage(trace.bindingContext, allowPublicInline = true)
for (experimentality in experimentalities) {
val isBodyUsageOfCompilationExperimentality =
experimentality.isCompilationOnly && element.isBodyUsage()
experimentality.isCompilationOnly && isBodyUsage
val isBodyUsageInSameModule =
experimentality.markerDescriptor.module == module && isBodyUsageExceptPublicInline
val annotationFqName = experimentality.annotationFqName
val isExperimentalityAccepted =
isBodyUsageInSameModule ||
(isBodyUsageOfCompilationExperimentality &&
element.hasContainerAnnotatedWithUseExperimental(annotationFqName, trace.bindingContext)) ||
element.propagates(annotationFqName, trace.bindingContext)
if (!isExperimentalityAccepted) {
val diagnostic = when (severity) {
val diagnostic = when (experimentality.severity) {
ExperimentalUsageChecker.Experimentality.Severity.WARNING -> Errors.EXPERIMENTAL_API_USAGE
ExperimentalUsageChecker.Experimentality.Severity.ERROR -> Errors.EXPERIMENTAL_API_USAGE_ERROR
}
@@ -125,16 +139,18 @@ object ExperimentalUsageChecker : CallChecker {
}
} ?: Experimentality.DEFAULT_IMPACT
return Experimentality(fqNameSafe, severity, 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(): Boolean {
private fun PsiElement.isBodyUsage(bindingContext: BindingContext, allowPublicInline: Boolean): Boolean {
return anyParentMatches { element, parent ->
element == (parent as? KtDeclarationWithBody)?.bodyExpression ||
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 ||
@@ -144,6 +160,19 @@ object ExperimentalUsageChecker : CallChecker {
}
}
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
}
}
// Checks whether any of the non-local enclosing declarations is annotated with annotationFqName, effectively requiring
// propagation for the experimental annotation to the call sites
private fun PsiElement.propagates(annotationFqName: FqName, bindingContext: BindingContext): Boolean {
@@ -185,7 +214,7 @@ object ExperimentalUsageChecker : CallChecker {
object ClassifierUsage : ClassifierUsageChecker {
override fun check(targetDescriptor: ClassifierDescriptor, element: PsiElement, context: ClassifierUsageCheckerContext) {
checkExperimental(targetDescriptor, element, context.trace)
checkExperimental(targetDescriptor, element, context.trace, context.moduleDescriptor)
}
}
@@ -938,7 +938,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
if (resolvedCall != null && trace.wantsDiagnostics()) {
// Call must be validated with the actual, not temporary trace in order to report operator diagnostic
// Only unary assignment expressions (++, --) and +=/... must be checked, normal assignments have the proper trace
CallCheckerContext callCheckerContext = new CallCheckerContext(context, components.deprecationResolver, trace);
CallCheckerContext callCheckerContext =
new CallCheckerContext(context, components.deprecationResolver, components.moduleDescriptor, trace);
for (CallChecker checker : components.callCheckers) {
checker.check(resolvedCall, expression, callCheckerContext);
}
@@ -1015,7 +1016,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
@NotNull
private CallCheckerContext createCallCheckerContext(@NotNull ExpressionTypingContext context) {
return new CallCheckerContext(context, components.deprecationResolver);
return new CallCheckerContext(context, components.deprecationResolver, components.moduleDescriptor);
}
@Override
@@ -1,5 +1,6 @@
// !API_VERSION: 1.3
// !DIAGNOSTICS: -UNUSED_PARAMETER
// MODULE: api
// FILE: api.kt
package api
@@ -14,6 +15,7 @@ annotation class ExperimentalAPI
AnnotationTarget.VALUE_PARAMETER)
annotation class EAnno
// MODULE: usage1(api)
// FILE: usage-propagate.kt
package usage1
@@ -59,6 +61,7 @@ val inProperty = @EAnno fun() {}
val inPropertyAccessor: () -> Unit
get() = @EAnno fun() {}
// MODULE: usage2(api)
// FILE: usage-use.kt
package usage2
@@ -102,6 +105,7 @@ val inPropertyAccessor: () -> Unit
@UseExperimental(ExperimentalAPI::class)
get() = @EAnno fun() {}
// MODULE: usage3(api)
// FILE: usage-none.kt
package usage3
@@ -1,3 +1,4 @@
// -- Module: <api> --
package
package api {
@@ -17,6 +18,13 @@ package api {
}
}
// -- Module: <usage1> --
package
package api {
}
package usage1 {
@api.ExperimentalAPI public val inProperty: () -> kotlin.Unit
@api.ExperimentalAPI public val inPropertyAccessor: () -> kotlin.Unit
@@ -45,6 +53,13 @@ package usage1 {
@api.ExperimentalAPI @api.EAnno public typealias Typealias = kotlin.Unit
}
// -- Module: <usage2> --
package
package api {
}
package usage2 {
@kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public val inProperty: () -> kotlin.Unit
public val inPropertyAccessor: () -> kotlin.Unit
@@ -73,6 +88,13 @@ package usage2 {
@kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) @api.EAnno public typealias Typealias = kotlin.Unit
}
// -- Module: <usage3> --
package
package api {
}
package usage3 {
public val inProperty: () -> kotlin.Unit
public val inPropertyAccessor: () -> kotlin.Unit
@@ -0,0 +1,104 @@
// !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() {
<!EXPERIMENTAL_API_USAGE!>compilation<!>()
<!EXPERIMENTAL_API_USAGE!>linkage<!>()
}
inline var inlineUse2: Unit
get() {
<!EXPERIMENTAL_API_USAGE!>compilation<!>()
<!EXPERIMENTAL_API_USAGE!>linkage<!>()
}
set(value) {
<!EXPERIMENTAL_API_USAGE!>compilation<!>()
<!EXPERIMENTAL_API_USAGE!>linkage<!>()
}
var inlineUse3: Unit
inline get() {
<!EXPERIMENTAL_API_USAGE!>compilation<!>()
<!EXPERIMENTAL_API_USAGE!>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()
}
}
@@ -0,0 +1,41 @@
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
}
}
package usage {
public var inlineUse2: kotlin.Unit
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
private inline fun privateInline1(): kotlin.Unit
internal inline fun privateInline2(): kotlin.Unit
public fun use1(): kotlin.Unit
internal final class InternalClass {
public constructor InternalClass()
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 final inline fun privateInline4(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -1,4 +1,5 @@
// !API_VERSION: 1.3
// MODULE: api
// FILE: api.kt
package api
@@ -11,6 +12,7 @@ interface I
@ExperimentalCompilationAPI
class Impl : I
// MODULE: usage(api)
// FILE: usage.kt
package usage
@@ -1,3 +1,4 @@
// -- Module: <api> --
package
package api {
@@ -23,6 +24,13 @@ package api {
}
}
// -- Module: <usage> --
package
package api {
}
package usage {
@kotlin.UseExperimental(markerClass = {api.ExperimentalCompilationAPI::class}) public val delegatedProperty: kotlin.Nothing?
public operator fun api.I.getValue(/*0*/ x: kotlin.Any?, /*1*/ y: kotlin.Any?): kotlin.Nothing?
@@ -1,4 +1,5 @@
// !API_VERSION: 1.3
// MODULE: api
// FILE: api.kt
package api
@@ -18,6 +19,7 @@ class C {
@ExperimentalAPI
fun C.extension() {}
// MODULE: usage1(api)
// FILE: usage-propagate.kt
package usage1
@@ -45,6 +47,7 @@ class Use {
}
}
// MODULE: usage2(api)
// FILE: usage-use.kt
package usage2
@@ -72,6 +75,7 @@ class Use {
}
}
// MODULE: usage3(api)
// FILE: usage-none.kt
package usage3
@@ -1,3 +1,4 @@
// -- Module: <api> --
package
package api {
@@ -34,6 +35,13 @@ package api {
}
}
// -- Module: <usage1> --
package
package api {
}
package usage1 {
@api.ExperimentalAPI public fun useAll(): kotlin.Unit
@@ -46,6 +54,13 @@ package usage1 {
}
}
// -- Module: <usage2> --
package
package api {
}
package usage2 {
@kotlin.UseExperimental(markerClass = {api.ExperimentalAPI::class}) public fun useAll(): kotlin.Unit
@@ -58,6 +73,13 @@ package usage2 {
}
}
// -- Module: <usage3> --
package
package api {
}
package usage3 {
public fun use(): kotlin.Unit
}
@@ -1,4 +1,5 @@
// !API_VERSION: 1.3
// MODULE: api
// FILE: api.kt
package api
@@ -22,6 +23,7 @@ class C {
}
}
// MODULE: usage(api)
// FILE: usage.kt
package usage
@@ -1,3 +1,4 @@
// -- Module: <api> --
package
package api {
@@ -27,6 +28,13 @@ package api {
}
}
// -- Module: <usage> --
package
package api {
}
package usage {
public fun use(): kotlin.Unit
}
@@ -1,4 +1,5 @@
// !API_VERSION: 1.3
// MODULE: api
// FILE: api.kt
package api
@@ -21,6 +22,7 @@ fun linkage() {}
@ExperimentalRuntimeAPI
fun runtime() {}
// MODULE: usage1(api)
// FILE: usage.kt
package usage1
@@ -52,6 +54,7 @@ fun recursiveUse() {
recursiveUse()
}
// MODULE: usage2(api,usage1)
// FILE: usage-no-annotation.txt
package usage2
@@ -1,3 +1,4 @@
// -- Module: <api> --
package
package api {
@@ -27,12 +28,29 @@ package api {
}
}
// -- Module: <usage1> --
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: <usage2> --
package
package api {
}
package usage1 {
}
package usage2 {
public fun use1(): kotlin.Unit
@api.ExperimentalLinkageAPI public fun use2(): kotlin.Unit
@@ -1,4 +1,5 @@
// !API_VERSION: 1.3
// MODULE: api
// FILE: api.kt
package api
@@ -10,6 +11,7 @@ annotation class BinaryExperimental
@BinaryExperimental
val x = ""
// MODULE: usage(api)
// FILE: usage.kt
import api.*
@@ -1,9 +1,6 @@
// -- Module: <api> --
package
@kotlin.UseExperimental(annotationClass = {}) public fun use1(): kotlin.String
@kotlin.UseExperimental(annotationClass = {api.BinaryExperimental::class}) public fun use2(): kotlin.String
@kotlin.UseExperimental(annotationClass = {kotlin.UseExperimental::class}) public fun use3(): kotlin.String
package api {
@api.BinaryExperimental public val x: kotlin.String = ""
@@ -14,3 +11,14 @@ package api {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
// -- Module: <usage> --
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 {
}
@@ -0,0 +1,52 @@
// !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() {
<!EXPERIMENTAL_API_USAGE, EXPERIMENTAL_API_USAGE!>use<!>()
}
@ExperimentalCompilationAPI
fun indirectUseOptInCompilation() {
<!EXPERIMENTAL_API_USAGE!>use<!>()
}
@ExperimentalLinkageAPI
fun indirectUseOptInLinkage() {
<!EXPERIMENTAL_API_USAGE!>use<!>()
}
@ExperimentalCompilationAPI
@ExperimentalLinkageAPI
fun indirectUseOptInBoth() {
use()
}
@@ -0,0 +1,36 @@
// -- Module: <api> --
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: <usage> --
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
}
@@ -1,5 +1,6 @@
// !API_VERSION: 1.3
// !DIAGNOSTICS: -UNUSED_VARIABLE
// MODULE: api
// FILE: api.kt
package api
@@ -18,6 +19,7 @@ val property: String = ""
@ExperimentalAPI
typealias Typealias = String
// MODULE: usage1(api)
// FILE: usage-propagate.kt
package usage1
@@ -40,6 +42,7 @@ class Use {
}
}
// MODULE: usage2(api)
// FILE: usage-use.kt
package usage2
@@ -64,6 +67,7 @@ class Use {
}
}
// MODULE: usage3(api)
// FILE: usage-none.kt
package usage3
@@ -1,3 +1,4 @@
// -- Module: <api> --
package
package api {
@@ -13,6 +14,13 @@ package api {
@api.ExperimentalAPI public typealias Typealias = kotlin.String
}
// -- Module: <usage1> --
package
package api {
}
package usage1 {
@api.ExperimentalAPI public fun useAll(): kotlin.Unit
@@ -25,6 +33,13 @@ package usage1 {
}
}
// -- Module: <usage2> --
package
package api {
}
package usage2 {
public fun useAll(): kotlin.Unit
@@ -37,6 +52,13 @@ package usage2 {
}
}
// -- Module: <usage3> --
package
package api {
}
package usage3 {
public fun use(): kotlin.Unit
}
@@ -1,4 +1,5 @@
// !API_VERSION: 1.3
// MODULE: api
// FILE: api.kt
package api
@@ -17,6 +18,7 @@ fun compilation() {}
@RuntimeExperimentalAPI
fun runtime() {}
// MODULE: usage(api)
// FILE: usage.kt
@file:UseExperimental(CompilationExperimentalAPI::class)
@@ -1,3 +1,4 @@
// -- Module: <api> --
package
package api {
@@ -19,6 +20,13 @@ package api {
}
}
// -- Module: <usage> --
package
package api {
}
package usage {
public fun use(): kotlin.Unit
@@ -1,5 +1,6 @@
// !API_VERSION: 1.3
// !DIAGNOSTICS: -UNUSED_PARAMETER
// MODULE: api
// FILE: api.kt
package api
@@ -11,6 +12,7 @@ annotation class E
@E
open class Foo(val s: String = "")
// MODULE: usage(api)
// FILE: usage.kt
import api.*
@@ -1,3 +1,26 @@
// -- Module: <api> --
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: <usage> --
package
@kotlin.UseExperimental(markerClass = {api.E::class}) public val property: kotlin.String
@@ -21,19 +44,4 @@ public final class Constructor {
}
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
}
}
@@ -1,4 +1,5 @@
// !API_VERSION: 1.3
// MODULE: api
// FILE: api.kt
package api
@@ -24,6 +25,7 @@ fun e2() {}
@E3
fun e3() {}
// MODULE: usage(api)
// FILE: usage.kt
package usage
@@ -1,3 +1,4 @@
// -- Module: <api> --
package
package api {
@@ -27,6 +28,13 @@ package api {
}
}
// -- Module: <usage> --
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
@@ -1809,6 +1809,12 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
doTest(fileName);
}
@TestMetadata("bodyUsageInSameModule.kt")
public void testBodyUsageInSameModule() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.kt");
doTest(fileName);
}
@TestMetadata("bodyUsages.kt")
public void testBodyUsages() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.kt");
@@ -1851,6 +1857,12 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
doTest(fileName);
}
@TestMetadata("indirectBodyUsageInAnotherModule.kt")
public void testIndirectBodyUsageInAnotherModule() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.kt");
doTest(fileName);
}
@TestMetadata("topLevel.kt")
public void testTopLevel() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.kt");
@@ -1809,6 +1809,12 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
doTest(fileName);
}
@TestMetadata("bodyUsageInSameModule.kt")
public void testBodyUsageInSameModule() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsageInSameModule.kt");
doTest(fileName);
}
@TestMetadata("bodyUsages.kt")
public void testBodyUsages() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/bodyUsages.kt");
@@ -1851,6 +1857,12 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
doTest(fileName);
}
@TestMetadata("indirectBodyUsageInAnotherModule.kt")
public void testIndirectBodyUsageInAnotherModule() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/indirectBodyUsageInAnotherModule.kt");
doTest(fileName);
}
@TestMetadata("topLevel.kt")
public void testTopLevel() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.kt");