diff --git a/native/commonizer/testData/functionCommonization/valueParameters/commonized/common/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/commonized/common/package_root.kt index 9309949a571..61b19c0a19b 100644 --- a/native/commonizer/testData/functionCommonization/valueParameters/commonized/common/package_root.kt +++ b/native/commonizer/testData/functionCommonization/valueParameters/commonized/common/package_root.kt @@ -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) +// 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) +// hasStableParameterNames=false +expect fun functionMismatchedParameterNames6(arg0: Int, arg1: String, arg2: List) +// hasStableParameterNames=false +expect fun functionMismatchedParameterNames7(arg0: Int, arg1: String, arg2: List) +// hasStableParameterNames=false +expect fun functionMismatchedParameterNames8(arg0: Int, arg1: String, arg2: List) +// hasStableParameterNames=false +expect fun functionMismatchedParameterNames9(arg0: Int, arg1: String, arg2: List) +// hasStableParameterNames=false +expect fun functionMismatchedParameterNames10(arg0: Int, arg1: String, arg2: List) +// hasStableParameterNames=false +expect fun functionMismatchedParameterNames11(arg0: Int, arg1: String, arg2: List) + +// 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) +// 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) +// 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) +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) diff --git a/native/commonizer/testData/functionCommonization/valueParameters/commonized/ios/package_kotlinx_cinterop.kt b/native/commonizer/testData/functionCommonization/valueParameters/commonized/ios/package_kotlinx_cinterop.kt new file mode 100644 index 00000000000..fe5970a0bf4 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/valueParameters/commonized/ios/package_kotlinx_cinterop.kt @@ -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 diff --git a/native/commonizer/testData/functionCommonization/valueParameters/commonized/ios/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/commonized/ios/package_root.kt new file mode 100644 index 00000000000..0fe7de2fc7d --- /dev/null +++ b/native/commonizer/testData/functionCommonization/valueParameters/commonized/ios/package_root.kt @@ -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) {} + +// 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) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames6(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames7(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames8(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames9(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames10(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames11(arg0: Int, arg1: String, arg2: List) {} + +// 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) {} +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) {} +// 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) {} +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) {} + +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) {} +actual fun functionWithVararg5(numbers: Array) {} +actual fun functionWithVararg6(vararg names: String) {} +fun functionWithVararg7(vararg names: String) {} +fun functionWithVararg8(vararg names: String) {} +fun functionWithVararg9(names: Array) {} +actual fun functionWithVararg10(names: Array) {} + +actual fun functionWithTypeParameters1(p1: T, p2: String) {} +fun functionWithTypeParameters2(p1: T, p2: String) {} +fun functionWithTypeParameters3(p1: T, p2: String) {} +actual fun functionWithTypeParameters4(p1: Q, p2: R) {} +fun functionWithTypeParameters5(p1: Q, p2: R) {} +fun functionWithTypeParameters6(p1: Q, p2: R) {} diff --git a/native/commonizer/testData/functionCommonization/valueParameters/commonized/js/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/commonized/js/package_root.kt deleted file mode 100644 index d943a6fd75a..00000000000 --- a/native/commonizer/testData/functionCommonization/valueParameters/commonized/js/package_root.kt +++ /dev/null @@ -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) {} - -fun functionMismatchedParameterCount1(i: Int, s: String) {} -fun functionMismatchedParameterCount2(i: Int, s: String, l: List) {} - -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) {} -actual fun functionWithVararg5(numbers: Array) {} -actual fun functionWithVararg6(vararg names: String) {} -fun functionWithVararg7(vararg names: String) {} -fun functionWithVararg8(vararg names: String) {} -fun functionWithVararg9(names: Array) {} -actual fun functionWithVararg10(names: Array) {} - -actual fun functionWithTypeParameters1(p1: T, p2: String) {} -fun functionWithTypeParameters2(p1: T, p2: String) {} -fun functionWithTypeParameters3(p1: T, p2: String) {} -actual fun functionWithTypeParameters4(p1: Q, p2: R) {} -fun functionWithTypeParameters5(p1: Q, p2: R) {} -fun functionWithTypeParameters6(p1: Q, p2: R) {} diff --git a/native/commonizer/testData/functionCommonization/valueParameters/commonized/jvm/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/commonized/jvm/package_root.kt deleted file mode 100644 index 2c23a79c97d..00000000000 --- a/native/commonizer/testData/functionCommonization/valueParameters/commonized/jvm/package_root.kt +++ /dev/null @@ -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) {} - -fun functionMismatchedParameterCount1(i: Int, s: String, l: List) {} -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) {} -fun functionWithVararg3(numbers: Array) {} -fun functionWithVararg4(numbers: Array) {} -actual fun functionWithVararg5(numbers: Array) {} -actual fun functionWithVararg6(vararg names: String) {} -fun functionWithVararg7(names: Array) {} -fun functionWithVararg8(names: Array) {} -fun functionWithVararg9(names: Array) {} -actual fun functionWithVararg10(names: Array) {} - -actual fun functionWithTypeParameters1(p1: T, p2: String) {} -fun functionWithTypeParameters2(p1: String, p2: String) {} -fun functionWithTypeParameters2(p1: String, p2: T) {} -actual fun functionWithTypeParameters4(p1: Q, p2: R) {} -fun functionWithTypeParameters5(p1: Q, p2: R) {} -fun functionWithTypeParameters6(p1: R, p2: Q) {} diff --git a/native/commonizer/testData/functionCommonization/valueParameters/commonized/macos/package_kotlinx_cinterop.kt b/native/commonizer/testData/functionCommonization/valueParameters/commonized/macos/package_kotlinx_cinterop.kt new file mode 100644 index 00000000000..fe5970a0bf4 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/valueParameters/commonized/macos/package_kotlinx_cinterop.kt @@ -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 diff --git a/native/commonizer/testData/functionCommonization/valueParameters/commonized/macos/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/commonized/macos/package_root.kt new file mode 100644 index 00000000000..d46c31fadb3 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/valueParameters/commonized/macos/package_root.kt @@ -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) {} + +// 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) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames6(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames7(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames8(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames9(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames10(arg0: Int, arg1: String, arg2: List) {} +// hasStableParameterNames=false +actual fun functionMismatchedParameterNames11(arg0: Int, arg1: String, arg2: List) {} + +// 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) {} +// 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) {} +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) {} +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) {} +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) {} +fun functionWithVararg3(numbers: Array) {} +fun functionWithVararg4(numbers: Array) {} +actual fun functionWithVararg5(numbers: Array) {} +actual fun functionWithVararg6(vararg names: String) {} +fun functionWithVararg7(names: Array) {} +fun functionWithVararg8(names: Array) {} +fun functionWithVararg9(names: Array) {} +actual fun functionWithVararg10(names: Array) {} + +actual fun functionWithTypeParameters1(p1: T, p2: String) {} +fun functionWithTypeParameters2(p1: String, p2: String) {} +fun functionWithTypeParameters2(p1: String, p2: T) {} +actual fun functionWithTypeParameters4(p1: Q, p2: R) {} +fun functionWithTypeParameters5(p1: Q, p2: R) {} +fun functionWithTypeParameters6(p1: R, p2: Q) {} diff --git a/native/commonizer/testData/functionCommonization/valueParameters/original/ios/package_kotlinx_cinterop.kt b/native/commonizer/testData/functionCommonization/valueParameters/original/ios/package_kotlinx_cinterop.kt new file mode 100644 index 00000000000..fe5970a0bf4 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/valueParameters/original/ios/package_kotlinx_cinterop.kt @@ -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 diff --git a/native/commonizer/testData/functionCommonization/valueParameters/original/ios/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/original/ios/package_root.kt new file mode 100644 index 00000000000..6fc8ecac0a5 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/valueParameters/original/ios/package_root.kt @@ -0,0 +1,111 @@ +fun functionNoParameters() {} +fun functionSingleParameter(i: Int) {} +fun functionTwoParameters(i: Int, s: String) {} +fun functionThreeParameters(i: Int, s: String, l: List) {} + +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) {} +fun functionMismatchedParameterNames6(i: Int, s: String, l: List) {} +fun functionMismatchedParameterNames7(i: Int, s: String, l: List) {} +fun functionMismatchedParameterNames8(i: Int, s: String, l: List) {} +fun functionMismatchedParameterNames9(i: Int, s: String, l: List) {} +fun functionMismatchedParameterNames10(i: Int, s: String, l: List) {} +fun functionMismatchedParameterNames11(i: Int, s: String, l: List) {} + +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) {} +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) {} +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) {} +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) {} + +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) {} +fun functionWithVararg5(numbers: Array) {} +fun functionWithVararg6(vararg names: String) {} +fun functionWithVararg7(vararg names: String) {} +fun functionWithVararg8(vararg names: String) {} +fun functionWithVararg9(names: Array) {} +fun functionWithVararg10(names: Array) {} + +fun functionWithTypeParameters1(p1: T, p2: String) {} +fun functionWithTypeParameters2(p1: T, p2: String) {} +fun functionWithTypeParameters3(p1: T, p2: String) {} +fun functionWithTypeParameters4(p1: Q, p2: R) {} +fun functionWithTypeParameters5(p1: Q, p2: R) {} +fun functionWithTypeParameters6(p1: Q, p2: R) {} diff --git a/native/commonizer/testData/functionCommonization/valueParameters/original/js/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/original/js/package_root.kt deleted file mode 100644 index bde3e547660..00000000000 --- a/native/commonizer/testData/functionCommonization/valueParameters/original/js/package_root.kt +++ /dev/null @@ -1,40 +0,0 @@ -fun functionNoParameters() {} -fun functionSingleParameter(i: Int) {} -fun functionTwoParameters(i: Int, s: String) {} -fun functionThreeParameters(i: Int, s: String, l: List) {} - -fun functionMismatchedParameterCount1(i: Int, s: String) {} -fun functionMismatchedParameterCount2(i: Int, s: String, l: List) {} - -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) {} -fun functionWithVararg5(numbers: Array) {} -fun functionWithVararg6(vararg names: String) {} -fun functionWithVararg7(vararg names: String) {} -fun functionWithVararg8(vararg names: String) {} -fun functionWithVararg9(names: Array) {} -fun functionWithVararg10(names: Array) {} - -fun functionWithTypeParameters1(p1: T, p2: String) {} -fun functionWithTypeParameters2(p1: T, p2: String) {} -fun functionWithTypeParameters3(p1: T, p2: String) {} -fun functionWithTypeParameters4(p1: Q, p2: R) {} -fun functionWithTypeParameters5(p1: Q, p2: R) {} -fun functionWithTypeParameters6(p1: Q, p2: R) {} diff --git a/native/commonizer/testData/functionCommonization/valueParameters/original/jvm/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/original/jvm/package_root.kt deleted file mode 100644 index e358bb08b0a..00000000000 --- a/native/commonizer/testData/functionCommonization/valueParameters/original/jvm/package_root.kt +++ /dev/null @@ -1,40 +0,0 @@ -fun functionNoParameters() {} -fun functionSingleParameter(i: Int) {} -fun functionTwoParameters(i: Int, s: String) {} -fun functionThreeParameters(i: Int, s: String, l: List) {} - -fun functionMismatchedParameterCount1(i: Int, s: String, l: List) {} -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) {} -fun functionWithVararg3(numbers: Array) {} -fun functionWithVararg4(numbers: Array) {} -fun functionWithVararg5(numbers: Array) {} -fun functionWithVararg6(vararg names: String) {} -fun functionWithVararg7(names: Array) {} -fun functionWithVararg8(names: Array) {} -fun functionWithVararg9(names: Array) {} -fun functionWithVararg10(names: Array) {} - -fun functionWithTypeParameters1(p1: T, p2: String) {} -fun functionWithTypeParameters2(p1: String, p2: String) {} -fun functionWithTypeParameters2(p1: String, p2: T) {} -fun functionWithTypeParameters4(p1: Q, p2: R) {} -fun functionWithTypeParameters5(p1: Q, p2: R) {} -fun functionWithTypeParameters6(p1: R, p2: Q) {} diff --git a/native/commonizer/testData/functionCommonization/valueParameters/original/macos/package_kotlinx_cinterop.kt b/native/commonizer/testData/functionCommonization/valueParameters/original/macos/package_kotlinx_cinterop.kt new file mode 100644 index 00000000000..fe5970a0bf4 --- /dev/null +++ b/native/commonizer/testData/functionCommonization/valueParameters/original/macos/package_kotlinx_cinterop.kt @@ -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 diff --git a/native/commonizer/testData/functionCommonization/valueParameters/original/macos/package_root.kt b/native/commonizer/testData/functionCommonization/valueParameters/original/macos/package_root.kt new file mode 100644 index 00000000000..bfa09f92aef --- /dev/null +++ b/native/commonizer/testData/functionCommonization/valueParameters/original/macos/package_root.kt @@ -0,0 +1,111 @@ +fun functionNoParameters() {} +fun functionSingleParameter(i: Int) {} +fun functionTwoParameters(i: Int, s: String) {} +fun functionThreeParameters(i: Int, s: String, l: List) {} + +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) {} +fun functionMismatchedParameterNames6(i: Int, xs: String, l: List) {} +fun functionMismatchedParameterNames7(i: Int, s: String, xl: List) {} +fun functionMismatchedParameterNames8(xi: Int, xs: String, l: List) {} +fun functionMismatchedParameterNames9(xi: Int, s: String, xl: List) {} +fun functionMismatchedParameterNames10(i: Int, xs: String, xl: List) {} +fun functionMismatchedParameterNames11(xi: Int, xs: String, xl: List) {} + +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) {} +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) {} +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) {} +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) {} +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) {} +fun functionWithVararg3(numbers: Array) {} +fun functionWithVararg4(numbers: Array) {} +fun functionWithVararg5(numbers: Array) {} +fun functionWithVararg6(vararg names: String) {} +fun functionWithVararg7(names: Array) {} +fun functionWithVararg8(names: Array) {} +fun functionWithVararg9(names: Array) {} +fun functionWithVararg10(names: Array) {} + +fun functionWithTypeParameters1(p1: T, p2: String) {} +fun functionWithTypeParameters2(p1: String, p2: String) {} +fun functionWithTypeParameters2(p1: String, p2: T) {} +fun functionWithTypeParameters4(p1: Q, p2: R) {} +fun functionWithTypeParameters5(p1: Q, p2: R) {} +fun functionWithTypeParameters6(p1: R, p2: Q) {} diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt index 0645f97cfec..bde3b3a174d 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/AbstractCommonizationFromSourcesTest.kt @@ -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( .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( ) { content -> environment.createPackagePartProvider(content.moduleContentScope) }.moduleDescriptor + + module.accept(PatchingTestDescriptorVisitor, Unit) + + return module } } } @@ -317,6 +328,43 @@ private class CommonizedCommonDependenciesContainer( override val refinesModuleInfos: List get() = listOf(commonModuleInfo) } +private object PatchingTestDescriptorVisitor : DeclarationDescriptorVisitorEmptyBodies() { + 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.toCommonizationParameters(): Parameters = Parameters().also { parameters -> forEach { (target, moduleDescriptor) -> if (!parameters.extendedLookupForBuiltInsClassifiers) { diff --git a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/ValueParameterListCommonizerTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/ValueParameterListCommonizerTest.kt index 5483c2d8fbf..eded987d004 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/ValueParameterListCommonizerTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/descriptors/commonizer/core/ValueParameterListCommonizerTest.kt @@ -107,9 +107,9 @@ class ValueParameterListCommonizerTest : AbstractCommonizerTest