diff --git a/native/commonizer/src/org/jetbrains/kotlin/commonizer/core/ClassOrTypeAliasTypeCommonizer.kt b/native/commonizer/src/org/jetbrains/kotlin/commonizer/core/ClassOrTypeAliasTypeCommonizer.kt index 315921d9b63..c862084d79f 100644 --- a/native/commonizer/src/org/jetbrains/kotlin/commonizer/core/ClassOrTypeAliasTypeCommonizer.kt +++ b/native/commonizer/src/org/jetbrains/kotlin/commonizer/core/ClassOrTypeAliasTypeCommonizer.kt @@ -131,7 +131,6 @@ internal class ClassOrTypeAliasTypeCommonizer( ): CirClassOrTypeAliasType? { return generateSequence(sourceType.underlyingType) { type -> type.safeAs()?.underlyingType } .firstOrNull { underlyingType -> underlyingType.classifierId == destinationClassifierId } - ?.withParentArguments(sourceType.arguments, sourceType.isMarkedNullable) } private fun backwardsSubstitute( 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 a82d2f2e933..203de31cf89 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/ParameterizedTypesCommonizationTest.kt @@ -358,4 +358,108 @@ class ParameterizedTypesCommonizationTest : AbstractInlineSourcesCommonizationTe """.trimIndent() ) } + + fun `test parameterized function - 3`() { + val result = commonize { + outputTarget("(a, b)") + + simpleSingleSourceTarget( + "a", """ + class Foo + typealias Bar = Foo + fun fn(arg: Bar) {} + """.trimIndent() + ) + + simpleSingleSourceTarget( + "b", """ + class Foo + typealias Bar = Foo + fun fn(arg: Foo) {} + """.trimIndent() + ) + } + + result.assertCommonized( + "(a, b)", """ + expect class Foo() + typealias Bar = Foo + expect fun fn(arg: Foo) + """.trimIndent() + ) + } + + fun `test member function - 0`() { + val result = commonize { + outputTarget("(a, b)") + + simpleSingleSourceTarget( + "a", """ + class Foo { + fun t(x: Baz) = Unit + } + typealias Bar = Foo + typealias Baz = Bar + """.trimIndent() + ) + + simpleSingleSourceTarget( + "b", """ + class Foo { + fun t(x: Boo) {} + } + typealias Boo = Foo + + """.trimIndent() + ) + } + + result.assertCommonized( + "(a, b)", """ + expect class Foo() { + expect fun t(x: Foo) + } + """.trimIndent() + ) + } + + fun `test member function - 1`() { + val result = commonize { + outputTarget("(a, b)") + + simpleSingleSourceTarget( + "a", """ + class Foo { + fun t(x: Z) = Unit + } + + typealias X = Foo + typealias Y = X + typealias Z = Y + """.trimIndent() + ) + + simpleSingleSourceTarget( + "b", """ + class Foo { + fun t(x: Y) = Unit + } + + typealias X = Foo + typealias Y = X + """.trimIndent() + ) + } + + result.assertCommonized( + "(a, b)", """ + expect class Foo() { + expect fun t(x: Y) + } + + typealias X = Foo + typealias Y = X + """.trimIndent() + ) + } }