1*af87fb4bSXin Li /*
2*af87fb4bSXin Li * Copyright 2022 Google LLC
3*af87fb4bSXin Li * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
4*af87fb4bSXin Li *
5*af87fb4bSXin Li * Licensed under the Apache License, Version 2.0 (the "License");
6*af87fb4bSXin Li * you may not use this file except in compliance with the License.
7*af87fb4bSXin Li * You may obtain a copy of the License at
8*af87fb4bSXin Li *
9*af87fb4bSXin Li * http://www.apache.org/licenses/LICENSE-2.0
10*af87fb4bSXin Li *
11*af87fb4bSXin Li * Unless required by applicable law or agreed to in writing, software
12*af87fb4bSXin Li * distributed under the License is distributed on an "AS IS" BASIS,
13*af87fb4bSXin Li * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*af87fb4bSXin Li * See the License for the specific language governing permissions and
15*af87fb4bSXin Li * limitations under the License.
16*af87fb4bSXin Li */
17*af87fb4bSXin Li
18*af87fb4bSXin Li // WITH_RUNTIME
19*af87fb4bSXin Li // TEST PROCESSOR: AsMemberOfProcessor
20*af87fb4bSXin Li // EXPECTED:
21*af87fb4bSXin Li // Child1!!
22*af87fb4bSXin Li // intType: kotlin.Int!!
23*af87fb4bSXin Li // baseTypeArg1: kotlin.Int!!
24*af87fb4bSXin Li // baseTypeArg2: kotlin.String?
25*af87fb4bSXin Li // typePair: kotlin.Pair!!<kotlin.String?, kotlin.Int!!>
26*af87fb4bSXin Li // errorType: <Error>?
27*af87fb4bSXin Li // extensionProperty: kotlin.String?
28*af87fb4bSXin Li // returnInt: () -> kotlin.Int!!
29*af87fb4bSXin Li // returnArg1: () -> kotlin.Int!!
30*af87fb4bSXin Li // returnArg1Nullable: () -> kotlin.Int?
31*af87fb4bSXin Li // returnArg2: () -> kotlin.String?
32*af87fb4bSXin Li // returnArg2Nullable: () -> kotlin.String?
33*af87fb4bSXin Li // receiveArgs: (kotlin.Int?, kotlin.Int!!, kotlin.String?) -> kotlin.Unit!!
34*af87fb4bSXin Li // receiveArgsPair: (kotlin.Pair!!<kotlin.Int!!, kotlin.String?>, kotlin.Pair?<kotlin.Int?, kotlin.String?>) -> kotlin.Unit!!
35*af87fb4bSXin Li // functionArgType: <BaseTypeArg1: kotlin.Any?>(Base.functionArgType.BaseTypeArg1?) -> kotlin.String?
36*af87fb4bSXin Li // functionArgTypeWithBounds: <in T: kotlin.Int!!>(Base.functionArgTypeWithBounds.T?) -> kotlin.String?
37*af87fb4bSXin Li // extensionFunction: kotlin.Int!!.() -> kotlin.Int?
38*af87fb4bSXin Li // Child2!!<kotlin.Any?>
39*af87fb4bSXin Li // intType: kotlin.Int!!
40*af87fb4bSXin Li // baseTypeArg1: kotlin.Any?
41*af87fb4bSXin Li // baseTypeArg2: kotlin.Any?
42*af87fb4bSXin Li // typePair: kotlin.Pair!!<kotlin.Any?, kotlin.Any?>
43*af87fb4bSXin Li // errorType: <Error>?
44*af87fb4bSXin Li // extensionProperty: kotlin.Any?
45*af87fb4bSXin Li // returnInt: () -> kotlin.Int!!
46*af87fb4bSXin Li // returnArg1: () -> kotlin.Any?
47*af87fb4bSXin Li // returnArg1Nullable: () -> kotlin.Any?
48*af87fb4bSXin Li // returnArg2: () -> kotlin.Any?
49*af87fb4bSXin Li // returnArg2Nullable: () -> kotlin.Any?
50*af87fb4bSXin Li // receiveArgs: (kotlin.Int?, kotlin.Any?, kotlin.Any?) -> kotlin.Unit!!
51*af87fb4bSXin Li // receiveArgsPair: (kotlin.Pair!!<kotlin.Any?, kotlin.Any?>, kotlin.Pair?<kotlin.Any?, kotlin.Any?>) -> kotlin.Unit!!
52*af87fb4bSXin Li // functionArgType: <BaseTypeArg1: kotlin.Any?>(Base.functionArgType.BaseTypeArg1?) -> kotlin.Any?
53*af87fb4bSXin Li // functionArgTypeWithBounds: <in T: kotlin.Any?>(Base.functionArgTypeWithBounds.T?) -> kotlin.Any?
54*af87fb4bSXin Li // extensionFunction: kotlin.Any?.() -> kotlin.Any?
55*af87fb4bSXin Li // Child2!!<kotlin.String!!>
56*af87fb4bSXin Li // intType: kotlin.Int!!
57*af87fb4bSXin Li // baseTypeArg1: kotlin.String!!
58*af87fb4bSXin Li // baseTypeArg2: kotlin.String?
59*af87fb4bSXin Li // typePair: kotlin.Pair!!<kotlin.String?, kotlin.String!!>
60*af87fb4bSXin Li // errorType: <Error>?
61*af87fb4bSXin Li // extensionProperty: kotlin.String?
62*af87fb4bSXin Li // returnInt: () -> kotlin.Int!!
63*af87fb4bSXin Li // returnArg1: () -> kotlin.String!!
64*af87fb4bSXin Li // returnArg1Nullable: () -> kotlin.String?
65*af87fb4bSXin Li // returnArg2: () -> kotlin.String?
66*af87fb4bSXin Li // returnArg2Nullable: () -> kotlin.String?
67*af87fb4bSXin Li // receiveArgs: (kotlin.Int?, kotlin.String!!, kotlin.String?) -> kotlin.Unit!!
68*af87fb4bSXin Li // receiveArgsPair: (kotlin.Pair!!<kotlin.String!!, kotlin.String?>, kotlin.Pair?<kotlin.String?, kotlin.String?>) -> kotlin.Unit!!
69*af87fb4bSXin Li // functionArgType: <BaseTypeArg1: kotlin.Any?>(Base.functionArgType.BaseTypeArg1?) -> kotlin.String?
70*af87fb4bSXin Li // functionArgTypeWithBounds: <in T: kotlin.String!!>(Base.functionArgTypeWithBounds.T?) -> kotlin.String?
71*af87fb4bSXin Li // extensionFunction: kotlin.String!!.() -> kotlin.String?
72*af87fb4bSXin Li // NotAChild!!
73*af87fb4bSXin Li // intType: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `intType` (Base)
74*af87fb4bSXin Li // baseTypeArg1: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `baseTypeArg1` (Base)
75*af87fb4bSXin Li // baseTypeArg2: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `baseTypeArg2` (Base)
76*af87fb4bSXin Li // typePair: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `typePair` (Base)
77*af87fb4bSXin Li // errorType: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `errorType` (Base)
78*af87fb4bSXin Li // extensionProperty: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `extensionProperty` (Base)
79*af87fb4bSXin Li // returnInt: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnInt` (Base)
80*af87fb4bSXin Li // returnArg1: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnArg1` (Base)
81*af87fb4bSXin Li // returnArg1Nullable: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnArg1Nullable` (Base)
82*af87fb4bSXin Li // returnArg2: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnArg2` (Base)
83*af87fb4bSXin Li // returnArg2Nullable: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnArg2Nullable` (Base)
84*af87fb4bSXin Li // receiveArgs: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `receiveArgs` (Base)
85*af87fb4bSXin Li // receiveArgsPair: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `receiveArgsPair` (Base)
86*af87fb4bSXin Li // functionArgType: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `functionArgType` (Base)
87*af87fb4bSXin Li // functionArgTypeWithBounds: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `functionArgTypeWithBounds` (Base)
88*af87fb4bSXin Li // extensionFunction: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `extensionFunction` (Base)
89*af87fb4bSXin Li // List#get
90*af87fb4bSXin Li // listOfStrings: (kotlin.Int!!) -> kotlin.String!!
91*af87fb4bSXin Li // setOfStrings: java.lang.IllegalArgumentException: Set<String> is not a sub type of the class/interface that contains `get` (List)
92*af87fb4bSXin Li // Set#contains
93*af87fb4bSXin Li // listOfStrings: java.lang.IllegalArgumentException: List<String> is not a sub type of the class/interface that contains `contains` (Set)
94*af87fb4bSXin Li // setOfStrings: (kotlin.String!!) -> kotlin.Boolean!!
95*af87fb4bSXin Li // JavaChild1!!
96*af87fb4bSXin Li // intType: kotlin.Int!!
97*af87fb4bSXin Li // typeArg1: kotlin.String
98*af87fb4bSXin Li // typeArg2: kotlin.Int
99*af87fb4bSXin Li // errorType: <Error>?
100*af87fb4bSXin Li // returnArg1: () -> kotlin.Int
101*af87fb4bSXin Li // receiveArgs: (kotlin.String, kotlin.Int, kotlin.Int!!) -> kotlin.Unit!!
102*af87fb4bSXin Li // methodArgType: <BaseTypeArg1: kotlin.Any>(JavaBase.methodArgType.BaseTypeArg1, kotlin.Int) -> kotlin.Unit!!
103*af87fb4bSXin Li // methodArgTypeWithBounds: <T: kotlin.String>(JavaBase.methodArgTypeWithBounds.T) -> kotlin.Unit!!
104*af87fb4bSXin Li // fileLevelFunction: java.lang.IllegalArgumentException: Cannot call asMemberOf with a function that is not declared in a class or an interface
105*af87fb4bSXin Li // fileLevelExtensionFunction: java.lang.IllegalArgumentException: Cannot call asMemberOf with a function that is not declared in a class or an interface
106*af87fb4bSXin Li // fileLevelProperty: java.lang.IllegalArgumentException: Cannot call asMemberOf with a property that is not declared in a class or an interface
107*af87fb4bSXin Li // errorType: (<Error>?) -> <Error>?
108*af87fb4bSXin Li // expected comparison failures
109*af87fb4bSXin Li // <BaseTypeArg1: kotlin.Any?>(Base.functionArgType.BaseTypeArg1?) -> kotlin.String?
110*af87fb4bSXin Li // () -> kotlin.Int!!
111*af87fb4bSXin Li // () -> kotlin.Int!!
112*af87fb4bSXin Li // (kotlin.Int!!) -> kotlin.Unit!!
113*af87fb4bSXin Li // END
114*af87fb4bSXin Li // FILE: Input.kt
115*af87fb4bSXin Li open class Base<BaseTypeArg1, BaseTypeArg2> {
116*af87fb4bSXin Li val intType: Int = 0
117*af87fb4bSXin Li val baseTypeArg1: BaseTypeArg1 = TODO()
118*af87fb4bSXin Li val baseTypeArg2: BaseTypeArg2 = TODO()
119*af87fb4bSXin Li val typePair: Pair<BaseTypeArg2, BaseTypeArg1> = TODO()
120*af87fb4bSXin Li val errorType: NonExistType = TODO()
returnIntnull121*af87fb4bSXin Li fun returnInt():Int = TODO()
122*af87fb4bSXin Li fun returnArg1(): BaseTypeArg1 = TODO()
123*af87fb4bSXin Li fun returnArg1Nullable(): BaseTypeArg1? = TODO()
124*af87fb4bSXin Li fun returnArg2(): BaseTypeArg2 = TODO()
125*af87fb4bSXin Li fun returnArg2Nullable(): BaseTypeArg2? = TODO()
126*af87fb4bSXin Li fun receiveArgs(intArg:Int?, arg1: BaseTypeArg1, arg2:BaseTypeArg2):Unit = TODO()
127*af87fb4bSXin Li fun receiveArgsPair(
128*af87fb4bSXin Li pairs: Pair<BaseTypeArg1, BaseTypeArg2>,
129*af87fb4bSXin Li pairNullable: Pair<BaseTypeArg1?, BaseTypeArg2?>?,
130*af87fb4bSXin Li ):Unit = TODO()
131*af87fb4bSXin Li // intentional type argument name conflict here to ensure it does not get replaced by mistake
132*af87fb4bSXin Li fun <BaseTypeArg1> functionArgType(t:BaseTypeArg1?): BaseTypeArg2 = TODO()
133*af87fb4bSXin Li fun <in T: BaseTypeArg1> functionArgTypeWithBounds(t:T?): BaseTypeArg2 = TODO()
134*af87fb4bSXin Li fun BaseTypeArg1.extensionFunction():BaseTypeArg1? = TODO()
135*af87fb4bSXin Li val BaseTypeArg2.extensionProperty:BaseTypeArg2? = TODO()
136*af87fb4bSXin Li }
137*af87fb4bSXin Li
138*af87fb4bSXin Li open class Child1 : Base<Int, String?>() {
139*af87fb4bSXin Li }
140*af87fb4bSXin Li
141*af87fb4bSXin Li open class Child2<ChildTypeArg1> : Base<ChildTypeArg1, ChildTypeArg1?>() {
142*af87fb4bSXin Li }
143*af87fb4bSXin Li
144*af87fb4bSXin Li class NotAChild
145*af87fb4bSXin Li val child2WithString: Child2<String> = TODO()
146*af87fb4bSXin Li val listOfStrings: List<String> = TODO()
147*af87fb4bSXin Li val setOfStrings: Set<String> = TODO()
148*af87fb4bSXin Li
fileLevelExtensionFunctionnull149*af87fb4bSXin Li fun <T>List<T>.fileLevelExtensionFunction():Unit = TODO()
150*af87fb4bSXin Li fun <T>fileLevelFunction():Unit = TODO()
151*af87fb4bSXin Li val fileLevelProperty:Int = 3
152*af87fb4bSXin Li val errorType: NonExistingType
153*af87fb4bSXin Li
154*af87fb4bSXin Li interface KotlinInterface {
155*af87fb4bSXin Li val x:Int
156*af87fb4bSXin Li var y:Int
157*af87fb4bSXin Li }
158*af87fb4bSXin Li
159*af87fb4bSXin Li // FILE: JavaInput.java
160*af87fb4bSXin Li class JavaBase<BaseTypeArg1, BaseTypeArg2> {
161*af87fb4bSXin Li int intType;
162*af87fb4bSXin Li BaseTypeArg1 typeArg1;
163*af87fb4bSXin Li BaseTypeArg2 typeArg2;
164*af87fb4bSXin Li NonExist errorType;
165*af87fb4bSXin Li BaseTypeArg2 returnArg1() {
166*af87fb4bSXin Li return null;
167*af87fb4bSXin Li }
168*af87fb4bSXin Li void receiveArgs(BaseTypeArg1 arg1, BaseTypeArg2 arg2, int intArg) {
169*af87fb4bSXin Li }
170*af87fb4bSXin Li <BaseTypeArg1> void methodArgType(BaseTypeArg1 arg1, BaseTypeArg2 arg2) {
171*af87fb4bSXin Li }
172*af87fb4bSXin Li <T extends BaseTypeArg1> void methodArgTypeWithBounds(T arg1) {
173*af87fb4bSXin Li }
174*af87fb4bSXin Li }
175*af87fb4bSXin Li
176*af87fb4bSXin Li class JavaChild1 extends JavaBase<String, Integer> {
177*af87fb4bSXin Li }
178*af87fb4bSXin Li
179*af87fb4bSXin Li class JavaImpl implements KotlinInterface {
<lambda>null180*af87fb4bSXin Li public int getX() {
181*af87fb4bSXin Li return 1;
182*af87fb4bSXin Li }
<lambda>null183*af87fb4bSXin Li public int getY() {
184*af87fb4bSXin Li return 1;
185*af87fb4bSXin Li }
186*af87fb4bSXin Li public void setY(int value) {
187*af87fb4bSXin Li }
188*af87fb4bSXin Li }
189