xref: /aosp_15_r20/external/ksp/test-utils/testData/api/annotationValue_java.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 // Str
22 // 42
23 // Foo
24 // File
25 // Error type synthetic declaration
26 // Array
27 // @Foo
28 // @Suppress
29 // G
30 // ONE
31 // 31
32 // [warning1, warning 2]
33 // END
34 // FILE: a.kt
35 
36 enum class RGB {
37     R, G, B
38 }
39 
40 annotation class Foo(val s: Int)
41 
42 annotation class Bar(
43     val argStr: String,
44     val argInt: Int,
45     val argClsUser: kotlin.reflect.KClass<*>,
46     val argClsLib: kotlin.reflect.KClass<*>,
47     val argClsLocal: kotlin.reflect.KClass<*>,
48     val argClsArray: kotlin.reflect.KClass<*>,
49     val argAnnoUser: Foo,
50     val argAnnoLib: Suppress,
51     val argEnum: RGB,
52     val argJavaNum: JavaEnum,
53     val argDef: Int = 31
54 )
55 
56 // FILE: C.java
57 
58 @SuppressWarnings({"warning1", "warning 2"})
59 class C {
60 
61 }
62 // FILE: JavaAnnotated.java
63 @Bar(argStr = "Str",
64     argInt = 40 + 2,
65     argClsUser = Foo.class,
66     argClsLib = java.io.File.class,
67     argClsLocal = Local.class, // intentional error type
68     argClsArray = kotlin.Array.class,
69     argAnnoUser = @Foo(s = 17),
70     argAnnoLib = @Suppress(names = {"name1", "name2"}),
71     argEnum = RGB.G,
72     argJavaNum = JavaEnum.ONE)
73 public class JavaAnnotated {}
74 
75 // FILE: JavaEnum.java
76 
77 enum JavaEnum { ONE, TWO, THREE }
78