From 7bf62ab159e20b669e719425c4a5b4ceeed83b2e Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Mon, 20 Sep 2021 09:24:06 +0200 Subject: [PATCH] [Commonizer] Implement tests for 'crossed' type aliases ^KT-48288 --- ...hicalClassAndTypeAliasCommonizationTest.kt | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/HierarchicalClassAndTypeAliasCommonizationTest.kt b/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/HierarchicalClassAndTypeAliasCommonizationTest.kt index 7476c72befa..bce3a684e5a 100644 --- a/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/HierarchicalClassAndTypeAliasCommonizationTest.kt +++ b/native/commonizer/tests/org/jetbrains/kotlin/commonizer/hierarchical/HierarchicalClassAndTypeAliasCommonizationTest.kt @@ -642,4 +642,85 @@ class HierarchicalClassAndTypeAliasCommonizationTest : AbstractInlineSourcesComm """.trimIndent() ) } + + fun `test 'crossed' type aliases - 0`() { + val result = commonize { + outputTarget("(a, b)") + simpleSingleSourceTarget( + "a", """ + class X + class Y + + typealias A = X + typealias B = Y + + fun x(x: A) + fun x(x: B) + """.trimIndent() + ) + + simpleSingleSourceTarget( + "b", """ + class X + class Y + + typealias A = Y // NOTE: Y & X are swapped + typealias B = X // NOTE: Y & X are swapped + + fun x(x: A) + fun x(x: B) + """.trimIndent() + ) + } + + result.assertCommonized( + "(a, b)", """ + expect class X() + expect class Y() + expect class A() + expect class B() + expect fun x(x: A) + expect fun x(x: B) + """.trimIndent() + ) + } + + fun `test 'crossed' type aliases - 1`() { + val result = commonize { + outputTarget("(a, b)") + simpleSingleSourceTarget( + "a", """ + class X + class Y + + typealias A = X + typealias B = Y + + fun x(x: A) + """.trimIndent() + ) + + simpleSingleSourceTarget( + "b", """ + class X + class Y + + typealias A = Y // NOTE: Y & X are swapped + typealias B = X // NOTE: Y & X are swapped + + fun x(x: A) + """.trimIndent() + ) + } + + result.assertCommonized( + "(a, b)", """ + expect class X() + expect class Y() + expect class A() + expect class B() + expect fun x(x: A) + """.trimIndent() + ) + } }