/* * Copyright 2022 Google LLC * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // WITH_RUNTIME // TEST PROCESSOR: AsMemberOfProcessor // EXPECTED: // Child1!! // intType: kotlin.Int!! // baseTypeArg1: kotlin.Int!! // baseTypeArg2: kotlin.String? // typePair: kotlin.Pair!! // errorType: ? // extensionProperty: kotlin.String? // returnInt: () -> kotlin.Int!! // returnArg1: () -> kotlin.Int!! // returnArg1Nullable: () -> kotlin.Int? // returnArg2: () -> kotlin.String? // returnArg2Nullable: () -> kotlin.String? // receiveArgs: (kotlin.Int?, kotlin.Int!!, kotlin.String?) -> kotlin.Unit!! // receiveArgsPair: (kotlin.Pair!!, kotlin.Pair?) -> kotlin.Unit!! // functionArgType: (Base.functionArgType.BaseTypeArg1?) -> kotlin.String? // functionArgTypeWithBounds: (Base.functionArgTypeWithBounds.T?) -> kotlin.String? // extensionFunction: kotlin.Int!!.() -> kotlin.Int? // Child2!! // intType: kotlin.Int!! // baseTypeArg1: kotlin.Any? // baseTypeArg2: kotlin.Any? // typePair: kotlin.Pair!! // errorType: ? // extensionProperty: kotlin.Any? // returnInt: () -> kotlin.Int!! // returnArg1: () -> kotlin.Any? // returnArg1Nullable: () -> kotlin.Any? // returnArg2: () -> kotlin.Any? // returnArg2Nullable: () -> kotlin.Any? // receiveArgs: (kotlin.Int?, kotlin.Any?, kotlin.Any?) -> kotlin.Unit!! // receiveArgsPair: (kotlin.Pair!!, kotlin.Pair?) -> kotlin.Unit!! // functionArgType: (Base.functionArgType.BaseTypeArg1?) -> kotlin.Any? // functionArgTypeWithBounds: (Base.functionArgTypeWithBounds.T?) -> kotlin.Any? // extensionFunction: kotlin.Any?.() -> kotlin.Any? // Child2!! // intType: kotlin.Int!! // baseTypeArg1: kotlin.String!! // baseTypeArg2: kotlin.String? // typePair: kotlin.Pair!! // errorType: ? // extensionProperty: kotlin.String? // returnInt: () -> kotlin.Int!! // returnArg1: () -> kotlin.String!! // returnArg1Nullable: () -> kotlin.String? // returnArg2: () -> kotlin.String? // returnArg2Nullable: () -> kotlin.String? // receiveArgs: (kotlin.Int?, kotlin.String!!, kotlin.String?) -> kotlin.Unit!! // receiveArgsPair: (kotlin.Pair!!, kotlin.Pair?) -> kotlin.Unit!! // functionArgType: (Base.functionArgType.BaseTypeArg1?) -> kotlin.String? // functionArgTypeWithBounds: (Base.functionArgTypeWithBounds.T?) -> kotlin.String? // extensionFunction: kotlin.String!!.() -> kotlin.String? // NotAChild!! // intType: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `intType` (Base) // baseTypeArg1: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `baseTypeArg1` (Base) // baseTypeArg2: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `baseTypeArg2` (Base) // typePair: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `typePair` (Base) // errorType: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `errorType` (Base) // extensionProperty: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `extensionProperty` (Base) // returnInt: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnInt` (Base) // returnArg1: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnArg1` (Base) // returnArg1Nullable: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnArg1Nullable` (Base) // returnArg2: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnArg2` (Base) // returnArg2Nullable: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `returnArg2Nullable` (Base) // receiveArgs: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `receiveArgs` (Base) // receiveArgsPair: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `receiveArgsPair` (Base) // functionArgType: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `functionArgType` (Base) // functionArgTypeWithBounds: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `functionArgTypeWithBounds` (Base) // extensionFunction: java.lang.IllegalArgumentException: NotAChild is not a sub type of the class/interface that contains `extensionFunction` (Base) // List#get // listOfStrings: (kotlin.Int!!) -> kotlin.String!! // setOfStrings: java.lang.IllegalArgumentException: Set is not a sub type of the class/interface that contains `get` (List) // Set#contains // listOfStrings: java.lang.IllegalArgumentException: List is not a sub type of the class/interface that contains `contains` (Set) // setOfStrings: (kotlin.String!!) -> kotlin.Boolean!! // JavaChild1!! // intType: kotlin.Int!! // typeArg1: kotlin.String // typeArg2: kotlin.Int // errorType: ? // returnArg1: () -> kotlin.Int // receiveArgs: (kotlin.String, kotlin.Int, kotlin.Int!!) -> kotlin.Unit!! // methodArgType: (JavaBase.methodArgType.BaseTypeArg1, kotlin.Int) -> kotlin.Unit!! // methodArgTypeWithBounds: (JavaBase.methodArgTypeWithBounds.T) -> kotlin.Unit!! // fileLevelFunction: java.lang.IllegalArgumentException: Cannot call asMemberOf with a function that is not declared in a class or an interface // fileLevelExtensionFunction: java.lang.IllegalArgumentException: Cannot call asMemberOf with a function that is not declared in a class or an interface // fileLevelProperty: java.lang.IllegalArgumentException: Cannot call asMemberOf with a property that is not declared in a class or an interface // errorType: (?) -> ? // expected comparison failures // (Base.functionArgType.BaseTypeArg1?) -> kotlin.String? // () -> kotlin.Int!! // () -> kotlin.Int!! // (kotlin.Int!!) -> kotlin.Unit!! // END // FILE: Input.kt open class Base { val intType: Int = 0 val baseTypeArg1: BaseTypeArg1 = TODO() val baseTypeArg2: BaseTypeArg2 = TODO() val typePair: Pair = TODO() val errorType: NonExistType = TODO() fun returnInt():Int = TODO() fun returnArg1(): BaseTypeArg1 = TODO() fun returnArg1Nullable(): BaseTypeArg1? = TODO() fun returnArg2(): BaseTypeArg2 = TODO() fun returnArg2Nullable(): BaseTypeArg2? = TODO() fun receiveArgs(intArg:Int?, arg1: BaseTypeArg1, arg2:BaseTypeArg2):Unit = TODO() fun receiveArgsPair( pairs: Pair, pairNullable: Pair?, ):Unit = TODO() // intentional type argument name conflict here to ensure it does not get replaced by mistake fun functionArgType(t:BaseTypeArg1?): BaseTypeArg2 = TODO() fun functionArgTypeWithBounds(t:T?): BaseTypeArg2 = TODO() fun BaseTypeArg1.extensionFunction():BaseTypeArg1? = TODO() val BaseTypeArg2.extensionProperty:BaseTypeArg2? = TODO() } open class Child1 : Base() { } open class Child2 : Base() { } class NotAChild val child2WithString: Child2 = TODO() val listOfStrings: List = TODO() val setOfStrings: Set = TODO() fun List.fileLevelExtensionFunction():Unit = TODO() fun fileLevelFunction():Unit = TODO() val fileLevelProperty:Int = 3 val errorType: NonExistingType interface KotlinInterface { val x:Int var y:Int } // FILE: JavaInput.java class JavaBase { int intType; BaseTypeArg1 typeArg1; BaseTypeArg2 typeArg2; NonExist errorType; BaseTypeArg2 returnArg1() { return null; } void receiveArgs(BaseTypeArg1 arg1, BaseTypeArg2 arg2, int intArg) { } void methodArgType(BaseTypeArg1 arg1, BaseTypeArg2 arg2) { } void methodArgTypeWithBounds(T arg1) { } } class JavaChild1 extends JavaBase { } class JavaImpl implements KotlinInterface { public int getX() { return 1; } public int getY() { return 1; } public void setY(int value) { } }