JS: prohibit runtime annotations on external declarations. Warn about runtime annotation in remaining cases. See KT-13895
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class X
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class Y
|
||||
|
||||
@X
|
||||
external class A {
|
||||
@X
|
||||
fun f()
|
||||
|
||||
@X
|
||||
val p: Int
|
||||
|
||||
@get:X
|
||||
val r: Int
|
||||
}
|
||||
|
||||
<!RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION!>@Y<!>
|
||||
external class B {
|
||||
<!RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION!>@Y<!>
|
||||
fun f()
|
||||
|
||||
<!RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION!>@Y<!>
|
||||
val p: Int
|
||||
|
||||
<!RUNTIME_ANNOTATION_ON_EXTERNAL_DECLARATION!>@get:Y<!>
|
||||
val r: Int
|
||||
}
|
||||
|
||||
@X
|
||||
class C {
|
||||
@X
|
||||
fun f() {}
|
||||
|
||||
@X
|
||||
val p: Int = 0
|
||||
|
||||
val q: Int
|
||||
@X get() = 0
|
||||
|
||||
@get:X
|
||||
val r: Int = 0
|
||||
}
|
||||
|
||||
<!RUNTIME_ANNOTATION_NOT_SUPPORTED!>@Y<!>
|
||||
class D {
|
||||
<!RUNTIME_ANNOTATION_NOT_SUPPORTED!>@Y<!>
|
||||
fun f() {}
|
||||
|
||||
<!RUNTIME_ANNOTATION_NOT_SUPPORTED!>@Y<!>
|
||||
val p: Int = 0
|
||||
|
||||
val q: Int
|
||||
<!RUNTIME_ANNOTATION_NOT_SUPPORTED!>@Y<!> get() = 0
|
||||
|
||||
<!RUNTIME_ANNOTATION_NOT_SUPPORTED!>@get:Y<!>
|
||||
val r: Int = 0
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package
|
||||
|
||||
@X public external final class A {
|
||||
public constructor A()
|
||||
@X public final val p: kotlin.Int
|
||||
public final val r: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@X public final fun f(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@Y public external final class B {
|
||||
public constructor B()
|
||||
@Y public final val p: kotlin.Int
|
||||
public final val r: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@Y public final fun f(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@X public final class C {
|
||||
public constructor C()
|
||||
@X public final val p: kotlin.Int = 0
|
||||
public final val q: kotlin.Int
|
||||
public final val r: kotlin.Int = 0
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@X public final fun f(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@Y public final class D {
|
||||
public constructor D()
|
||||
@Y public final val p: kotlin.Int = 0
|
||||
public final val q: kotlin.Int
|
||||
public final val r: kotlin.Int = 0
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
@Y public final fun f(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class X : kotlin.Annotation {
|
||||
public constructor X()
|
||||
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.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class Y : kotlin.Annotation {
|
||||
public constructor Y()
|
||||
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
|
||||
}
|
||||
+2
-2
@@ -30,9 +30,9 @@ class TestBinary {
|
||||
}
|
||||
}
|
||||
|
||||
@AnnotationWithRuntimeRetention
|
||||
<!RUNTIME_ANNOTATION_NOT_SUPPORTED!>@AnnotationWithRuntimeRetention<!>
|
||||
class TestRuntime {
|
||||
@AnnotationWithRuntimeRetention
|
||||
<!RUNTIME_ANNOTATION_NOT_SUPPORTED!>@AnnotationWithRuntimeRetention<!>
|
||||
fun baz(@AnnotationWithRuntimeRetention foo : Int) : Int {
|
||||
return (<!NOT_SUPPORTED!>@AnnotationWithRuntimeRetention 1<!>)
|
||||
}
|
||||
|
||||
@@ -36,6 +36,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLib"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("runtimeAnnotations.kt")
|
||||
public void testRuntimeAnnotations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/runtimeAnnotations.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user