xref: /aosp_15_r20/external/ksp/test-utils/testData/api/annotationValue_kt.kt (revision af87fb4bb8e3042070d2a054e912924f599b22b7)
1 /*
2  * Copyright 2020 Google LLC
3  * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 // WITH_RUNTIME
19 // TEST PROCESSOR: AnnotationArgumentProcessor
20 // EXPECTED:
21 // defaultInNested
22 // Str
23 // 42
24 // Foo
25 // File
26 // Local
27 // Array
28 // @Foo
29 // @Suppress
30 // G
31 // ONE
32 // 31
33 // Throws
34 // END
35 // FILE: a.kt
36 
37 enum class RGB {
38     R, G, B
39 }
40 
41 class ThrowsClass {
42     @Throws(Exception::class)
throwsExceptionnull43     protected open fun throwsException() {
44     }
45 }
46 
47 annotation class Foo(val s: Int) {
48     annotation class Nested(val nestedDefault:String = "defaultInNested")
49 }
50 
51 annotation class Bar(
52     val argStr: String,
53     val argInt: Int,
54     val argClsUser: kotlin.reflect.KClass<*>,
55     val argClsLib: kotlin.reflect.KClass<*>,
56     val argClsLocal: kotlin.reflect.KClass<*>,
57     val argClsArray: kotlin.reflect.KClass<*>,
58     val argAnnoUser: Foo,
59     val argAnnoLib: Suppress,
60     val argEnum: RGB,
61     val argJavaNum: JavaEnum,
62     val argDef: Int = 31
63 )
64 
Funnull65 fun Fun() {
66     @Foo.Nested
67     @Bar("Str", 40 + 2, Foo::class, java.io.File::class, Local::class, Array<String>::class, Foo(17), Suppress("name1", "name2"), RGB.G, JavaEnum.ONE)
68     class Local
69 }
70 
71 // FILE: JavaEnum.java
72 
73 enum JavaEnum { ONE, TWO, THREE }
74