xref: /aosp_15_r20/external/ksp/test-utils/testData/api/referenceElement.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: ReferenceElementProcessor
20 // EXPECTED:
21 // KSClassifierReferenceImpl: Qualifier of B is A
22 // KSClassifierReferenceImpl: Qualifier of C is A
23 // KSClassifierReferenceImpl: Qualifier of Int is null
24 // KSClassifierReferenceImpl: Qualifier of String is null
25 // KSClassifierReferenceDescriptorImpl: Qualifier of Int is null
26 // KSClassifierReferenceDescriptorImpl: Qualifier of String is null
27 // KSClassifierReferenceDescriptorImpl: Qualifier of Y is X
28 // KSClassifierReferenceDescriptorImpl: Qualifier of Z<Int> is X<String>
29 // KSDefNonNullReferenceImpl: Enclosed type of T
30 // KSClassifierReferenceJavaImpl: Qualifier of H is J<String>
31 // KSClassifierReferenceJavaImpl: Qualifier of I is J
32 // KSClassifierReferenceJavaImpl: Qualifier of Object is null
33 // KSClassifierReferenceJavaImpl: Qualifier of Object is null
34 // KSClassifierReferenceJavaImpl: Qualifier of Object is null
35 // KSClassifierReferenceJavaImpl: Qualifier of Object is null
36 // KSClassifierReferenceJavaImpl: Qualifier of String is null
37 // END
38 
39 // MODULE: lib
40 // FILE: lib.kt
41 class X<T1> {
42     class Y
43     inner class Z<T2>
44 }
45 
46 val z: X.Y = X.Y()
47 val w: X<String>.Z<Int> = X<String>().Z<Int>()
48 
49 // MODULE: main(lib)
50 // FILE: reference.kt
51 class A<T1> {
52     class B
53     inner class C<T2>
54 }
55 
56 class DefNonNull<T> {
57     val u: T & Any
58 }
59 
60 val x: A.B = A.B()
61 val y: A<String>.C<Int> = A<String>().C<Int>()
62 
63 // FILE: J.java
64 class J<T> {
65     class H {
66     }
67 
68     static class I {
69     }
70 }
71 
72 class K {
73     J<String>.H x = null;
74     J.I z = null;
75 }
76