xref: /aosp_15_r20/external/ksp/test-utils/testData/api/hello.kt (revision af87fb4bb8e3042070d2a054e912924f599b22b7)
1 /*
<lambda>null2  * 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: HelloProcessor
20 // EXPECTED:
21 // 8
22 // AClass
23 // Bar.BBB
24 // Bar.list
25 // C
26 // C.f
27 // C.javaFun
28 // test.Foo
29 // test.ITF
30 // END
31 //FILE: a.kt
32 package test
33 annotation class Anno
34 
35 
36 @Anno
37 class Foo() {
38     val k = "123"
39     var a : String = "123"
40     val aaa : (Int) -> Int = { a -> 1 }
41     fun bar(): Int {
42 //        val aa = 1234
43         return 3
44     }
45 }
46 
47 @Anno
48 interface ITF<T> {
fooITFnull49     fun fooITF() = 1
50 }
51 
52 //FILE: b.kt
53 import test.Anno
54 import test.ITF
55 
56 class Bar<out S, out D>() : ITF<D> {
57     @Anno
58     val list : List<Int>? = null
59     val funInObj = foo()
60     open internal fun foo(c: C, dd: () -> D): Int {
61         val a = 1
62 //        fun <TTT> foo(c: C, dd: () -> TTT): Int {
63 //            return 1
64 //        }
65         return 1
66     }
67     @Anno
68     class BBB {
69         fun <TTA: String> fofo(c: C, dd: () -> TTA): Int {
70             return 1
71         }
72         fun <TTA: Int> fofofo(c: C, dd: () -> TTA): Int {
73             return 1
74         }
75     }
76     val a = 1
77 
78     val kk
79     get() = 1
80 
81     companion object {
82         val s = 1
83         fun foo() = 123
84     }
85 }
86 
87 //FILE: c.kt
88 import test.Anno
89 
90 @Anno
91 class AClass(val a: Int, val b: String, c: Double) {
foonull92     fun foo() = a + b.length + c
93 }
94 
95 fun <D> foo(c: C, dd: () -> D) = 1
96 
97 class CC: C() {}
98 
99 // FILE: C.java
100 import java.util.List;
101 import java.util.ArrayList;
102 import test.Foo;
103 import test.ITF;
104 import test.Anno;
105 
106 @Anno
107 class C {
108     @Anno
109     public Foo f = new Foo();
110     List<? extends ITF> list = new ArrayList<>();
111 
112     @Anno
<lambda>null113     public String javaFun() {
114         return f.k;
115     }
116 }
117