Don't report EXPERIMENTAL_OVERRIDE_ERROR on annotated local functions

#KT-31728 Fixed
This commit is contained in:
Mikhail Glukhikh
2021-05-19 16:14:52 +03:00
committed by teamcityserver
parent cb232725f0
commit 7393465696
7 changed files with 65 additions and 2 deletions
@@ -34339,6 +34339,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overrideDifferentExperimentalities.kt");
}
@Test
@TestMetadata("overrideInAnonymousObject.kt")
public void testOverrideInAnonymousObject() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overrideInAnonymousObject.kt");
}
@Test
@TestMetadata("topLevel.kt")
public void testTopLevel() throws Exception {
@@ -34339,6 +34339,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overrideDifferentExperimentalities.kt");
}
@Test
@TestMetadata("overrideInAnonymousObject.kt")
public void testOverrideInAnonymousObject() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overrideInAnonymousObject.kt");
}
@Test
@TestMetadata("topLevel.kt")
public void testTopLevel() throws Exception {
@@ -214,8 +214,7 @@ class ExperimentalUsageChecker(project: Project) : CallChecker {
if (this !is KtDeclaration) return false
val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, this)
return descriptor != null && !DescriptorUtils.isLocal(descriptor) &&
descriptor.annotations.hasAnnotation(annotationFqName)
return descriptor != null && descriptor.annotations.hasAnnotation(annotationFqName)
}
private fun PsiElement.isElementAnnotatedWithUseExperimentalOf(annotationFqName: FqName, bindingContext: BindingContext): Boolean {
@@ -0,0 +1,23 @@
// FIR_IDENTICAL
// !USE_EXPERIMENTAL: kotlin.RequiresOptIn
@RequiresOptIn
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
annotation class MyAnn
interface MyInterface {
@MyAnn
fun foo()
@MyAnn
fun bar()
}
val field = object : MyInterface {
@MyAnn
override fun foo() {}
@OptIn(MyAnn::class)
override fun bar() {}
}
@@ -0,0 +1,18 @@
package
public val field: MyInterface
@kotlin.RequiresOptIn @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) @kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION}) public final annotation class MyAnn : kotlin.Annotation {
public constructor MyAnn()
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 interface MyInterface {
@MyAnn public abstract fun bar(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@MyAnn public abstract fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -34435,6 +34435,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overrideDifferentExperimentalities.kt");
}
@Test
@TestMetadata("overrideInAnonymousObject.kt")
public void testOverrideInAnonymousObject() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overrideInAnonymousObject.kt");
}
@Test
@TestMetadata("topLevel.kt")
public void testTopLevel() throws Exception {
@@ -30151,6 +30151,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overrideDifferentExperimentalities.kt");
}
@TestMetadata("overrideInAnonymousObject.kt")
public void testOverrideInAnonymousObject() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/overrideInAnonymousObject.kt");
}
@TestMetadata("topLevel.kt")
public void testTopLevel() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/experimental/topLevel.kt");