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 3572769e8a3..ed90024a496 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalUsageChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExperimentalUsageChecker.kt @@ -220,11 +220,6 @@ class ExperimentalUsageChecker(project: Project) : CallChecker { } } - val container = containingDeclaration - if (container is ClassDescriptor && this !is ConstructorDescriptor) { - result.addAll(container.loadExperimentalities(moduleAnnotationsResolver, languageVersionSettings, visited, useFutureError)) - } - for (moduleAnnotationClassId in moduleAnnotationsResolver.getAnnotationsOnContainingModule(this)) { val annotationClass = module.findClassAcrossModuleDependencies(moduleAnnotationClassId) result.addIfNotNull(annotationClass?.loadExperimentalityForMarkerAnnotation()) diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.fir.kt new file mode 100644 index 00000000000..b0b6b1e44d8 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.fir.kt @@ -0,0 +1,89 @@ +// !USE_EXPERIMENTAL: kotlin.RequiresOptIn +// FILE: api.kt + +package api + +@RequiresOptIn(level = RequiresOptIn.Level.WARNING) +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +@Retention(AnnotationRetention.BINARY) +annotation class ExperimentalAPI + +@ExperimentalAPI +class C { + fun function(): String = "" + val property: String = "" + class Nested + inner class Inner +} + +@ExperimentalAPI +fun C.extension() {} + +// FILE: usage-propagate.kt + +package usage1 + +import api.* + +@ExperimentalAPI +fun useAll() { + val c: C = C() + c.function() + c.property + C.Nested() + c.Inner() + c.extension() +} + +@ExperimentalAPI +class Use { + fun useAll(c: C) { + c.function() + c.property + C.Nested() + c.Inner() + c.extension() + } +} + +// FILE: usage-use.kt + +package usage2 + +import api.* + +@OptIn(ExperimentalAPI::class) +fun useAll() { + val c: C = C() + c.function() + c.property + C.Nested() + c.Inner() + c.extension() +} + +@OptIn(ExperimentalAPI::class) +class Use { + fun useAll(c: C) { + c.function() + c.property + C.Nested() + c.Inner() + c.extension() + } +} + +// FILE: usage-none.kt + +package usage3 + +import api.* + +fun use() { + val c: C = C() + c.function() + c.property + C.Nested() + c.Inner() + c.extension() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt index d390e4a5e02..a332420920b 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/classMembers.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !USE_EXPERIMENTAL: kotlin.RequiresOptIn // FILE: api.kt @@ -82,9 +81,9 @@ import api.* fun use() { val c: C = C() - c.function() - c.property - C.Nested() - c.Inner() + c.function() + c.property + C.Nested() + c.Inner() c.extension() } diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt index 32e03d8a48d..9432a69cb49 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/deeplyNestedClass.kt @@ -52,7 +52,7 @@ package usage3 import api.* fun use1() { - C.D.E.F() + C.D.E.F() } -fun use2(f: C.D.E.F) = f.hashCode() +fun use2(f: C.D.E.F) = f.hashCode() diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsages.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsages.kt index 11ee92f7dfe..f4a79472e0d 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsages.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsages.kt @@ -49,7 +49,7 @@ interface NotExperimentalExtension : ExperimentalType { fun use(arg: NotExperimentalExtension) { arg.foo() - arg.bar() + arg.bar() } @Marker diff --git a/compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsagesFuture.kt b/compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsagesFuture.kt index 3635d075a13..2ee4ec1c8f9 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsagesFuture.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsagesFuture.kt @@ -49,7 +49,7 @@ interface NotExperimentalExtension : ExperimentalType { fun use(arg: NotExperimentalExtension) { arg.foo() - arg.bar() + arg.bar() } @Marker @@ -84,7 +84,7 @@ object O { operator fun provideDelegate(x: Any?, y: Any?): C = C() } -val x: String by O +val x: String by O @Marker class OperatorContainer : Comparable {