Skip to content

Commit 077919a

Browse files
mpiekutowskiSpace Team
authored andcommitted
[Test] Test reading/writing annotations to common metadata in KLIB compilers
^KT-64237
1 parent 479a21c commit 077919a

10 files changed

+376
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
public final fun R|kotlin/Any|.ff(): R|kotlin/Unit|
2+
3+
field:@PROPERTY_DELEGATE_FIELD:R|test/A|(s = String(delegate)) public final val @RECEIVER:R|test/A|(s = String(property-receiver)) R|kotlin/Any|.pp: R|kotlin/Int|
4+
public get(): R|kotlin/Int|
5+
6+
public final fun topLevel(): R|kotlin/Unit|
7+
8+
@R|kotlin/annotation/Target|(allowedTargets = <implicitArrayOf>(kotlin/annotation/AnnotationTarget.CLASS, kotlin/annotation/AnnotationTarget.TYPE_PARAMETER, kotlin/annotation/AnnotationTarget.PROPERTY, kotlin/annotation/AnnotationTarget.FIELD, kotlin/annotation/AnnotationTarget.LOCAL_VARIABLE, kotlin/annotation/AnnotationTarget.VALUE_PARAMETER, kotlin/annotation/AnnotationTarget.CONSTRUCTOR, kotlin/annotation/AnnotationTarget.FUNCTION, kotlin/annotation/AnnotationTarget.PROPERTY_GETTER, kotlin/annotation/AnnotationTarget.PROPERTY_SETTER, kotlin/annotation/AnnotationTarget.TYPE, kotlin/annotation/AnnotationTarget.TYPEALIAS)) @R|kotlin/annotation/Repeatable|() public final annotation class A : R|kotlin/Annotation| {
9+
public final val s: R|kotlin/String|
10+
public get(): R|kotlin/String|
11+
12+
public constructor(s: R|kotlin/String|): R|test/A|
13+
14+
}
15+
16+
@R|test/A|(s = String(class-1)) @R|test/A|(s = String(class-2)) public final class C<@R|test/A|(s = String(class-type-param)) T> : R|kotlin/Any| {
17+
@R|test/A|(s = String(fun)) public final fun <@R|test/A|(s = String(fun-type-param)) T> f(@R|test/A|(s = String(fun-param-1)) @R|test/A|(s = String(fun-param-2)) r: R|kotlin/Any|): R|@R|test/A|(s = String(return-type)) kotlin/Unit|
18+
19+
@PROPERTY:R|test/A|(s = String(ctor-property)) public final val p: R|kotlin/Int|
20+
public get(): R|kotlin/Int|
21+
22+
@PROPERTY:R|test/A|(s = String(property)) field:@FIELD:R|test/A|(s = String(field)) public final var q: R|kotlin/Int|
23+
@PROPERTY_GETTER:R|test/A|(s = String(getter)) public get(): R|kotlin/Int|
24+
@PROPERTY_SETTER:R|test/A|(s = String(setter)) public set(@R|test/A|(s = String(setparam-1)) @R|test/A|(s = String(setparam-2)) value: R|kotlin/Int|): R|kotlin/Unit|
25+
26+
@R|test/A|(s = String(primary-ctor)) public constructor<@R|test/A|(s = String(class-type-param)) T>(@R|test/A|(s = String(ctor-param)) p: R|kotlin/Int|): R|test/C<T>|
27+
28+
@R|test/A|(s = String(secondary-ctor)) public constructor<@R|test/A|(s = String(class-type-param)) T>(): R|test/C<T>|
29+
30+
@R|test/A|(s = String(nested-class)) public final class Nested : R|kotlin/Any| {
31+
public constructor(): R|test/C.Nested|
32+
33+
}
34+
35+
}
36+
37+
public final enum class E : R|kotlin/Enum<test/E>| {
38+
private constructor(): R|test/E|
39+
40+
@R|test/A|(s = String(enum-entry)) public final static enum entry ENTRY: R|test/E|
41+
public final static fun values(): R|kotlin/Array<test/E>| {
42+
}
43+
44+
public final static fun valueOf(value: R|kotlin/String|): R|test/E| {
45+
}
46+
47+
public final static val entries: R|kotlin/enums/EnumEntries<test/E>|
48+
public get(): R|kotlin/enums/EnumEntries<test/E>|
49+
50+
}
51+
52+
@R|test/A|(s = String(typealias)) public final typealias Z = R|kotlin/String|
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// TARGET_BACKEND: JS_IR, WASM
2+
// PLATFORM_DEPENDANT_METADATA
3+
// LANGUAGE: +KlibAnnotationsInMetadata
4+
5+
package test
6+
7+
import kotlin.annotation.AnnotationTarget.*
8+
9+
@Target(
10+
CLASS,
11+
TYPE_PARAMETER,
12+
PROPERTY,
13+
FIELD,
14+
LOCAL_VARIABLE,
15+
VALUE_PARAMETER,
16+
CONSTRUCTOR,
17+
FUNCTION,
18+
PROPERTY_GETTER,
19+
PROPERTY_SETTER,
20+
TYPE,
21+
TYPEALIAS,
22+
)
23+
24+
@Repeatable
25+
annotation class A(val s: String)
26+
27+
@A("class-1")
28+
@A("class-2")
29+
class C<@A("class-type-param") T> @A("primary-ctor") constructor(
30+
@property:A("ctor-property") @param:A("ctor-param") val p: Int
31+
) {
32+
@A("secondary-ctor") constructor() : this(0)
33+
34+
@A("property")
35+
@field:A("field")
36+
@get:A("getter")
37+
@set:A("setter")
38+
@setparam:A("setparam-2")
39+
var q: Int = 1
40+
set(@A("setparam-1") value) {}
41+
42+
@A("fun")
43+
fun <@A("fun-type-param") T> f(@A("fun-param-1") @A("fun-param-2") r: Any): @A("return-type") Unit {
44+
@A("local-delegated-property-in-class")
45+
val ldp: Int by lazy { 1 }
46+
}
47+
48+
@A("nested-class") class Nested
49+
}
50+
51+
@A("typealias")
52+
typealias Z = String
53+
54+
fun topLevel() {
55+
@A("local-delegated-property-in-file")
56+
val ldp: Int by lazy { 2 }
57+
}
58+
59+
fun @receiver:A("fun-receiver") Any.ff() {}
60+
61+
@delegate:A("delegate")
62+
val @receiver:A("property-receiver") Any.pp: Int by lazy { 3 }
63+
64+
enum class E {
65+
@A("enum-entry") ENTRY,
66+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package test
2+
3+
@delegate:test.A(s = "delegate") public val @receiver:test.A(s = "property-receiver") kotlin.Any.pp: kotlin.Int
4+
public fun @receiver:test.A(s = "property-receiver") kotlin.Any.`<get-pp>`(): kotlin.Int
5+
public fun topLevel(): kotlin.Unit
6+
public fun @receiver:test.A(s = "fun-receiver") kotlin.Any.ff(): kotlin.Unit
7+
8+
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPE, AnnotationTarget.TYPEALIAS}) @kotlin.annotation.Repeatable public final annotation class A : kotlin.Annotation {
9+
/*primary*/ public constructor A(/*0*/ s: kotlin.String)
10+
public final val s: kotlin.String
11+
public final fun `<get-s>`(): kotlin.String
12+
}
13+
14+
@test.A(s = "class-1") @test.A(s = "class-2") public final class C</*0*/ @test.A(s = "class-type-param") T> {
15+
@test.A(s = "secondary-ctor") public constructor C</*0*/ @test.A(s = "class-type-param") T>()
16+
/*primary*/ @test.A(s = "primary-ctor") public constructor C</*0*/ @test.A(s = "class-type-param") T>(/*0*/ @test.A(s = "ctor-param") p: kotlin.Int)
17+
@test.A(s = "ctor-property") public final val p: kotlin.Int
18+
public final fun `<get-p>`(): kotlin.Int
19+
@test.A(s = "property") @field:test.A(s = "field") public final var q: kotlin.Int
20+
@test.A(s = "getter") public final fun `<get-q>`(): kotlin.Int
21+
@test.A(s = "setter") public final fun `<set-q>`(/*0*/ @test.A(s = "setparam-1") @test.A(s = "setparam-2") value: kotlin.Int): kotlin.Unit
22+
@test.A(s = "fun") public final fun </*0*/ @test.A(s = "fun-type-param") T> f(/*0*/ @test.A(s = "fun-param-1") @test.A(s = "fun-param-2") r: kotlin.Any): @test.A(s = "return-type") kotlin.Unit
23+
24+
@test.A(s = "nested-class") public final class Nested {
25+
/*primary*/ public constructor Nested()
26+
}
27+
}
28+
29+
public final enum class E : kotlin.Enum<test.E> {
30+
@test.A(s = "enum-entry") enum entry ENTRY
31+
32+
/*primary*/ private constructor E()
33+
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
34+
public final override /*1*/ /*fake_override*/ fun `<get-name>`(): kotlin.String
35+
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
36+
public final override /*1*/ /*fake_override*/ fun `<get-ordinal>`(): kotlin.Int
37+
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
38+
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.E): kotlin.Int
39+
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
40+
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<test.E!>!
41+
42+
// Static members
43+
public final /*synthesized*/ val entries: kotlin.enums.EnumEntries<test.E>
44+
public final /*synthesized*/ fun `<get-entries>`(): kotlin.enums.EnumEntries<test.E>
45+
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.E
46+
public final /*synthesized*/ fun values(): kotlin.Array<test.E>
47+
}
48+
@test.A(s = "typealias") public typealias Z = kotlin.String
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
public final fun R|kotlin/Any|.ff(): R|kotlin/Unit|
2+
3+
field:@PROPERTY_DELEGATE_FIELD:R|test/A|(s = String(delegate)) public final val @RECEIVER:R|test/A|(s = String(property-receiver)) R|kotlin/Any|.pp: R|kotlin/Int|
4+
public get(): R|kotlin/Int|
5+
6+
public final fun topLevel(): R|kotlin/Unit|
7+
8+
@R|kotlin/annotation/Target|(allowedTargets = <implicitArrayOf>(kotlin/annotation/AnnotationTarget.CLASS, kotlin/annotation/AnnotationTarget.TYPE_PARAMETER, kotlin/annotation/AnnotationTarget.PROPERTY, kotlin/annotation/AnnotationTarget.FIELD, kotlin/annotation/AnnotationTarget.LOCAL_VARIABLE, kotlin/annotation/AnnotationTarget.VALUE_PARAMETER, kotlin/annotation/AnnotationTarget.CONSTRUCTOR, kotlin/annotation/AnnotationTarget.FUNCTION, kotlin/annotation/AnnotationTarget.PROPERTY_GETTER, kotlin/annotation/AnnotationTarget.PROPERTY_SETTER, kotlin/annotation/AnnotationTarget.TYPE, kotlin/annotation/AnnotationTarget.TYPEALIAS)) @R|kotlin/annotation/Repeatable|() public final annotation class A : R|kotlin/Annotation| {
9+
public final val s: R|kotlin/String|
10+
public get(): R|kotlin/String|
11+
12+
public constructor(s: R|kotlin/String|): R|test/A|
13+
14+
}
15+
16+
@R|test/A|(s = String(class-1)) @R|test/A|(s = String(class-2)) public final class C<@R|test/A|(s = String(class-type-param)) T> : R|kotlin/Any| {
17+
@R|test/A|(s = String(fun)) public final fun <@R|test/A|(s = String(fun-type-param)) T> f(@R|test/A|(s = String(fun-param-1)) @R|test/A|(s = String(fun-param-2)) r: R|kotlin/Any|): R|@R|test/A|(s = String(return-type)) kotlin/Unit|
18+
19+
@PROPERTY:R|test/A|(s = String(ctor-property)) public final val p: R|kotlin/Int|
20+
public get(): R|kotlin/Int|
21+
22+
@PROPERTY:R|test/A|(s = String(property)) field:@FIELD:R|test/A|(s = String(field)) public final var q: R|kotlin/Int|
23+
@PROPERTY_GETTER:R|test/A|(s = String(getter)) public get(): R|kotlin/Int|
24+
@PROPERTY_SETTER:R|test/A|(s = String(setter)) public set(@R|test/A|(s = String(setparam-1)) @R|test/A|(s = String(setparam-2)) value: R|kotlin/Int|): R|kotlin/Unit|
25+
26+
@R|test/A|(s = String(primary-ctor)) public constructor<@R|test/A|(s = String(class-type-param)) T>(@R|test/A|(s = String(ctor-param)) p: R|kotlin/Int|): R|test/C<T>|
27+
28+
@R|test/A|(s = String(secondary-ctor)) public constructor<@R|test/A|(s = String(class-type-param)) T>(): R|test/C<T>|
29+
30+
@R|test/A|(s = String(nested-class)) public final class Nested : R|kotlin/Any| {
31+
public constructor(): R|test/C.Nested|
32+
33+
}
34+
35+
}
36+
37+
public final enum class E : R|kotlin/Enum<test/E>| {
38+
private constructor(): R|test/E|
39+
40+
@R|test/A|(s = String(enum-entry)) public final static enum entry ENTRY: R|test/E|
41+
public final static fun values(): R|kotlin/Array<test/E>| {
42+
}
43+
44+
public final static fun valueOf(value: R|kotlin/String|): R|test/E| {
45+
}
46+
47+
public final static val entries: R|kotlin/enums/EnumEntries<test/E>|
48+
public get(): R|kotlin/enums/EnumEntries<test/E>|
49+
50+
}
51+
52+
@R|test/A|(s = String(typealias)) public final typealias Z = R|kotlin/String|
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// TARGET_BACKEND: JS_IR, WASM
2+
// PLATFORM_DEPENDANT_METADATA
3+
// LANGUAGE: -KlibAnnotationsInMetadata
4+
5+
package test
6+
7+
import kotlin.annotation.AnnotationTarget.*
8+
9+
@Target(
10+
CLASS,
11+
TYPE_PARAMETER,
12+
PROPERTY,
13+
FIELD,
14+
LOCAL_VARIABLE,
15+
VALUE_PARAMETER,
16+
CONSTRUCTOR,
17+
FUNCTION,
18+
PROPERTY_GETTER,
19+
PROPERTY_SETTER,
20+
TYPE,
21+
TYPEALIAS,
22+
)
23+
24+
@Repeatable
25+
annotation class A(val s: String)
26+
27+
@A("class-1")
28+
@A("class-2")
29+
class C<@A("class-type-param") T> @A("primary-ctor") constructor(
30+
@property:A("ctor-property") @param:A("ctor-param") val p: Int
31+
) {
32+
@A("secondary-ctor") constructor() : this(0)
33+
34+
@A("property")
35+
@field:A("field")
36+
@get:A("getter")
37+
@set:A("setter")
38+
@setparam:A("setparam-2")
39+
var q: Int = 1
40+
set(@A("setparam-1") value) {}
41+
42+
@A("fun")
43+
fun <@A("fun-type-param") T> f(@A("fun-param-1") @A("fun-param-2") r: Any): @A("return-type") Unit {
44+
@A("local-delegated-property-in-class")
45+
val ldp: Int by lazy { 1 }
46+
}
47+
48+
@A("nested-class") class Nested
49+
}
50+
51+
@A("typealias")
52+
typealias Z = String
53+
54+
fun topLevel() {
55+
@A("local-delegated-property-in-file")
56+
val ldp: Int by lazy { 2 }
57+
}
58+
59+
fun @receiver:A("fun-receiver") Any.ff() {}
60+
61+
@delegate:A("delegate")
62+
val @receiver:A("property-receiver") Any.pp: Int by lazy { 3 }
63+
64+
enum class E {
65+
@A("enum-entry") ENTRY,
66+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package test
2+
3+
@delegate:test.A(s = "delegate") public val @receiver:test.A(s = "property-receiver") kotlin.Any.pp: kotlin.Int
4+
public fun @receiver:test.A(s = "property-receiver") kotlin.Any.`<get-pp>`(): kotlin.Int
5+
public fun topLevel(): kotlin.Unit
6+
public fun @receiver:test.A(s = "fun-receiver") kotlin.Any.ff(): kotlin.Unit
7+
8+
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPE, AnnotationTarget.TYPEALIAS}) @kotlin.annotation.Repeatable public final annotation class A : kotlin.Annotation {
9+
/*primary*/ public constructor A(/*0*/ s: kotlin.String)
10+
public final val s: kotlin.String
11+
public final fun `<get-s>`(): kotlin.String
12+
}
13+
14+
@test.A(s = "class-1") @test.A(s = "class-2") public final class C</*0*/ @test.A(s = "class-type-param") T> {
15+
@test.A(s = "secondary-ctor") public constructor C</*0*/ @test.A(s = "class-type-param") T>()
16+
/*primary*/ @test.A(s = "primary-ctor") public constructor C</*0*/ @test.A(s = "class-type-param") T>(/*0*/ @test.A(s = "ctor-param") p: kotlin.Int)
17+
@test.A(s = "ctor-property") public final val p: kotlin.Int
18+
public final fun `<get-p>`(): kotlin.Int
19+
@test.A(s = "property") @field:test.A(s = "field") public final var q: kotlin.Int
20+
@test.A(s = "getter") public final fun `<get-q>`(): kotlin.Int
21+
@test.A(s = "setter") public final fun `<set-q>`(/*0*/ @test.A(s = "setparam-1") @test.A(s = "setparam-2") value: kotlin.Int): kotlin.Unit
22+
@test.A(s = "fun") public final fun </*0*/ @test.A(s = "fun-type-param") T> f(/*0*/ @test.A(s = "fun-param-1") @test.A(s = "fun-param-2") r: kotlin.Any): @test.A(s = "return-type") kotlin.Unit
23+
24+
@test.A(s = "nested-class") public final class Nested {
25+
/*primary*/ public constructor Nested()
26+
}
27+
}
28+
29+
public final enum class E : kotlin.Enum<test.E> {
30+
@test.A(s = "enum-entry") enum entry ENTRY
31+
32+
/*primary*/ private constructor E()
33+
@kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String
34+
public final override /*1*/ /*fake_override*/ fun `<get-name>`(): kotlin.String
35+
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
36+
public final override /*1*/ /*fake_override*/ fun `<get-ordinal>`(): kotlin.Int
37+
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
38+
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.E): kotlin.Int
39+
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
40+
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<test.E!>!
41+
42+
// Static members
43+
public final /*synthesized*/ val entries: kotlin.enums.EnumEntries<test.E>
44+
public final /*synthesized*/ fun `<get-entries>`(): kotlin.enums.EnumEntries<test.E>
45+
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.E
46+
public final /*synthesized*/ fun values(): kotlin.Array<test.E>
47+
}
48+
@test.A(s = "typealias") public typealias Z = kotlin.String

compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/LoadJavaTestGenerated.java

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/tests-gen/org/jetbrains/kotlin/jvm/compiler/javac/LoadJavaUsingJavacTestGenerated.java

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLoadK2CompiledJsKotlinTestGenerated.java

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)