Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/annotations/subclassOptInRequired/UsageOptInIsNotImplied.kt
T
Anastasia.Nekrasova ad9025afa6 [k1/K2]: Mark @SubclassOptInRequired as an experimental
At the moment, SubclassOptInRequired is marked with the
ExperimentalSubclassOptIn annotation. However, it does not work
as expected due to a missing opt-in error. To use SubclassOptInRequired,
an explicit opt-in is necessary because SubclassOptInRequired is an
unstable feature now.

^KT-64739
2024-01-15 14:54:36 +00:00

24 lines
638 B
Kotlin
Vendored

// FIR_IDENTICAL
@file:OptIn(ExperimentalSubclassOptIn::class)
@RequiresOptIn
annotation class ApiMarker
@ApiMarker
class UnstableKlassApi
open class UnstableFunctionApi {
@ApiMarker
open fun overridableFunction() {}
}
@SubclassOptInRequired(ApiMarker::class)
open class NotFullyOptedIntoApiMarker: UnstableFunctionApi() {
init {
// usage is unstable, error is reported even despite SubclassOptInRequired
<!OPT_IN_USAGE_ERROR!>UnstableKlassApi<!>()
}
// usage is unstable, error is reported even despite SubclassOptInRequired
override fun <!OPT_IN_OVERRIDE_ERROR!>overridableFunction<!>() {}
}