Make EXPERIMENTAL_API_USAGE_ERR warning till 1.6 for signature type case
This commit is contained in:
+6
@@ -34891,6 +34891,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsages.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitUsagesFuture.kt")
|
||||
public void testImplicitUsagesFuture() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsagesFuture.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importStatement.kt")
|
||||
public void testImportStatement() throws Exception {
|
||||
|
||||
+6
@@ -34891,6 +34891,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsages.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitUsagesFuture.kt")
|
||||
public void testImplicitUsagesFuture() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsagesFuture.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importStatement.kt")
|
||||
public void testImportStatement() throws Exception {
|
||||
|
||||
@@ -276,6 +276,7 @@ public interface Errors {
|
||||
|
||||
DiagnosticFactory2<PsiElement, FqName, String> EXPERIMENTAL_API_USAGE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, FqName, String> EXPERIMENTAL_API_USAGE_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
DiagnosticFactory2<PsiElement, FqName, String> EXPERIMENTAL_API_USAGE_FUTURE_ERROR = DiagnosticFactory2.create(WARNING);
|
||||
|
||||
DiagnosticFactory2<PsiElement, FqName, String> EXPERIMENTAL_OVERRIDE = DiagnosticFactory2.create(WARNING);
|
||||
DiagnosticFactory2<PsiElement, FqName, String> EXPERIMENTAL_OVERRIDE_ERROR = DiagnosticFactory2.create(ERROR);
|
||||
|
||||
+1
@@ -159,6 +159,7 @@ public class DefaultErrorMessages {
|
||||
|
||||
MAP.put(EXPERIMENTAL_API_USAGE, "{1}", TO_STRING, STRING);
|
||||
MAP.put(EXPERIMENTAL_API_USAGE_ERROR, "{1}", TO_STRING, STRING);
|
||||
MAP.put(EXPERIMENTAL_API_USAGE_FUTURE_ERROR, "{1}", TO_STRING, STRING);
|
||||
|
||||
MAP.put(EXPERIMENTAL_OVERRIDE, "{1}", TO_STRING, STRING);
|
||||
MAP.put(EXPERIMENTAL_OVERRIDE_ERROR, "{1}", TO_STRING, STRING);
|
||||
|
||||
+25
-11
@@ -79,7 +79,8 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
|
||||
data class ExperimentalityDiagnostics(
|
||||
val warning: ExperimentalityDiagnostic,
|
||||
val error: ExperimentalityDiagnostic
|
||||
val error: ExperimentalityDiagnostic,
|
||||
val futureError: ExperimentalityDiagnostic
|
||||
)
|
||||
|
||||
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
|
||||
@@ -131,7 +132,11 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
error = ExperimentalityDiagnostic2(
|
||||
Errors.EXPERIMENTAL_API_USAGE_ERROR,
|
||||
getDefaultDiagnosticMessage("This declaration is experimental and its usage must be marked")
|
||||
)
|
||||
),
|
||||
futureError = ExperimentalityDiagnostic2(
|
||||
Errors.EXPERIMENTAL_API_USAGE_FUTURE_ERROR,
|
||||
getDefaultDiagnosticMessage("This declaration is experimental due to signature types and its usage must be marked (will become an error in 1.6)")
|
||||
),
|
||||
)
|
||||
|
||||
fun reportNotAcceptedExperimentalities(
|
||||
@@ -154,6 +159,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
val diagnostic = when (severity) {
|
||||
Experimentality.Severity.WARNING -> diagnostics.warning
|
||||
Experimentality.Severity.ERROR -> diagnostics.error
|
||||
Experimentality.Severity.FUTURE_ERROR -> diagnostics.futureError
|
||||
}
|
||||
diagnostic.report(trace, element, annotationFqName, message)
|
||||
}
|
||||
@@ -163,19 +169,20 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
fun DeclarationDescriptor.loadExperimentalities(
|
||||
moduleAnnotationsResolver: ModuleAnnotationsResolver,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
visited: MutableSet<DeclarationDescriptor> = mutableSetOf()
|
||||
visited: MutableSet<DeclarationDescriptor> = mutableSetOf(),
|
||||
useFutureError: Boolean = false
|
||||
): Set<Experimentality> {
|
||||
if (!visited.add(this)) return emptySet()
|
||||
val result = SmartSet.create<Experimentality>()
|
||||
if (this is CallableMemberDescriptor && kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
for (overridden in overriddenDescriptors) {
|
||||
result.addAll(overridden.loadExperimentalities(moduleAnnotationsResolver, languageVersionSettings, visited))
|
||||
result.addAll(overridden.loadExperimentalities(moduleAnnotationsResolver, languageVersionSettings, visited, useFutureError))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
for (annotation in annotations) {
|
||||
result.addIfNotNull(annotation.annotationClass?.loadExperimentalityForMarkerAnnotation())
|
||||
result.addIfNotNull(annotation.annotationClass?.loadExperimentalityForMarkerAnnotation(useFutureError))
|
||||
}
|
||||
|
||||
if (this is CallableDescriptor && this !is ClassConstructorDescriptor) {
|
||||
@@ -211,7 +218,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
|
||||
val container = containingDeclaration
|
||||
if (container is ClassDescriptor && this !is ConstructorDescriptor) {
|
||||
result.addAll(container.loadExperimentalities(moduleAnnotationsResolver, languageVersionSettings, visited))
|
||||
result.addAll(container.loadExperimentalities(moduleAnnotationsResolver, languageVersionSettings, visited, useFutureError))
|
||||
}
|
||||
|
||||
for (moduleAnnotationClassId in moduleAnnotationsResolver.getAnnotationsOnContainingModule(this)) {
|
||||
@@ -230,19 +237,21 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
when {
|
||||
this?.isError != false -> emptySet()
|
||||
this is AbbreviatedType -> abbreviation.constructor.declarationDescriptor?.loadExperimentalities(
|
||||
moduleAnnotationsResolver, languageVersionSettings, visitedClassifiers
|
||||
moduleAnnotationsResolver, languageVersionSettings, visitedClassifiers,
|
||||
useFutureError = !languageVersionSettings.supportsFeature(LanguageFeature.OptInContagiousSignatures)
|
||||
).orEmpty() + expandedType.loadExperimentalities(
|
||||
moduleAnnotationsResolver, languageVersionSettings, visitedClassifiers
|
||||
)
|
||||
else -> constructor.declarationDescriptor?.loadExperimentalities(
|
||||
moduleAnnotationsResolver, languageVersionSettings, visitedClassifiers
|
||||
moduleAnnotationsResolver, languageVersionSettings, visitedClassifiers,
|
||||
useFutureError = !languageVersionSettings.supportsFeature(LanguageFeature.OptInContagiousSignatures)
|
||||
).orEmpty() + arguments.flatMap {
|
||||
if (it.isStarProjection) emptySet()
|
||||
else it.type.loadExperimentalities(moduleAnnotationsResolver, languageVersionSettings, visitedClassifiers)
|
||||
}
|
||||
}
|
||||
|
||||
internal fun ClassDescriptor.loadExperimentalityForMarkerAnnotation(): Experimentality? {
|
||||
internal fun ClassDescriptor.loadExperimentalityForMarkerAnnotation(useFutureError: Boolean = false): Experimentality? {
|
||||
val experimental =
|
||||
annotations.findAnnotation(REQUIRES_OPT_IN_FQ_NAME)
|
||||
?: annotations.findAnnotation(OLD_EXPERIMENTAL_FQ_NAME)
|
||||
@@ -251,8 +260,12 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
val arguments = experimental.allValueArguments
|
||||
val severity = when ((arguments[LEVEL] as? EnumValue)?.enumEntryName) {
|
||||
WARNING_LEVEL -> Experimentality.Severity.WARNING
|
||||
ERROR_LEVEL -> Experimentality.Severity.ERROR
|
||||
else -> Experimentality.DEFAULT_SEVERITY
|
||||
ERROR_LEVEL -> if (useFutureError) Experimentality.Severity.FUTURE_ERROR else Experimentality.Severity.ERROR
|
||||
else -> if (Experimentality.DEFAULT_SEVERITY == Experimentality.Severity.ERROR && useFutureError) {
|
||||
Experimentality.Severity.FUTURE_ERROR
|
||||
} else {
|
||||
Experimentality.DEFAULT_SEVERITY
|
||||
}
|
||||
}
|
||||
|
||||
val message = (arguments[MESSAGE] as? StringValue)?.value
|
||||
@@ -457,6 +470,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
|
||||
val (diagnostic, defaultMessageVerb) = when (experimentality.severity) {
|
||||
Experimentality.Severity.WARNING -> Errors.EXPERIMENTAL_OVERRIDE to "should"
|
||||
Experimentality.Severity.ERROR -> Errors.EXPERIMENTAL_OVERRIDE_ERROR to "must"
|
||||
Experimentality.Severity.FUTURE_ERROR -> Errors.EXPERIMENTAL_OVERRIDE_ERROR to "must"
|
||||
}
|
||||
val message = experimentality.message
|
||||
?: "This declaration overrides experimental member of supertype " +
|
||||
|
||||
+2
-1
@@ -342,7 +342,8 @@ class ConstantExpressionEvaluator(
|
||||
|
||||
private val EXPERIMENTAL_UNSIGNED_LITERALS_DIAGNOSTICS = ExperimentalUsageChecker.ExperimentalityDiagnostics(
|
||||
warning = ExperimentalityDiagnostic1(Errors.EXPERIMENTAL_UNSIGNED_LITERALS, "should"),
|
||||
error = ExperimentalityDiagnostic1(Errors.EXPERIMENTAL_UNSIGNED_LITERALS_ERROR, "must")
|
||||
error = ExperimentalityDiagnostic1(Errors.EXPERIMENTAL_UNSIGNED_LITERALS_ERROR, "must"),
|
||||
futureError = ExperimentalityDiagnostic1(Errors.EXPERIMENTAL_UNSIGNED_LITERALS_ERROR, "must"),
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR -UNUSED_PARAMETER
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR -EXPERIMENTAL_API_USAGE_FUTURE_ERROR -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.contracts.*
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR -UNUSED_PARAMETER
|
||||
// !DIAGNOSTICS: -EXPERIMENTAL_API_USAGE_ERROR -EXPERIMENTAL_API_USAGE_FUTURE_ERROR -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.contracts.*
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR")
|
||||
inline fun atLeastOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
@@ -8,7 +8,7 @@ inline fun atLeastOnce(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR")
|
||||
inline fun atMostOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
|
||||
@@ -16,7 +16,7 @@ inline fun atMostOnce(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR")
|
||||
inline fun exactlyOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR")
|
||||
inline fun atLeastOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_LEAST_ONCE)
|
||||
@@ -8,7 +8,7 @@ inline fun atLeastOnce(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR")
|
||||
inline fun atMostOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
|
||||
@@ -16,7 +16,7 @@ inline fun atMostOnce(block: () -> Unit) {
|
||||
block()
|
||||
}
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR")
|
||||
inline fun exactlyOnce(block: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
package
|
||||
|
||||
@kotlin.Suppress(names = {"EXPERIMENTAL_API_USAGE_ERROR"}) public inline fun atLeastOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
|
||||
@kotlin.Suppress(names = {"EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR"}) public inline fun atLeastOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
|
||||
CallsInPlace(block, AT_LEAST_ONCE)
|
||||
|
||||
@kotlin.Suppress(names = {"EXPERIMENTAL_API_USAGE_ERROR"}) public inline fun atMostOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
|
||||
@kotlin.Suppress(names = {"EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR"}) public inline fun atMostOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
|
||||
CallsInPlace(block, AT_MOST_ONCE)
|
||||
|
||||
@kotlin.Suppress(names = {"EXPERIMENTAL_API_USAGE_ERROR"}) public inline fun exactlyOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
|
||||
@kotlin.Suppress(names = {"EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR"}) public inline fun exactlyOnce(/*0*/ block: () -> kotlin.Unit): kotlin.Unit
|
||||
CallsInPlace(block, EXACTLY_ONCE)
|
||||
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR")
|
||||
fun foo(f1: () -> Unit, f2: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(f1, InvocationKind.EXACTLY_ONCE)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import kotlin.contracts.*
|
||||
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR")
|
||||
@Suppress("EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR")
|
||||
fun foo(f1: () -> Unit, f2: () -> Unit) {
|
||||
contract {
|
||||
callsInPlace(f1, InvocationKind.EXACTLY_ONCE)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
@kotlin.Suppress(names = {"EXPERIMENTAL_API_USAGE_ERROR"}) public fun foo(/*0*/ f1: () -> kotlin.Unit, /*1*/ f2: () -> kotlin.Unit): kotlin.Unit
|
||||
@kotlin.Suppress(names = {"EXPERIMENTAL_API_USAGE_ERROR", "EXPERIMENTAL_API_USAGE_FUTURE_ERROR"}) public fun foo(/*0*/ f1: () -> kotlin.Unit, /*1*/ f2: () -> kotlin.Unit): kotlin.Unit
|
||||
CallsInPlace(f1, EXACTLY_ONCE)
|
||||
CallsInPlace(f2, EXACTLY_ONCE)
|
||||
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// LANGUAGE: +OptInContagiousSignatures
|
||||
|
||||
@RequiresOptIn
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// LANGUAGE: +OptInContagiousSignatures
|
||||
|
||||
@RequiresOptIn
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// LANGUAGE: -OptInContagiousSignatures
|
||||
|
||||
@RequiresOptIn
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS)
|
||||
annotation class Marker
|
||||
|
||||
@Marker
|
||||
interface Some
|
||||
|
||||
abstract class User {
|
||||
abstract fun createSome(): <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>
|
||||
fun <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>?.onSome() {}
|
||||
fun withSome(some: <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>? = null) {}
|
||||
|
||||
fun use() {
|
||||
val something = <!EXPERIMENTAL_API_USAGE_ERROR!>createSome<!>()
|
||||
val somethingOther: <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!> = <!EXPERIMENTAL_API_USAGE_ERROR!>createSome<!>()
|
||||
null.<!EXPERIMENTAL_API_USAGE_ERROR!>onSome<!>()
|
||||
<!EXPERIMENTAL_API_USAGE_ERROR!>withSome<!>()
|
||||
}
|
||||
}
|
||||
|
||||
data class DataClass(@property:Marker val x: Int)
|
||||
|
||||
fun useDataClass(d: DataClass) {
|
||||
// Should have error in both
|
||||
d.<!EXPERIMENTAL_API_USAGE_ERROR!>x<!>
|
||||
val (x) = d
|
||||
}
|
||||
|
||||
typealias My = <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>
|
||||
|
||||
fun my(my: <!EXPERIMENTAL_API_USAGE_ERROR!>My<!>) {}
|
||||
|
||||
fun your(my: <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>) {}
|
||||
|
||||
@Marker
|
||||
interface ExperimentalType {
|
||||
fun foo() {}
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
@OptIn(Marker::class)
|
||||
interface NotExperimentalExtension : ExperimentalType {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
fun use(arg: NotExperimentalExtension) {
|
||||
arg.foo()
|
||||
arg.<!EXPERIMENTAL_API_USAGE_ERROR!>bar<!>()
|
||||
}
|
||||
|
||||
@Marker
|
||||
interface I
|
||||
|
||||
@OptIn(Marker::class)
|
||||
class A : I
|
||||
|
||||
@OptIn(Marker::class)
|
||||
class B : I
|
||||
|
||||
@OptIn(Marker::class)
|
||||
typealias MyList = ArrayList<I>
|
||||
|
||||
@Marker
|
||||
typealias YourList = ArrayList<String>
|
||||
|
||||
fun main() {
|
||||
val x = <!EXPERIMENTAL_API_USAGE_ERROR!>listOf<!>(A(), B())
|
||||
val y = MyList()
|
||||
val z = YourList()
|
||||
YourList().add("")
|
||||
}
|
||||
|
||||
@Marker
|
||||
class C {
|
||||
operator fun getValue(x: Any?, y: Any?): String = ""
|
||||
}
|
||||
|
||||
object O {
|
||||
@OptIn(Marker::class)
|
||||
operator fun provideDelegate(x: Any?, y: Any?): C = C()
|
||||
}
|
||||
|
||||
val x: String by <!EXPERIMENTAL_API_USAGE_ERROR!>O<!>
|
||||
|
||||
@Marker
|
||||
class OperatorContainer : Comparable<OperatorContainer> {
|
||||
@OptIn(Marker::class)
|
||||
override fun compareTo(other: OperatorContainer): Int {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(Marker::class)
|
||||
class AnotherContainer : Iterable<C> {
|
||||
@OptIn(Marker::class)
|
||||
override fun iterator(): Iterator<C> {
|
||||
return object : Iterator<C> {
|
||||
override fun hasNext(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun next(): C {
|
||||
throw java.util.NoSuchElementException()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(Marker::class)
|
||||
operator fun String.minus(s: String) = OperatorContainer()
|
||||
|
||||
@OptIn(Marker::class)
|
||||
operator fun String.invoke() = OperatorContainer()
|
||||
|
||||
fun operatorContainerUsage(s: String, a: AnotherContainer) {
|
||||
val res1 = s <!EXPERIMENTAL_API_USAGE_ERROR!>-<!> s
|
||||
val res2 = <!EXPERIMENTAL_API_USAGE_ERROR!>s<!>()
|
||||
val res3 = <!EXPERIMENTAL_API_USAGE_ERROR!>res1<!> <!EXPERIMENTAL_API_USAGE_ERROR!>><!> <!EXPERIMENTAL_API_USAGE_ERROR!>res2<!>
|
||||
<!EXPERIMENTAL_API_USAGE_ERROR, EXPERIMENTAL_API_USAGE_ERROR, EXPERIMENTAL_API_USAGE_ERROR, EXPERIMENTAL_API_USAGE_ERROR!>for (c in a) {}<!>
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
|
||||
// LANGUAGE: -OptInContagiousSignatures
|
||||
|
||||
@RequiresOptIn
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS)
|
||||
annotation class Marker
|
||||
|
||||
@Marker
|
||||
interface Some
|
||||
|
||||
abstract class User {
|
||||
abstract fun createSome(): <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>
|
||||
fun <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>?.onSome() {}
|
||||
fun withSome(some: <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>? = null) {}
|
||||
|
||||
fun use() {
|
||||
val something = <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>createSome<!>()
|
||||
val somethingOther: <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!> = <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>createSome<!>()
|
||||
null.<!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>onSome<!>()
|
||||
<!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>withSome<!>()
|
||||
}
|
||||
}
|
||||
|
||||
data class DataClass(@property:Marker val x: Int)
|
||||
|
||||
fun useDataClass(d: DataClass) {
|
||||
// Should have error in both
|
||||
d.<!EXPERIMENTAL_API_USAGE_ERROR!>x<!>
|
||||
val (<!EXPERIMENTAL_API_USAGE_ERROR!>x<!>) = d
|
||||
}
|
||||
|
||||
typealias My = <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>
|
||||
|
||||
fun my(my: <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>My<!>) {}
|
||||
|
||||
fun your(my: <!EXPERIMENTAL_API_USAGE_ERROR!>Some<!>) {}
|
||||
|
||||
@Marker
|
||||
interface ExperimentalType {
|
||||
fun foo() {}
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
@OptIn(Marker::class)
|
||||
interface NotExperimentalExtension : ExperimentalType {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
fun use(arg: NotExperimentalExtension) {
|
||||
arg.foo()
|
||||
arg.<!EXPERIMENTAL_API_USAGE_ERROR!>bar<!>()
|
||||
}
|
||||
|
||||
@Marker
|
||||
interface I
|
||||
|
||||
@OptIn(Marker::class)
|
||||
class A : I
|
||||
|
||||
@OptIn(Marker::class)
|
||||
class B : I
|
||||
|
||||
@OptIn(Marker::class)
|
||||
typealias MyList = ArrayList<I>
|
||||
|
||||
@Marker
|
||||
typealias YourList = ArrayList<String>
|
||||
|
||||
fun main() {
|
||||
val x = <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>listOf<!>(A(), B())
|
||||
val y = <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>MyList<!>()
|
||||
val z = <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>YourList<!>()
|
||||
<!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>YourList<!>().add("")
|
||||
}
|
||||
|
||||
@Marker
|
||||
class C {
|
||||
operator fun getValue(x: Any?, y: Any?): String = ""
|
||||
}
|
||||
|
||||
object O {
|
||||
@OptIn(Marker::class)
|
||||
operator fun provideDelegate(x: Any?, y: Any?): C = C()
|
||||
}
|
||||
|
||||
val x: String by <!EXPERIMENTAL_API_USAGE_ERROR, EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>O<!>
|
||||
|
||||
@Marker
|
||||
class OperatorContainer : Comparable<OperatorContainer> {
|
||||
@OptIn(Marker::class)
|
||||
override fun compareTo(other: OperatorContainer): Int {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(Marker::class)
|
||||
class AnotherContainer : Iterable<C> {
|
||||
@OptIn(Marker::class)
|
||||
override fun iterator(): Iterator<C> {
|
||||
return object : Iterator<C> {
|
||||
override fun hasNext(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun next(): C {
|
||||
throw java.util.NoSuchElementException()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(Marker::class)
|
||||
operator fun String.minus(s: String) = OperatorContainer()
|
||||
|
||||
@OptIn(Marker::class)
|
||||
operator fun String.invoke() = OperatorContainer()
|
||||
|
||||
fun operatorContainerUsage(s: String, a: AnotherContainer) {
|
||||
val res1 = s <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>-<!> s
|
||||
val res2 = <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>s<!>()
|
||||
val res3 = <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>res1<!> <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>><!> <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>res2<!>
|
||||
for (c in <!EXPERIMENTAL_API_USAGE_FUTURE_ERROR!>a<!>) {}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package
|
||||
|
||||
public val x: kotlin.String
|
||||
public fun main(): kotlin.Unit
|
||||
public fun my(/*0*/ my: My /* = Some */): kotlin.Unit
|
||||
public fun operatorContainerUsage(/*0*/ s: kotlin.String, /*1*/ a: AnotherContainer): kotlin.Unit
|
||||
public fun use(/*0*/ arg: NotExperimentalExtension): kotlin.Unit
|
||||
public fun useDataClass(/*0*/ d: DataClass): kotlin.Unit
|
||||
public fun your(/*0*/ my: Some): kotlin.Unit
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public operator fun kotlin.String.invoke(): OperatorContainer
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public operator fun kotlin.String.minus(/*0*/ s: kotlin.String): OperatorContainer
|
||||
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public final class A : I {
|
||||
public constructor A()
|
||||
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.OptIn(markerClass = {Marker::class}) public final class AnotherContainer : kotlin.collections.Iterable<C> {
|
||||
public constructor AnotherContainer()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public open override /*1*/ fun iterator(): kotlin.collections.Iterator<C>
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public final class B : I {
|
||||
public constructor B()
|
||||
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
|
||||
}
|
||||
|
||||
@Marker public final class C {
|
||||
public constructor C()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final operator fun getValue(/*0*/ x: kotlin.Any?, /*1*/ y: kotlin.Any?): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final data class DataClass {
|
||||
public constructor DataClass(/*0*/ x: kotlin.Int)
|
||||
@Marker public final val x: kotlin.Int
|
||||
public final operator /*synthesized*/ fun component1(): kotlin.Int
|
||||
public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): DataClass
|
||||
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@Marker public interface ExperimentalType {
|
||||
public open fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@Marker public interface I {
|
||||
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.RequiresOptIn @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.TYPEALIAS}) public final annotation class Marker : kotlin.Annotation {
|
||||
public constructor Marker()
|
||||
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.OptIn(markerClass = {Marker::class}) public interface NotExperimentalExtension : ExperimentalType {
|
||||
public open override /*1*/ /*fake_override*/ fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public object O {
|
||||
private constructor O()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public final operator fun provideDelegate(/*0*/ x: kotlin.Any?, /*1*/ y: kotlin.Any?): C
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@Marker public final class OperatorContainer : kotlin.Comparable<OperatorContainer> {
|
||||
public constructor OperatorContainer()
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public open override /*1*/ fun compareTo(/*0*/ other: OperatorContainer): kotlin.Int
|
||||
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
|
||||
}
|
||||
|
||||
@Marker public interface Some {
|
||||
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 abstract class User {
|
||||
public constructor User()
|
||||
public abstract fun createSome(): Some
|
||||
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
|
||||
public final fun withSome(/*0*/ some: Some? = ...): kotlin.Unit
|
||||
public final fun Some?.onSome(): kotlin.Unit
|
||||
}
|
||||
public typealias My = Some
|
||||
@kotlin.OptIn(markerClass = {Marker::class}) public typealias MyList = kotlin.collections.ArrayList<I>
|
||||
@Marker public typealias YourList = kotlin.collections.ArrayList<kotlin.String>
|
||||
Generated
+6
@@ -34987,6 +34987,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsages.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitUsagesFuture.kt")
|
||||
public void testImplicitUsagesFuture() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsagesFuture.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importStatement.kt")
|
||||
public void testImportStatement() throws Exception {
|
||||
|
||||
@@ -217,6 +217,7 @@ enum class LanguageFeature(
|
||||
WarnAboutNonExhaustiveWhenOnAlgebraicTypes(KOTLIN_1_6, kind = BUG_FIX),
|
||||
InstantiationOfAnnotationClasses(KOTLIN_1_6),
|
||||
OptInOnOverrideForbidden(KOTLIN_1_6, kind = BUG_FIX),
|
||||
OptInContagiousSignatures(KOTLIN_1_6, kind = BUG_FIX),
|
||||
|
||||
// 1.7
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
data class Experimentality(val annotationFqName: FqName, val severity: Severity, val message: String?) {
|
||||
enum class Severity { WARNING, ERROR }
|
||||
enum class Severity { WARNING, ERROR, FUTURE_ERROR }
|
||||
|
||||
companion object {
|
||||
val DEFAULT_SEVERITY = Severity.ERROR
|
||||
|
||||
+6
@@ -34891,6 +34891,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsages.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitUsagesFuture.kt")
|
||||
public void testImplicitUsagesFuture() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/implicitUsagesFuture.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("importStatement.kt")
|
||||
public void testImportStatement() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user