diff --git a/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt index 033522543ec..e0a231286bb 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.commonizer.hierarchical import org.jetbrains.kotlin.commonizer.AbstractInlineSourcesCommonizationTest import org.jetbrains.kotlin.commonizer.assertCommonized +import org.junit.Test class ParameterizedTypesCommonizationTest : AbstractInlineSourcesCommonizationTest() { @@ -524,4 +525,97 @@ class ParameterizedTypesCommonizationTest : AbstractInlineSourcesCommonizationTe """.trimIndent() ) } + + fun `test nested arguments`() { + val result = commonize { + outputTarget("(a, b)") + "a" withSource """ + class X + class Y + fun x(x: X>) = Unit + """.trimIndent() + + "b" withSource """ + class X + class Y + fun x(x: X>) = Unit + """.trimIndent() + } + + result.assertCommonized( + "(a, b)", """ + expect class X() + expect class Y() + expect fun x(x: X>) + """.trimIndent() + ) + } + + fun `test nested arguments - with typealias`() { + val result = commonize { + outputTarget("(a, b)") + "a" withSource """ + class X + class Y + typealias TA = Y + fun x(x: X>) = Unit + fun y(x: X>) = Unit + """.trimIndent() + + "b" withSource """ + class X + class Y + typealias TA = Y + fun x(x: X>) = Unit + fun y(x: X>) = Unit + """.trimIndent() + } + + result.assertCommonized( + "(a, b)", """ + expect class X() + expect class Y() + typealias TA = Y + expect fun x(x: X>) + expect fun y(x: X>) + """.trimIndent() + ) + } + + fun `test KT-51686`() { + val result = commonize { + outputTarget("(a, b)") + "a" withSource """ + class CPointer + class CPointerVarOf> + class ByteVarOf + typealias ByteVar = ByteVarOf + typealias CPointerVar = CPointerVarOf> + + fun x(x: CPointer>) = Unit + """.trimIndent() + + "b" withSource """ + class CPointer + class CPointerVarOf> + class ByteVarOf + typealias ByteVar = ByteVarOf + typealias CPointerVar = CPointerVarOf> + + fun x(x: CPointer>) = Unit + """.trimIndent() + } + + result.assertCommonized( + "(a, b)", """ + expect class CPointer() + expect class CPointerVarOf>() + expect class ByteVarOf() + typealias ByteVar = ByteVarOf + typealias CPointerVar = CPointerVarOf> + + expect fun x(x: CPointer>) + """.trimIndent() + ) + } }