[Commonizer] Tests on rewriting callables names to succeed commonization

^KT-34602
This commit is contained in:
Dmitriy Dolovov
2020-08-07 14:40:28 +07:00
parent de0b6e06cf
commit 75be9cf31f
15 changed files with 652 additions and 186 deletions
@@ -3,6 +3,90 @@ expect fun functionSingleParameter(i: Int)
expect fun functionTwoParameters(i: Int, s: String)
expect fun functionThreeParameters(i: Int, s: String, l: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames1(arg0: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames2(arg0: Int, arg1: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames3(arg0: Int, arg1: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames4(arg0: Int, arg1: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames5(arg0: Int, arg1: String, arg2: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames6(arg0: Int, arg1: String, arg2: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames7(arg0: Int, arg1: String, arg2: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames8(arg0: Int, arg1: String, arg2: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames9(arg0: Int, arg1: String, arg2: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames10(arg0: Int, arg1: String, arg2: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames11(arg0: Int, arg1: String, arg2: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames12(vararg variadicArguments: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames13(arg0: Int, vararg variadicArguments: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames14(arg0: Int, vararg variadicArguments: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames15(arg0: Int, vararg variadicArguments: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames16(i: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames17(i: Int, s: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames18(i: Int, s: String, l: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames19(vararg v: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames20(i: Int, vararg v: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames21(i: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames22(i: Int, s: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames23(i: Int, s: String, l: List<Double>)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames24(vararg v: Int)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames25(i: Int, vararg v: Int)
expect fun functionMismatchedParameterNames26(arg0: Int)
expect fun functionMismatchedParameterNames27(arg0: Int, arg1: String)
expect fun functionMismatchedParameterNames28(arg0: Int, arg1: String, arg2: List<Double>)
expect fun functionMismatchedParameterNames29(vararg variadicArguments: Int)
expect fun functionMismatchedParameterNames30(arg0: Int, vararg variadicArguments: Int)
expect fun functionMismatchedParameterNames31(i: Int, s: String)
expect fun functionMismatchedParameterNames34(i: Int, s: String)
expect fun functionMismatchedParameterNames37(arg0: Int, arg1: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames38(i: Int, s: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames39(i: Int, s: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames40(i: Int, s: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames41(arg0: Int, arg1: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames42(arg0: Int, arg1: String)
// hasStableParameterNames=false
expect fun functionMismatchedParameterNames43(arg0: Int, arg1: String)
expect fun overloadedFunctionByParameterNames(i: Int, s: String)
expect fun overloadedFunctionByParameterNames(xi: Int, xs: String)
expect inline fun inlineFunction1(lazyMessage: () -> String)
expect inline fun inlineFunction2(lazyMessage: () -> String)
expect inline fun inlineFunction3(crossinline lazyMessage: () -> String)
@@ -0,0 +1,6 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@Retention(AnnotationRetention.BINARY)
annotation class ObjCMethod() // fake annotation class without properties
@@ -0,0 +1,131 @@
actual fun functionNoParameters() {}
actual fun functionSingleParameter(i: Int) {}
actual fun functionTwoParameters(i: Int, s: String) {}
actual fun functionThreeParameters(i: Int, s: String, l: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames1(arg0: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames2(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames3(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames4(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames5(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames6(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames7(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames8(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames9(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames10(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames11(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames12(vararg variadicArguments: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames13(arg0: Int, vararg variadicArguments: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames14(arg0: Int, vararg variadicArguments: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames15(arg0: Int, vararg variadicArguments: Int) {}
actual fun functionMismatchedParameterNames16(i: Int) {}
actual fun functionMismatchedParameterNames17(i: Int, s: String) {}
actual fun functionMismatchedParameterNames18(i: Int, s: String, l: List<Double>) {}
actual fun functionMismatchedParameterNames19(vararg v: Int) {}
actual fun functionMismatchedParameterNames20(i: Int, vararg v: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames21(i: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames22(i: Int, s: String) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames23(i: Int, s: String, l: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames24(vararg v: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames25(i: Int, vararg v: Int) {}
actual fun functionMismatchedParameterNames26(arg0: Int) {}
actual fun functionMismatchedParameterNames27(arg0: Int, arg1: String) {}
actual fun functionMismatchedParameterNames28(arg0: Int, arg1: String, arg2: List<Double>) {}
actual fun functionMismatchedParameterNames29(vararg variadicArguments: Int) {}
actual fun functionMismatchedParameterNames30(arg0: Int, vararg variadicArguments: Int) {}
actual fun functionMismatchedParameterNames31(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames32(i: Int, s: String) {}
fun functionMismatchedParameterNames33(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames34(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames35(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames36(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames37(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames38(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames39(i: Int, s: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames40(i: Int, s: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames41(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames42(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames43(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun overloadedFunctionByParameterNames(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun overloadedFunctionByParameterNames(xi: Int, xs: String) {}
fun functionMismatchedParameterCount1(i: Int, s: String) {}
fun functionMismatchedParameterCount2(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterTypes1(i: Int, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: String) {}
fun functionDefaultValues1(i: Int = 1, s: String) {}
fun functionDefaultValues2(i: Int, s: String = "hello") {}
actual inline fun inlineFunction1(lazyMessage: () -> String) {}
actual inline fun inlineFunction2(lazyMessage: () -> String) {}
actual inline fun inlineFunction3(crossinline lazyMessage: () -> String) {}
actual inline fun inlineFunction4(lazyMessage: () -> String) {}
actual inline fun inlineFunction5(noinline lazyMessage: () -> String) {}
actual fun functionWithVararg1(vararg numbers: Int) {}
fun functionWithVararg2(vararg numbers: Int) {}
fun functionWithVararg3(vararg numbers: Int) {}
fun functionWithVararg4(numbers: Array<Int>) {}
actual fun functionWithVararg5(numbers: Array<out Int>) {}
actual fun functionWithVararg6(vararg names: String) {}
fun functionWithVararg7(vararg names: String) {}
fun functionWithVararg8(vararg names: String) {}
fun functionWithVararg9(names: Array<String>) {}
actual fun functionWithVararg10(names: Array<out String>) {}
actual fun <T> functionWithTypeParameters1(p1: T, p2: String) {}
fun <T> functionWithTypeParameters2(p1: T, p2: String) {}
fun <T> functionWithTypeParameters3(p1: T, p2: String) {}
actual fun <Q, R> functionWithTypeParameters4(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters5(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters6(p1: Q, p2: R) {}
@@ -1,40 +0,0 @@
actual fun functionNoParameters() {}
actual fun functionSingleParameter(i: Int) {}
actual fun functionTwoParameters(i: Int, s: String) {}
actual fun functionThreeParameters(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount1(i: Int, s: String) {}
fun functionMismatchedParameterCount2(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames1(i: Int, s: String) {}
fun functionMismatchedParameterNames2(i: Int, s: String) {}
fun functionMismatchedParameterTypes1(i: Int, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: String) {}
fun functionDefaultValues1(i: Int = 1, s: String) {}
fun functionDefaultValues2(i: Int, s: String = "hello") {}
actual inline fun inlineFunction1(lazyMessage: () -> String) {}
actual inline fun inlineFunction2(lazyMessage: () -> String) {}
actual inline fun inlineFunction3(crossinline lazyMessage: () -> String) {}
actual inline fun inlineFunction4(lazyMessage: () -> String) {}
actual inline fun inlineFunction5(noinline lazyMessage: () -> String) {}
actual fun functionWithVararg1(vararg numbers: Int) {}
fun functionWithVararg2(vararg numbers: Int) {}
fun functionWithVararg3(vararg numbers: Int) {}
fun functionWithVararg4(numbers: Array<Int>) {}
actual fun functionWithVararg5(numbers: Array<out Int>) {}
actual fun functionWithVararg6(vararg names: String) {}
fun functionWithVararg7(vararg names: String) {}
fun functionWithVararg8(vararg names: String) {}
fun functionWithVararg9(names: Array<String>) {}
actual fun functionWithVararg10(names: Array<out String>) {}
actual fun <T> functionWithTypeParameters1(p1: T, p2: String) {}
fun <T> functionWithTypeParameters2(p1: T, p2: String) {}
fun <T> functionWithTypeParameters3(p1: T, p2: String) {}
actual fun <Q, R> functionWithTypeParameters4(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters5(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters6(p1: Q, p2: R) {}
@@ -1,40 +0,0 @@
actual fun functionNoParameters() {}
actual fun functionSingleParameter(i: Int) {}
actual fun functionTwoParameters(i: Int, s: String) {}
actual fun functionThreeParameters(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount1(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount2(i: Int, s: String) {}
fun functionMismatchedParameterNames1(i1: Int, s: String) {}
fun functionMismatchedParameterNames2(i: Int, s1: String) {}
fun functionMismatchedParameterTypes1(i: Short, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: CharSequence) {}
fun functionDefaultValues1(i: Int = 1, s: String) {}
fun functionDefaultValues2(i: Int, s: String = "hello") {}
actual inline fun inlineFunction1(lazyMessage: () -> String) {}
actual inline fun inlineFunction2(crossinline lazyMessage: () -> String) {}
actual inline fun inlineFunction3(crossinline lazyMessage: () -> String) {}
actual inline fun inlineFunction4(noinline lazyMessage: () -> String) {}
actual inline fun inlineFunction5(noinline lazyMessage: () -> String) {}
actual fun functionWithVararg1(vararg numbers: Int) {}
fun functionWithVararg2(numbers: Array<Int>) {}
fun functionWithVararg3(numbers: Array<out Int>) {}
fun functionWithVararg4(numbers: Array<out Int>) {}
actual fun functionWithVararg5(numbers: Array<out Int>) {}
actual fun functionWithVararg6(vararg names: String) {}
fun functionWithVararg7(names: Array<String>) {}
fun functionWithVararg8(names: Array<out String>) {}
fun functionWithVararg9(names: Array<out String>) {}
actual fun functionWithVararg10(names: Array<out String>) {}
actual fun <T> functionWithTypeParameters1(p1: T, p2: String) {}
fun <T> functionWithTypeParameters2(p1: String, p2: String) {}
fun <T> functionWithTypeParameters2(p1: String, p2: T) {}
actual fun <Q, R> functionWithTypeParameters4(p1: Q, p2: R) {}
fun <R, Q> functionWithTypeParameters5(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters6(p1: R, p2: Q) {}
@@ -0,0 +1,6 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@Retention(AnnotationRetention.BINARY)
annotation class ObjCMethod() // fake annotation class without properties
@@ -0,0 +1,131 @@
actual fun functionNoParameters() {}
actual fun functionSingleParameter(i: Int) {}
actual fun functionTwoParameters(i: Int, s: String) {}
actual fun functionThreeParameters(i: Int, s: String, l: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames1(arg0: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames2(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames3(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames4(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames5(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames6(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames7(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames8(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames9(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames10(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames11(arg0: Int, arg1: String, arg2: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames12(vararg variadicArguments: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames13(arg0: Int, vararg variadicArguments: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames14(arg0: Int, vararg variadicArguments: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames15(arg0: Int, vararg variadicArguments: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames16(i: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames17(i: Int, s: String) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames18(i: Int, s: String, l: List<Double>) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames19(vararg v: Int) {}
// hasStableParameterNames=false
actual fun functionMismatchedParameterNames20(i: Int, vararg v: Int) {}
actual fun functionMismatchedParameterNames21(i: Int) {}
actual fun functionMismatchedParameterNames22(i: Int, s: String) {}
actual fun functionMismatchedParameterNames23(i: Int, s: String, l: List<Double>) {}
actual fun functionMismatchedParameterNames24(vararg v: Int) {}
actual fun functionMismatchedParameterNames25(i: Int, vararg v: Int) {}
actual fun functionMismatchedParameterNames26(arg0: Int) {}
actual fun functionMismatchedParameterNames27(arg0: Int, arg1: String) {}
actual fun functionMismatchedParameterNames28(arg0: Int, arg1: String, arg2: List<Double>) {}
actual fun functionMismatchedParameterNames29(vararg variadicArguments: Int) {}
actual fun functionMismatchedParameterNames30(arg0: Int, vararg variadicArguments: Int) {}
actual fun functionMismatchedParameterNames31(i: Int, s: String) {}
fun functionMismatchedParameterNames32(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames33(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames34(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames35(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames36(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames37(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames38(i: Int, s: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames39(i: Int, s: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames40(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames41(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames42(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
actual fun functionMismatchedParameterNames43(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun overloadedFunctionByParameterNames(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
actual fun overloadedFunctionByParameterNames(xi: Int, xs: String) {}
fun functionMismatchedParameterCount1(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount2(i: Int, s: String) {}
fun functionMismatchedParameterTypes1(i: Short, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: CharSequence) {}
fun functionDefaultValues1(i: Int = 1, s: String) {}
fun functionDefaultValues2(i: Int, s: String = "hello") {}
actual inline fun inlineFunction1(lazyMessage: () -> String) {}
actual inline fun inlineFunction2(crossinline lazyMessage: () -> String) {}
actual inline fun inlineFunction3(crossinline lazyMessage: () -> String) {}
actual inline fun inlineFunction4(noinline lazyMessage: () -> String) {}
actual inline fun inlineFunction5(noinline lazyMessage: () -> String) {}
actual fun functionWithVararg1(vararg numbers: Int) {}
fun functionWithVararg2(numbers: Array<Int>) {}
fun functionWithVararg3(numbers: Array<out Int>) {}
fun functionWithVararg4(numbers: Array<out Int>) {}
actual fun functionWithVararg5(numbers: Array<out Int>) {}
actual fun functionWithVararg6(vararg names: String) {}
fun functionWithVararg7(names: Array<String>) {}
fun functionWithVararg8(names: Array<out String>) {}
fun functionWithVararg9(names: Array<out String>) {}
actual fun functionWithVararg10(names: Array<out String>) {}
actual fun <T> functionWithTypeParameters1(p1: T, p2: String) {}
fun <T> functionWithTypeParameters2(p1: String, p2: String) {}
fun <T> functionWithTypeParameters2(p1: String, p2: T) {}
actual fun <Q, R> functionWithTypeParameters4(p1: Q, p2: R) {}
fun <R, Q> functionWithTypeParameters5(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters6(p1: R, p2: Q) {}
@@ -0,0 +1,6 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@Retention(AnnotationRetention.BINARY)
annotation class ObjCMethod() // fake annotation class without properties
@@ -0,0 +1,111 @@
fun functionNoParameters() {}
fun functionSingleParameter(i: Int) {}
fun functionTwoParameters(i: Int, s: String) {}
fun functionThreeParameters(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames1(i: Int) {}
fun functionMismatchedParameterNames2(i: Int, s: String) {}
fun functionMismatchedParameterNames3(i: Int, s: String) {}
fun functionMismatchedParameterNames4(i: Int, s: String) {}
fun functionMismatchedParameterNames5(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames6(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames7(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames8(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames9(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames10(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames11(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames12(vararg v: Int) {}
fun functionMismatchedParameterNames13(i: Int, vararg v: Int) {}
fun functionMismatchedParameterNames14(i: Int, vararg v: Int) {}
fun functionMismatchedParameterNames15(i: Int, vararg v: Int) {}
fun functionMismatchedParameterNames16(i: Int) {}
fun functionMismatchedParameterNames17(i: Int, s: String) {}
fun functionMismatchedParameterNames18(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames19(vararg v: Int) {}
fun functionMismatchedParameterNames20(i: Int, vararg v: Int) {}
fun functionMismatchedParameterNames21(arg0: Int) {}
fun functionMismatchedParameterNames22(arg0: Int, arg1: String) {}
fun functionMismatchedParameterNames23(arg0: Int, arg1: String, arg2: List<Double>) {}
fun functionMismatchedParameterNames24(vararg variadicArguments: Int) {}
fun functionMismatchedParameterNames25(arg0: Int, vararg variadicArguments: Int) {}
fun functionMismatchedParameterNames26(arg0: Int) {}
fun functionMismatchedParameterNames27(arg0: Int, arg1: String) {}
fun functionMismatchedParameterNames28(arg0: Int, arg1: String, arg2: List<Double>) {}
fun functionMismatchedParameterNames29(vararg variadicArguments: Int) {}
fun functionMismatchedParameterNames30(arg0: Int, vararg variadicArguments: Int) {}
fun functionMismatchedParameterNames31(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames32(i: Int, s: String) {}
fun functionMismatchedParameterNames33(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames34(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames35(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames36(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames37(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames38(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames39(i: Int, s: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames40(i: Int, s: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames41(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames42(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames43(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
fun overloadedFunctionByParameterNames(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun overloadedFunctionByParameterNames(xi: Int, xs: String) {}
fun functionMismatchedParameterCount1(i: Int, s: String) {}
fun functionMismatchedParameterCount2(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterTypes1(i: Int, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: String) {}
fun functionDefaultValues1(i: Int = 1, s: String) {}
fun functionDefaultValues2(i: Int, s: String = "hello") {}
inline fun inlineFunction1(lazyMessage: () -> String) {}
inline fun inlineFunction2(lazyMessage: () -> String) {}
inline fun inlineFunction3(crossinline lazyMessage: () -> String) {}
inline fun inlineFunction4(lazyMessage: () -> String) {}
inline fun inlineFunction5(noinline lazyMessage: () -> String) {}
fun functionWithVararg1(vararg numbers: Int) {}
fun functionWithVararg2(vararg numbers: Int) {}
fun functionWithVararg3(vararg numbers: Int) {}
fun functionWithVararg4(numbers: Array<Int>) {}
fun functionWithVararg5(numbers: Array<out Int>) {}
fun functionWithVararg6(vararg names: String) {}
fun functionWithVararg7(vararg names: String) {}
fun functionWithVararg8(vararg names: String) {}
fun functionWithVararg9(names: Array<String>) {}
fun functionWithVararg10(names: Array<out String>) {}
fun <T> functionWithTypeParameters1(p1: T, p2: String) {}
fun <T> functionWithTypeParameters2(p1: T, p2: String) {}
fun <T> functionWithTypeParameters3(p1: T, p2: String) {}
fun <Q, R> functionWithTypeParameters4(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters5(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters6(p1: Q, p2: R) {}
@@ -1,40 +0,0 @@
fun functionNoParameters() {}
fun functionSingleParameter(i: Int) {}
fun functionTwoParameters(i: Int, s: String) {}
fun functionThreeParameters(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount1(i: Int, s: String) {}
fun functionMismatchedParameterCount2(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames1(i: Int, s: String) {}
fun functionMismatchedParameterNames2(i: Int, s: String) {}
fun functionMismatchedParameterTypes1(i: Int, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: String) {}
fun functionDefaultValues1(i: Int = 1, s: String) {}
fun functionDefaultValues2(i: Int, s: String = "hello") {}
inline fun inlineFunction1(lazyMessage: () -> String) {}
inline fun inlineFunction2(lazyMessage: () -> String) {}
inline fun inlineFunction3(crossinline lazyMessage: () -> String) {}
inline fun inlineFunction4(lazyMessage: () -> String) {}
inline fun inlineFunction5(noinline lazyMessage: () -> String) {}
fun functionWithVararg1(vararg numbers: Int) {}
fun functionWithVararg2(vararg numbers: Int) {}
fun functionWithVararg3(vararg numbers: Int) {}
fun functionWithVararg4(numbers: Array<Int>) {}
fun functionWithVararg5(numbers: Array<out Int>) {}
fun functionWithVararg6(vararg names: String) {}
fun functionWithVararg7(vararg names: String) {}
fun functionWithVararg8(vararg names: String) {}
fun functionWithVararg9(names: Array<String>) {}
fun functionWithVararg10(names: Array<out String>) {}
fun <T> functionWithTypeParameters1(p1: T, p2: String) {}
fun <T> functionWithTypeParameters2(p1: T, p2: String) {}
fun <T> functionWithTypeParameters3(p1: T, p2: String) {}
fun <Q, R> functionWithTypeParameters4(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters5(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters6(p1: Q, p2: R) {}
@@ -1,40 +0,0 @@
fun functionNoParameters() {}
fun functionSingleParameter(i: Int) {}
fun functionTwoParameters(i: Int, s: String) {}
fun functionThreeParameters(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount1(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount2(i: Int, s: String) {}
fun functionMismatchedParameterNames1(i1: Int, s: String) {}
fun functionMismatchedParameterNames2(i: Int, s1: String) {}
fun functionMismatchedParameterTypes1(i: Short, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: CharSequence) {}
fun functionDefaultValues1(i: Int = 1, s: String) {}
fun functionDefaultValues2(i: Int, s: String = "hello") {}
inline fun inlineFunction1(lazyMessage: () -> String) {}
inline fun inlineFunction2(crossinline lazyMessage: () -> String) {}
inline fun inlineFunction3(crossinline lazyMessage: () -> String) {}
inline fun inlineFunction4(noinline lazyMessage: () -> String) {}
inline fun inlineFunction5(noinline lazyMessage: () -> String) {}
fun functionWithVararg1(vararg numbers: Int) {}
fun functionWithVararg2(numbers: Array<Int>) {}
fun functionWithVararg3(numbers: Array<out Int>) {}
fun functionWithVararg4(numbers: Array<out Int>) {}
fun functionWithVararg5(numbers: Array<out Int>) {}
fun functionWithVararg6(vararg names: String) {}
fun functionWithVararg7(names: Array<String>) {}
fun functionWithVararg8(names: Array<out String>) {}
fun functionWithVararg9(names: Array<out String>) {}
fun functionWithVararg10(names: Array<out String>) {}
fun <T> functionWithTypeParameters1(p1: T, p2: String) {}
fun <T> functionWithTypeParameters2(p1: String, p2: String) {}
fun <T> functionWithTypeParameters2(p1: String, p2: T) {}
fun <Q, R> functionWithTypeParameters4(p1: Q, p2: R) {}
fun <R, Q> functionWithTypeParameters5(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters6(p1: R, p2: Q) {}
@@ -0,0 +1,6 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER)
@Retention(AnnotationRetention.BINARY)
annotation class ObjCMethod() // fake annotation class without properties
@@ -0,0 +1,111 @@
fun functionNoParameters() {}
fun functionSingleParameter(i: Int) {}
fun functionTwoParameters(i: Int, s: String) {}
fun functionThreeParameters(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames1(xi: Int) {}
fun functionMismatchedParameterNames2(xi: Int, s: String) {}
fun functionMismatchedParameterNames3(i: Int, xs: String) {}
fun functionMismatchedParameterNames4(xi: Int, xs: String) {}
fun functionMismatchedParameterNames5(xi: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames6(i: Int, xs: String, l: List<Double>) {}
fun functionMismatchedParameterNames7(i: Int, s: String, xl: List<Double>) {}
fun functionMismatchedParameterNames8(xi: Int, xs: String, l: List<Double>) {}
fun functionMismatchedParameterNames9(xi: Int, s: String, xl: List<Double>) {}
fun functionMismatchedParameterNames10(i: Int, xs: String, xl: List<Double>) {}
fun functionMismatchedParameterNames11(xi: Int, xs: String, xl: List<Double>) {}
fun functionMismatchedParameterNames12(vararg xv: Int) {}
fun functionMismatchedParameterNames13(xi: Int, vararg v: Int) {}
fun functionMismatchedParameterNames14(i: Int, vararg xv: Int) {}
fun functionMismatchedParameterNames15(xi: Int, vararg xv: Int) {}
fun functionMismatchedParameterNames16(arg0: Int) {}
fun functionMismatchedParameterNames17(arg0: Int, arg1: String) {}
fun functionMismatchedParameterNames18(arg0: Int, arg1: String, arg2: List<Double>) {}
fun functionMismatchedParameterNames19(vararg variadicArguments: Int) {}
fun functionMismatchedParameterNames20(arg0: Int, vararg variadicArguments: Int) {}
fun functionMismatchedParameterNames21(i: Int) {}
fun functionMismatchedParameterNames22(i: Int, s: String) {}
fun functionMismatchedParameterNames23(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterNames24(vararg v: Int) {}
fun functionMismatchedParameterNames25(i: Int, vararg v: Int) {}
fun functionMismatchedParameterNames26(arg0: Int) {}
fun functionMismatchedParameterNames27(arg0: Int, arg1: String) {}
fun functionMismatchedParameterNames28(arg0: Int, arg1: String, arg2: List<Double>) {}
fun functionMismatchedParameterNames29(vararg variadicArguments: Int) {}
fun functionMismatchedParameterNames30(arg0: Int, vararg variadicArguments: Int) {}
fun functionMismatchedParameterNames31(i: Int, s: String) {}
fun functionMismatchedParameterNames32(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames33(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames34(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames35(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames36(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames37(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames38(i: Int, s: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames39(i: Int, s: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames40(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames41(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames42(arg0: Int, arg1: String) {}
// hasStableParameterNames=false
@kotlinx.cinterop.ObjCMethod
fun functionMismatchedParameterNames43(arg0: Int, arg1: String) {}
@kotlinx.cinterop.ObjCMethod
fun overloadedFunctionByParameterNames(i: Int, s: String) {}
@kotlinx.cinterop.ObjCMethod
fun overloadedFunctionByParameterNames(xi: Int, xs: String) {}
fun functionMismatchedParameterCount1(i: Int, s: String, l: List<Double>) {}
fun functionMismatchedParameterCount2(i: Int, s: String) {}
fun functionMismatchedParameterTypes1(i: Short, s: String) {}
fun functionMismatchedParameterTypes2(i: Int, s: CharSequence) {}
fun functionDefaultValues1(i: Int = 1, s: String) {}
fun functionDefaultValues2(i: Int, s: String = "hello") {}
inline fun inlineFunction1(lazyMessage: () -> String) {}
inline fun inlineFunction2(crossinline lazyMessage: () -> String) {}
inline fun inlineFunction3(crossinline lazyMessage: () -> String) {}
inline fun inlineFunction4(noinline lazyMessage: () -> String) {}
inline fun inlineFunction5(noinline lazyMessage: () -> String) {}
fun functionWithVararg1(vararg numbers: Int) {}
fun functionWithVararg2(numbers: Array<Int>) {}
fun functionWithVararg3(numbers: Array<out Int>) {}
fun functionWithVararg4(numbers: Array<out Int>) {}
fun functionWithVararg5(numbers: Array<out Int>) {}
fun functionWithVararg6(vararg names: String) {}
fun functionWithVararg7(names: Array<String>) {}
fun functionWithVararg8(names: Array<out String>) {}
fun functionWithVararg9(names: Array<out String>) {}
fun functionWithVararg10(names: Array<out String>) {}
fun <T> functionWithTypeParameters1(p1: T, p2: String) {}
fun <T> functionWithTypeParameters2(p1: String, p2: String) {}
fun <T> functionWithTypeParameters2(p1: String, p2: T) {}
fun <Q, R> functionWithTypeParameters4(p1: Q, p2: R) {}
fun <R, Q> functionWithTypeParameters5(p1: Q, p2: R) {}
fun <Q, R> functionWithTypeParameters6(p1: R, p2: Q) {}
@@ -16,18 +16,25 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentProvider
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.commonizer.SourceModuleRoot.Companion.COMMON_TARGET_NAME
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.ClassCollector
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.FunctionCollector
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.collectMembers
import org.jetbrains.kotlin.descriptors.commonizer.mergedtree.collectNonEmptyPackageMemberScopes
import org.jetbrains.kotlin.descriptors.commonizer.utils.*
import org.jetbrains.kotlin.descriptors.commonizer.utils.MockBuiltInsProvider
import org.jetbrains.kotlin.descriptors.impl.DeclarationDescriptorVisitorEmptyBodies
import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.js.resolve.diagnostics.findPsi
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.CommonPlatforms
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.test.KotlinTestUtils.*
import org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase
import java.io.File
@@ -218,7 +225,7 @@ private class AnalyzedModule<T : Target>(
.map { psiFactory.createFile(it.name, doLoadFile(it)) }
.toList()
return CommonResolverForModuleFactory.analyzeFiles(
val module = CommonResolverForModuleFactory.analyzeFiles(
files = psiFiles,
moduleName = Name.special("<$moduleName>"),
dependOnBuiltIns = true,
@@ -228,6 +235,10 @@ private class AnalyzedModule<T : Target>(
) { content ->
environment.createPackagePartProvider(content.moduleContentScope)
}.moduleDescriptor
module.accept(PatchingTestDescriptorVisitor, Unit)
return module
}
}
}
@@ -317,6 +328,43 @@ private class CommonizedCommonDependenciesContainer(
override val refinesModuleInfos: List<ModuleInfo> get() = listOf(commonModuleInfo)
}
private object PatchingTestDescriptorVisitor : DeclarationDescriptorVisitorEmptyBodies<Unit, Unit>() {
override fun visitModuleDeclaration(descriptor: ModuleDescriptor, data: Unit) {
descriptor.collectNonEmptyPackageMemberScopes { _, memberScope ->
visitMemberScope(memberScope)
}
}
private fun visitMemberScope(memberScope: MemberScope) {
memberScope.collectMembers(
ClassCollector {
it.constructors.forEach(::visitCallableMemberDescriptor)
visitMemberScope(it.unsubstitutedMemberScope)
},
FunctionCollector {
visitCallableMemberDescriptor(it)
},
{
true // eat and ignore everything else
}
)
}
private fun visitCallableMemberDescriptor(callableDescriptor: CallableMemberDescriptor) {
val comment = callableDescriptor.findPsi()?.text?.lineSequence()?.firstOrNull()?.takeIf { it.startsWith("//") } ?: return
val (key, value) = comment.substringAfter("//").split('=', limit = 2).takeIf { it.size == 2 }?.map { it.trim() } ?: return
when (key) {
"hasStableParameterNames" -> {
if (!value.toBoolean()) (callableDescriptor as FunctionDescriptorImpl).setHasStableParameterNames(false)
}
else -> {
// more custom actions may be added here in the future
}
}
}
}
private fun Map<InputTarget, ModuleDescriptor>.toCommonizationParameters(): Parameters = Parameters().also { parameters ->
forEach { (target, moduleDescriptor) ->
if (!parameters.extendedLookupForBuiltInsClassifiers) {
@@ -107,9 +107,9 @@ class ValueParameterListCommonizerTest : AbstractCommonizerTest<List<CirValuePar
)
)
@Test(expected = IllegalCommonizerStateException::class)
fun mismatchedParameterNames1() = doTestFailure(
mockValueParams(
@Test // types match, names doesn't match, without rewriting names the commonizer chooses the names from the first list of parameters
fun mismatchedParameterNames() = doTestSuccess(
expected = mockValueParams(
"a" to "kotlin.String",
"b" to "kotlin.Int",
"c" to "org.sample.Foo"
@@ -120,28 +120,14 @@ class ValueParameterListCommonizerTest : AbstractCommonizerTest<List<CirValuePar
"c" to "org.sample.Foo"
),
mockValueParams(
"a1" to "kotlin.String",
"b" to "kotlin.Int",
"c" to "org.sample.Foo"
)
)
@Test(expected = IllegalCommonizerStateException::class)
fun mismatchedParameterNames2() = doTestFailure(
mockValueParams(
"a" to "kotlin.String",
"b" to "kotlin.Int",
"c" to "org.sample.Foo"
"d" to "kotlin.String",
"e" to "kotlin.Int",
"f" to "org.sample.Foo"
),
mockValueParams(
"a" to "kotlin.String",
"b" to "kotlin.Int",
"c" to "org.sample.Foo"
),
mockValueParams(
"a" to "kotlin.String",
"b" to "kotlin.Int",
"c1" to "org.sample.Foo"
"h" to "kotlin.String",
"i" to "kotlin.Int",
"j" to "org.sample.Foo"
)
)