From 38bcedc4516079d662c65d4eebb792802d43cdf9 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Mon, 8 Apr 2019 15:06:46 +0300 Subject: [PATCH] [Tests] Add tests for types refinement in IDE --- .../kotlin/generators/tests/GenerateTests.kt | 5 + .../aliasesTypeMismatch/common/common.kt | 9 ++ .../aliasesTypeMismatch/commonLibrary/lib.kt | 3 + .../aliasesTypeMismatch/dependencies.txt | 9 ++ .../aliasesTypeMismatch/jvm/jvm.kt | 9 ++ .../jvmLibrary/bindings.kt | 3 + .../aliasesTypeMismatch/jvmLibrary/core.kt | 7 + .../common-1-main/common-1-main.kt | 25 +++ .../callableReferences/common-1/common-1.kt | 20 +++ .../common-2-main/common-2-main.kt | 94 +++++++++++ .../callableReferences/common-2/common-2.kt | 24 +++ .../callableReferences/dependencies.txt | 15 ++ .../callableReferences/graph.txt | 11 ++ .../callableReferences/jvm-main/jvm-main.kt | 131 ++++++++++++++++ .../callableReferences/jvm/jvm.kt | 25 +++ .../constructorsOfExpect/common/common.kt | 3 + .../constructorsOfExpect/dependencies.txt | 4 + .../constructorsOfExpect/jvm/jvm.kt | 10 ++ .../common-1/common-1.kt | 13 ++ .../common-2-1/common-2-1.kt | 13 ++ .../common-2-2/common-2-2.kt | 13 ++ .../diamondModuleDependency1/dependencies.txt | 14 ++ .../diamondModuleDependency1/graph.txt | 17 ++ .../diamondModuleDependency1/jvm/jvm.kt | 23 +++ .../common-1/common-1.kt | 21 +++ .../common-2-1/common-2-1.kt | 12 ++ .../common-2-2/common-2-2.kt | 10 ++ .../common-2-3/common-2-3.kt | 16 ++ .../diamondModuleDependency2/dependencies.txt | 16 ++ .../diamondModuleDependency2/graph.txt | 25 +++ .../diamondModuleDependency2/jvm/jvm.kt | 45 ++++++ .../extensionOnExpect/common/common.kt | 3 + .../extensionOnExpect/dependencies.txt | 6 + .../extensionOnExpect/jvm/jvm.kt | 5 + .../extensionOnExpect/main/main.kt | 4 + .../jsNameClash/common/common.kt | 7 + .../jsNameClash/dependencies.txt | 5 + .../jsNameClash/js/js.kt | 10 ++ .../lambdas/common/common.kt | 9 ++ .../lambdas/dependencies.txt | 4 + .../lambdas/jvm/jvm.kt | 23 +++ .../languageConstructions/common/common.kt | 10 ++ .../languageConstructions/dependencies.txt | 7 + .../languageConstructions/jvm/jvm.kt | 14 ++ .../languageConstructions/main/main.kt | 20 +++ .../multilevelParents/common-1/common-1.kt | 18 +++ .../multilevelParents/common-2/common-2.kt | 38 +++++ .../multilevelParents/dependencies.txt | 8 + .../multilevelParents/graph.txt | 17 ++ .../multilevelParents/jvm/jvm.kt | 53 +++++++ .../qualifiedReceiver/common/common.kt | 18 +++ .../qualifiedReceiver/dependencies.txt | 6 + .../qualifiedReceiver/jvm/platform.kt | 15 ++ .../qualifiedReceiver/main/main.kt | 33 ++++ .../recursiveTypes/common/common.kt | 17 ++ .../recursiveTypes/dependencies.txt | 4 + .../recursiveTypes/jvm/jvm.kt | 24 +++ .../simple/d1/d1.kt | 2 + .../simple/d2/d2.kt | 4 + .../simple/d3/d3.kt | 5 + .../simple/d4/d4.kt | 6 + .../simple/dependencies.txt | 8 + .../supertypes/d0/d0.kt | 5 + .../supertypes/d1/d1.kt | 9 ++ .../supertypes/d2/d2.kt | 10 ++ .../supertypes/d3/d3.kt | 4 + .../supertypes/d4/d4.kt | 21 +++ .../supertypes/dependencies.txt | 11 ++ .../common/common.kt | 5 + .../dependencies.txt | 4 + .../jvm/jvm.kt | 10 ++ .../typeAliases/common/aliases.kt | 17 ++ .../typeAliases/dependencies.txt | 6 + .../typeAliases/jvm/aliases.kt | 18 +++ .../typeAliases/main/main.kt | 123 +++++++++++++++ .../typeParameters/common/common.kt | 15 ++ .../typeParameters/dependencies.txt | 6 + .../typeParameters/jvm/platform.kt | 19 +++ .../typeParameters/main/main.kt | 30 ++++ .../MultiplatformAnalysisTestGenerated.java | 147 ++++++++++++++++++ .../idea/stubs/AbstractMultiModuleTest.kt | 2 +- 81 files changed, 1509 insertions(+), 1 deletion(-) create mode 100644 idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/commonLibrary/lib.kt create mode 100644 idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvmLibrary/bindings.kt create mode 100644 idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvmLibrary/core.kt create mode 100644 idea/testData/multiplatformTypeRefinement/callableReferences/common-1-main/common-1-main.kt create mode 100644 idea/testData/multiplatformTypeRefinement/callableReferences/common-1/common-1.kt create mode 100644 idea/testData/multiplatformTypeRefinement/callableReferences/common-2-main/common-2-main.kt create mode 100644 idea/testData/multiplatformTypeRefinement/callableReferences/common-2/common-2.kt create mode 100644 idea/testData/multiplatformTypeRefinement/callableReferences/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/callableReferences/graph.txt create mode 100644 idea/testData/multiplatformTypeRefinement/callableReferences/jvm-main/jvm-main.kt create mode 100644 idea/testData/multiplatformTypeRefinement/callableReferences/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/constructorsOfExpect/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/constructorsOfExpect/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/constructorsOfExpect/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-1/common-1.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-2-1/common-2-1.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-2-2/common-2-2.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/graph.txt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-1/common-1.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-1/common-2-1.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-2/common-2-2.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-3/common-2-3.kt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/graph.txt create mode 100644 idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/extensionOnExpect/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/extensionOnExpect/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/extensionOnExpect/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/extensionOnExpect/main/main.kt create mode 100644 idea/testData/multiplatformTypeRefinement/jsNameClash/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/jsNameClash/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/jsNameClash/js/js.kt create mode 100644 idea/testData/multiplatformTypeRefinement/lambdas/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/lambdas/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/lambdas/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/languageConstructions/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/languageConstructions/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/languageConstructions/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/languageConstructions/main/main.kt create mode 100644 idea/testData/multiplatformTypeRefinement/multilevelParents/common-1/common-1.kt create mode 100644 idea/testData/multiplatformTypeRefinement/multilevelParents/common-2/common-2.kt create mode 100644 idea/testData/multiplatformTypeRefinement/multilevelParents/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/multilevelParents/graph.txt create mode 100644 idea/testData/multiplatformTypeRefinement/multilevelParents/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/qualifiedReceiver/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/qualifiedReceiver/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/qualifiedReceiver/jvm/platform.kt create mode 100644 idea/testData/multiplatformTypeRefinement/qualifiedReceiver/main/main.kt create mode 100644 idea/testData/multiplatformTypeRefinement/recursiveTypes/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/recursiveTypes/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/recursiveTypes/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/simple/d1/d1.kt create mode 100644 idea/testData/multiplatformTypeRefinement/simple/d2/d2.kt create mode 100644 idea/testData/multiplatformTypeRefinement/simple/d3/d3.kt create mode 100644 idea/testData/multiplatformTypeRefinement/simple/d4/d4.kt create mode 100644 idea/testData/multiplatformTypeRefinement/simple/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/supertypes/d0/d0.kt create mode 100644 idea/testData/multiplatformTypeRefinement/supertypes/d1/d1.kt create mode 100644 idea/testData/multiplatformTypeRefinement/supertypes/d2/d2.kt create mode 100644 idea/testData/multiplatformTypeRefinement/supertypes/d3/d3.kt create mode 100644 idea/testData/multiplatformTypeRefinement/supertypes/d4/d4.kt create mode 100644 idea/testData/multiplatformTypeRefinement/supertypes/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/jvm/jvm.kt create mode 100644 idea/testData/multiplatformTypeRefinement/typeAliases/common/aliases.kt create mode 100644 idea/testData/multiplatformTypeRefinement/typeAliases/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/typeAliases/jvm/aliases.kt create mode 100644 idea/testData/multiplatformTypeRefinement/typeAliases/main/main.kt create mode 100644 idea/testData/multiplatformTypeRefinement/typeParameters/common/common.kt create mode 100644 idea/testData/multiplatformTypeRefinement/typeParameters/dependencies.txt create mode 100644 idea/testData/multiplatformTypeRefinement/typeParameters/jvm/platform.kt create mode 100644 idea/testData/multiplatformTypeRefinement/typeParameters/main/main.kt create mode 100644 idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiplatformAnalysisTestGenerated.java diff --git a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 62e12184916..e688eb1ea87 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -673,6 +673,11 @@ fun main(args: Array) { model("multiModuleHighlighting/hierarchicalExpectActualMatching/", recursive = false, extension = null) } + testClass { + model("multiplatform", recursive = false, extension = null) + model("multiplatformTypeRefinement", recursive = false, extension = null) + } + testClass { model("multiModuleQuickFix", recursive = false, extension = null) } diff --git a/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/common/common.kt b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/common/common.kt new file mode 100644 index 00000000000..9165ee6ca4c --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/common/common.kt @@ -0,0 +1,9 @@ +@file:Suppress("UNUSED_PARAMETER") + +expect open class MyCancelException : MyIllegalStateException + +fun cancel(cause: MyCancelException) {} + +expect open class OtherException : MyIllegalStateException + +fun other(cause: OtherException) {} diff --git a/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/commonLibrary/lib.kt b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/commonLibrary/lib.kt new file mode 100644 index 00000000000..b089ad48d19 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/commonLibrary/lib.kt @@ -0,0 +1,3 @@ +public expect open class MyException + +public expect open class MyIllegalStateException : MyException \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/dependencies.txt b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/dependencies.txt new file mode 100644 index 00000000000..009919b5ed5 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/dependencies.txt @@ -0,0 +1,9 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE commonLibrary { platform=[JVM, JS, Native]; root=commonLibrary } +MODULE jvm { platform=[JVM]; root=jvm } +MODULE jvmLibrary { platform=[JVM]; root=jvmLibrary } + +common -> commonLibrary { kind=DEPENDENCY } +jvmLibrary -> commonLibrary { kind=DEPENDS_ON } +jvm -> commonLibrary, jvmLibrary { kind=DEPENDENCY } +jvm -> common { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvm/jvm.kt new file mode 100644 index 00000000000..5595c8ef7a0 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvm/jvm.kt @@ -0,0 +1,9 @@ +actual typealias MyCancelException = platform.lib.MyCancellationException + +actual open class OtherException : platform.lib.MyIllegalStateException() + +fun test() { + cancel(MyCancelException()) // TYPE_MISMATCH + + other(OtherException()) +} diff --git a/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvmLibrary/bindings.kt b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvmLibrary/bindings.kt new file mode 100644 index 00000000000..0a03dd29ca8 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvmLibrary/bindings.kt @@ -0,0 +1,3 @@ +actual typealias MyException = platform.lib.MyException + +actual typealias MyIllegalStateException = platform.lib.MyIllegalStateException \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvmLibrary/core.kt b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvmLibrary/core.kt new file mode 100644 index 00000000000..cf9578251a6 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/jvmLibrary/core.kt @@ -0,0 +1,7 @@ +package platform.lib + +open class MyException + +open class MyIllegalStateException : MyException() + +open class MyCancellationException : MyIllegalStateException() \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/callableReferences/common-1-main/common-1-main.kt b/idea/testData/multiplatformTypeRefinement/callableReferences/common-1-main/common-1-main.kt new file mode 100644 index 00000000000..9e87545f2b6 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/callableReferences/common-1-main/common-1-main.kt @@ -0,0 +1,25 @@ +package sample + +fun test_1() { + take_A_common_1(A::common_1_A) + take_A_alias_common_1(A::common_1_A) +} + +fun test_2() { + take_B_common_1(B::common_1_A) + take_B_alias_common_1(B::common_1_A) + take_B_common_1(B::common_1_B) + take_B_alias_common_1(B::common_1_B) +} + +fun test_3() { + take_A_common_1(A_Common_1_Alias::common_1_A) + take_A_alias_common_1(A_Common_1_Alias::common_1_A) +} + +fun test_4() { + take_B_common_1(B_Common_1_Alias::common_1_A) + take_B_alias_common_1(B_Common_1_Alias::common_1_A) + take_B_common_1(B_Common_1_Alias::common_1_B) + take_B_alias_common_1(B_Common_1_Alias::common_1_B) +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/callableReferences/common-1/common-1.kt b/idea/testData/multiplatformTypeRefinement/callableReferences/common-1/common-1.kt new file mode 100644 index 00000000000..936a5830396 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/callableReferences/common-1/common-1.kt @@ -0,0 +1,20 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +expect interface A { + fun common_1_A() +} + +expect interface B : A { + fun common_1_B() +} + +typealias A_Common_1_Alias = A +typealias B_Common_1_Alias = B + +fun take_A_common_1(func: (A) -> Unit) {} +fun take_B_common_1(func: (B) -> Unit) {} + +fun take_A_alias_common_1(func: (A_Common_1_Alias) -> Unit) {} +fun take_B_alias_common_1(func: (B_Common_1_Alias) -> Unit) {} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/callableReferences/common-2-main/common-2-main.kt b/idea/testData/multiplatformTypeRefinement/callableReferences/common-2-main/common-2-main.kt new file mode 100644 index 00000000000..d830a544d6d --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/callableReferences/common-2-main/common-2-main.kt @@ -0,0 +1,94 @@ +package sample + +fun test_1() { + take_A_common_1(A::common_1_A) + take_A_alias_common_1(A::common_1_A) + take_A_common_1(A::common_2_A) + take_A_alias_common_1(A::common_2_A) + take_A_common_1(C::common_2_C) + take_A_alias_common_1(C::common_2_C) +} + +fun test_1_alias_1() { + take_A_common_1(A_Common_1_Alias::common_1_A) + take_A_alias_common_1(A_Common_1_Alias::common_1_A) + take_A_common_1(A_Common_1_Alias::common_2_A) + take_A_alias_common_1(A_Common_1_Alias::common_2_A) +} + +fun test_1_alias_2() { + take_A_common_1(A_Common_2_Alias::common_1_A) + take_A_alias_common_1(A_Common_2_Alias::common_1_A) + take_A_common_1(A_Common_2_Alias::common_2_A) + take_A_alias_common_1(A_Common_2_Alias::common_2_A) + take_A_common_1(C_Common_2_Alias::common_2_C) + take_A_alias_common_1(C_Common_2_Alias::common_2_C) +} + +fun test_2() { + take_A_common_2(A::common_2_A) + take_A_alias_common_2(A::common_2_A) + take_A_common_2(A::common_2_A) + take_A_alias_common_2(A::common_2_A) + take_A_common_2(C::common_2_C) + take_A_alias_common_2(C::common_2_C) +} + +fun test_2_alias_1() { + take_A_common_2(A_Common_1_Alias::common_2_A) + take_A_alias_common_2(A_Common_1_Alias::common_2_A) + take_A_common_2(A_Common_1_Alias::common_2_A) + take_A_alias_common_2(A_Common_1_Alias::common_2_A) +} + +fun test_2_alias_2() { + take_A_common_2(A_Common_2_Alias::common_2_A) + take_A_alias_common_2(A_Common_2_Alias::common_2_A) + take_A_common_2(A_Common_2_Alias::common_2_A) + take_A_alias_common_2(A_Common_2_Alias::common_2_A) + take_A_common_2(C_Common_2_Alias::common_2_C) + take_A_alias_common_2(C_Common_2_Alias::common_2_C) +} + +fun test_3() { + take_C_common_2(C::common_2_C) + take_C_alias_common_2(C::common_2_C) + take_C_common_2(C_Common_2_Alias::common_2_C) + take_C_alias_common_2(C_Common_2_Alias::common_2_C) +} + +fun test_4() { + take_B_common_1(B::common_1_A) + take_B_common_1(B::common_2_A) + take_B_common_2(B::common_1_A) + take_B_common_2(B::common_2_A) + + take_B_alias_common_1(B::common_1_A) + take_B_alias_common_1(B::common_2_A) + take_B_alias_common_2(B::common_1_A) + take_B_alias_common_2(B::common_2_A) +} + +fun test_4_alias_1() { + take_B_common_1(B_Common_1_Alias::common_1_A) + take_B_common_1(B_Common_1_Alias::common_2_A) + take_B_common_2(B_Common_1_Alias::common_1_A) + take_B_common_2(B_Common_1_Alias::common_2_A) + + take_B_alias_common_1(B_Common_1_Alias::common_1_A) + take_B_alias_common_1(B_Common_1_Alias::common_2_A) + take_B_alias_common_2(B_Common_1_Alias::common_1_A) + take_B_alias_common_2(B_Common_1_Alias::common_2_A) +} + +fun test_4_alias_2() { + take_B_common_1(B_Common_2_Alias::common_1_A) + take_B_common_1(B_Common_2_Alias::common_2_A) + take_B_common_2(B_Common_2_Alias::common_1_A) + take_B_common_2(B_Common_2_Alias::common_2_A) + + take_B_alias_common_1(B_Common_2_Alias::common_1_A) + take_B_alias_common_1(B_Common_2_Alias::common_2_A) + take_B_alias_common_2(B_Common_2_Alias::common_1_A) + take_B_alias_common_2(B_Common_2_Alias::common_2_A) +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/callableReferences/common-2/common-2.kt b/idea/testData/multiplatformTypeRefinement/callableReferences/common-2/common-2.kt new file mode 100644 index 00000000000..3d02aceaae2 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/callableReferences/common-2/common-2.kt @@ -0,0 +1,24 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +expect interface C { + fun common_2_C() +} + +actual interface A : C { + actual fun common_1_A() + fun common_2_A() +} + +typealias A_Common_2_Alias = A +typealias B_Common_2_Alias = B +typealias C_Common_2_Alias = C + +fun take_A_common_2(func: (A) -> Unit) {} +fun take_B_common_2(func: (B) -> Unit) {} +fun take_C_common_2(func: (C) -> Unit) {} + +fun take_A_alias_common_2(func: (A_Common_2_Alias) -> Unit) {} +fun take_B_alias_common_2(func: (B_Common_2_Alias) -> Unit) {} +fun take_C_alias_common_2(func: (C_Common_2_Alias) -> Unit) {} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/callableReferences/dependencies.txt b/idea/testData/multiplatformTypeRefinement/callableReferences/dependencies.txt new file mode 100644 index 00000000000..48b5fead5ad --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/callableReferences/dependencies.txt @@ -0,0 +1,15 @@ +MODULE common-1 { platform=[JVM, JS, Native] } +MODULE common-1-main { platform=[JVM, JS, Native] } + +MODULE common-2 { platform=[JVM, JS, Native] } +MODULE common-2-main { platform=[JVM, JS, Native] } + +MODULE jvm { platform=[JVM] } +MODULE jvm-main { platform=[JVM] } + +common-2 -> common-1 { kind=DEPENDS_ON } +jvm -> common-2 { kind=DEPENDS_ON } + +common-1-main -> common-1 { kind=DEPENDENCY } +common-2-main -> common-2, common-1 { kind=DEPENDENCY } +jvm-main -> jvm, common-2, common-1 { kind=DEPENDENCY } diff --git a/idea/testData/multiplatformTypeRefinement/callableReferences/graph.txt b/idea/testData/multiplatformTypeRefinement/callableReferences/graph.txt new file mode 100644 index 00000000000..577a2500b7f --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/callableReferences/graph.txt @@ -0,0 +1,11 @@ +This file presents modules dependency graph for the test (classes). +Please, use monospaced font. + + + common-1 ---- common-1-main + | + | + common-2 ---- common-2-main + | + | + jvm ------ jvm-main \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/callableReferences/jvm-main/jvm-main.kt b/idea/testData/multiplatformTypeRefinement/callableReferences/jvm-main/jvm-main.kt new file mode 100644 index 00000000000..78fc4021daa --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/callableReferences/jvm-main/jvm-main.kt @@ -0,0 +1,131 @@ +package sample + +fun test_1() { + take_C_common_2(C::common_2_C) + take_C_alias_common_2(C::common_2_C) + take_C_jvm(C::common_2_C) + take_C_alias_jvm(C::common_2_C) + + take_C_common_2(C::jvm_C) + take_C_alias_common_2(C::jvm_C) + take_C_jvm(C::jvm_C) + take_C_alias_jvm(C::jvm_C) +} + +fun test_1_alias_1() { + take_C_common_2(C_Common_2_Alias::common_2_C) + take_C_alias_common_2(C_Common_2_Alias::common_2_C) + take_C_jvm(C_Common_2_Alias::common_2_C) + take_C_alias_jvm(C_Common_2_Alias::common_2_C) + + take_C_common_2(C_Common_2_Alias::jvm_C) + take_C_alias_common_2(C_Common_2_Alias::jvm_C) + take_C_jvm(C_Common_2_Alias::jvm_C) + take_C_alias_jvm(C_Common_2_Alias::jvm_C) +} + +fun test_1_alias_2() { + take_C_common_2(C_jvm_Alias::common_2_C) + take_C_alias_common_2(C_jvm_Alias::common_2_C) + take_C_jvm(C_jvm_Alias::common_2_C) + take_C_alias_jvm(C_jvm_Alias::common_2_C) + + take_C_common_2(C_jvm_Alias::jvm_C) + take_C_alias_common_2(C_jvm_Alias::jvm_C) + take_C_jvm(C_jvm_Alias::jvm_C) + take_C_alias_jvm(C_jvm_Alias::jvm_C) +} + +fun test_2() { + take_A_common_1(C::jvm_C) + take_A_common_2(C::jvm_C) + take_A_jvm(C::jvm_C) + + take_A_common_1(C::common_2_C) + take_A_common_2(C::common_2_C) + take_A_jvm(C::common_2_C) +} + +fun test_2_alias_1() { + take_A_common_1(C_Common_2_Alias::jvm_C) + take_A_common_2(C_Common_2_Alias::jvm_C) + take_A_jvm(C_Common_2_Alias::jvm_C) + + take_A_common_1(C_Common_2_Alias::common_2_C) + take_A_common_2(C_Common_2_Alias::common_2_C) + take_A_jvm(C_Common_2_Alias::common_2_C) +} + +fun test_2_alias_2() { + take_A_common_1(C_jvm_Alias::jvm_C) + take_A_common_2(C_jvm_Alias::jvm_C) + take_A_jvm(C_jvm_Alias::jvm_C) + + take_A_common_1(C_jvm_Alias::common_2_C) + take_A_common_2(C_jvm_Alias::common_2_C) + take_A_jvm(C_jvm_Alias::common_2_C) +} + +fun test_3() { + take_B_common_1(B::common_1_B) + take_B_common_2(B::common_1_B) + take_B_jvm(B::common_1_B) + take_B_common_1(B::jvm_B) + take_B_common_2(B::jvm_B) + take_B_jvm(B::jvm_B) + + take_B_alias_common_1(B::common_1_B) + take_B_alias_common_2(B::common_1_B) + take_B_alias_jvm(B::common_1_B) + take_B_alias_common_1(B::jvm_B) + take_B_alias_common_2(B::jvm_B) + take_B_alias_jvm(B::jvm_B) +} + +fun test_3_alias_1() { + take_B_common_1(B_Common_1_Alias::common_1_B) + take_B_common_2(B_Common_1_Alias::common_1_B) + take_B_jvm(B_Common_1_Alias::common_1_B) + take_B_common_1(B_Common_1_Alias::jvm_B) + take_B_common_2(B_Common_1_Alias::jvm_B) + take_B_jvm(B_Common_1_Alias::jvm_B) + + take_B_alias_common_1(B_Common_1_Alias::common_1_B) + take_B_alias_common_2(B_Common_1_Alias::common_1_B) + take_B_alias_jvm(B_Common_1_Alias::common_1_B) + take_B_alias_common_1(B_Common_1_Alias::jvm_B) + take_B_alias_common_2(B_Common_1_Alias::jvm_B) + take_B_alias_jvm(B_Common_1_Alias::jvm_B) +} + +fun test_3_alias_2() { + take_B_common_1(B_Common_2_Alias::common_1_B) + take_B_common_2(B_Common_2_Alias::common_1_B) + take_B_jvm(B_Common_2_Alias::common_1_B) + take_B_common_1(B_Common_2_Alias::jvm_B) + take_B_common_2(B_Common_2_Alias::jvm_B) + take_B_jvm(B_Common_2_Alias::jvm_B) + + take_B_alias_common_1(B_Common_2_Alias::common_1_B) + take_B_alias_common_2(B_Common_2_Alias::common_1_B) + take_B_alias_jvm(B_Common_2_Alias::common_1_B) + take_B_alias_common_1(B_Common_2_Alias::jvm_B) + take_B_alias_common_2(B_Common_2_Alias::jvm_B) + take_B_alias_jvm(B_Common_2_Alias::jvm_B) +} + +fun test_3_alias_3() { + take_B_common_1(B_jvm_Alias::common_1_B) + take_B_common_2(B_jvm_Alias::common_1_B) + take_B_jvm(B_jvm_Alias::common_1_B) + take_B_common_1(B_jvm_Alias::jvm_B) + take_B_common_2(B_jvm_Alias::jvm_B) + take_B_jvm(B_jvm_Alias::jvm_B) + + take_B_alias_common_1(B_jvm_Alias::common_1_B) + take_B_alias_common_2(B_jvm_Alias::common_1_B) + take_B_alias_jvm(B_jvm_Alias::common_1_B) + take_B_alias_common_1(B_jvm_Alias::jvm_B) + take_B_alias_common_2(B_jvm_Alias::jvm_B) + take_B_alias_jvm(B_jvm_Alias::jvm_B) +} diff --git a/idea/testData/multiplatformTypeRefinement/callableReferences/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/callableReferences/jvm/jvm.kt new file mode 100644 index 00000000000..3cbbfae12ef --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/callableReferences/jvm/jvm.kt @@ -0,0 +1,25 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +actual interface C { + actual fun common_2_C() + fun jvm_C() +} + +actual interface B : A { + actual fun common_1_B() + fun jvm_B() +} + +typealias A_jvm_Alias = A +typealias B_jvm_Alias = B +typealias C_jvm_Alias = C + +fun take_A_jvm(func: (A) -> Unit) {} +fun take_B_jvm(func: (B) -> Unit) {} +fun take_C_jvm(func: (C) -> Unit) {} + +fun take_A_alias_jvm(func: (A_jvm_Alias) -> Unit) {} +fun take_B_alias_jvm(func: (B_jvm_Alias) -> Unit) {} +fun take_C_alias_jvm(func: (C_jvm_Alias) -> Unit) {} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/common/common.kt b/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/common/common.kt new file mode 100644 index 00000000000..a4a56d42678 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/common/common.kt @@ -0,0 +1,3 @@ +expect class A { + fun commonMember() +} diff --git a/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/dependencies.txt b/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/dependencies.txt new file mode 100644 index 00000000000..549b0097cf5 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/dependencies.txt @@ -0,0 +1,4 @@ +MODULE common { platform=[JVM, JS, Native] } +MODULE jvm { platform=[JVM] } + +jvm -> common { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/jvm/jvm.kt new file mode 100644 index 00000000000..176156e3830 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/constructorsOfExpect/jvm/jvm.kt @@ -0,0 +1,10 @@ +actual class A { + actual fun commonMember() { } + + fun platformMember() { } +} + +fun test() { + A().commonMember() + A().platformMember() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-1/common-1.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-1/common-1.kt new file mode 100644 index 00000000000..16984b10298 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-1/common-1.kt @@ -0,0 +1,13 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +// -------------------------------------------- + +expect interface A { + fun foo() +} + +fun take_A_common_1(x: A) { + x.foo() +} diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-2-1/common-2-1.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-2-1/common-2-1.kt new file mode 100644 index 00000000000..b1b7436c281 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-2-1/common-2-1.kt @@ -0,0 +1,13 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +actual interface A { + actual fun foo() + fun bar() +} + +fun take_A_common_2_1(x: A) { + x.foo() + x.bar() +} diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-2-2/common-2-2.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-2-2/common-2-2.kt new file mode 100644 index 00000000000..c66f893d494 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/common-2-2/common-2-2.kt @@ -0,0 +1,13 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +actual interface A { + actual fun foo() + fun baz() +} + +fun take_A_common_2_2(x: A) { + x.foo() + x.baz() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/dependencies.txt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/dependencies.txt new file mode 100644 index 00000000000..e5aff527283 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/dependencies.txt @@ -0,0 +1,14 @@ +MODULE common-1 { platform=[JVM, JS, Native]; root=common-1 } + +MODULE common-2-1 { platform=[JVM]; root=common-2-1 } +MODULE common-2-2 { platform=[JVM]; root=common-2-2 } + +MODULE jvm { platform=[JVM]; root=jvm } + +common-2-1 -> common-1 { kind=DEPENDS_ON } +common-2-2 -> common-1 { kind=DEPENDS_ON } + +jvm -> common-2-1, common-2-2 { kind=DEPENDENCY } + +// TODO: remove closure +jvm -> common-1 { kind=DEPENDENCY } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/graph.txt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/graph.txt new file mode 100644 index 00000000000..87a6f191732 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/graph.txt @@ -0,0 +1,17 @@ +This file presents modules dependency graph for the test (classes). +Please, use monospaced font. + + common-1 + / \ + / \ + / \ + / \ + / \ + common-2-1 common-2-2 + \ / + \ / + \ / + \ / + \ / + \ / + jvm \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/jvm/jvm.kt new file mode 100644 index 00000000000..88c93c3f866 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/jvm/jvm.kt @@ -0,0 +1,23 @@ +package sample + +interface B : A + +fun testA(x: A) { + x.foo() + x.bar() + x.baz() + + take_A_common_1(x) + take_A_common_2_1(x) + take_A_common_2_2(x) +} + +fun testB(x: B) { + x.foo() + x.bar() + x.baz() + + take_A_common_1(x) + take_A_common_2_1(x) + take_A_common_2_2(x) // here we should have some error +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-1/common-1.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-1/common-1.kt new file mode 100644 index 00000000000..bb69e60f25a --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-1/common-1.kt @@ -0,0 +1,21 @@ +@file:Suppress("UNUSED_PARAMETER") +package sample + +interface AA +interface BB +interface CC +interface DD + +expect interface A { + fun foo_A() +} + +fun take0(x: A): AA = null!! +fun take1(x: A): AA = null!! +fun take2(x: A): AA = null!! +fun take3(x: A): AA = null!! +fun take4(x: A): AA = null!! + +fun test(x: A) { + take4(x) +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-1/common-2-1.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-1/common-2-1.kt new file mode 100644 index 00000000000..fc55ae8f0f3 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-1/common-2-1.kt @@ -0,0 +1,12 @@ +@file:Suppress("UNUSED_PARAMETER") +package sample + +expect interface B : A { + fun foo_B_1() +} + +fun take1(x: B): BB = null!! +fun take2(x: B): BB = null!! +fun take3(x: B): BB = null!! + +fun getB(): B = null!! \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-2/common-2-2.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-2/common-2-2.kt new file mode 100644 index 00000000000..e3c86b64062 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-2/common-2-2.kt @@ -0,0 +1,10 @@ +@file:Suppress("UNUSED_PARAMETER") +package sample + +expect interface C : A { + fun foo_C_1() +} + +fun take1(x: C): CC = null!! + +fun getC(): C = null!! \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-3/common-2-3.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-3/common-2-3.kt new file mode 100644 index 00000000000..3e964ba006d --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/common-2-3/common-2-3.kt @@ -0,0 +1,16 @@ +@file:Suppress("UNUSED_PARAMETER") +package sample + +actual interface A { + actual fun foo_A() + fun foo_A_3() +} + +fun take0(x: A): DD = null!! +fun take1(x: A): DD = null!! +fun take2(x: A): DD = null!! +fun take4(x: A): DD = null!! + +fun test(x: A) { + take4(x) +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/dependencies.txt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/dependencies.txt new file mode 100644 index 00000000000..57fe132ef41 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/dependencies.txt @@ -0,0 +1,16 @@ +MODULE common-1 { platform=[JVM, JS, Native] } + +MODULE common-2-1 { platform=[JVM, JS, Native] } +MODULE common-2-2 { platform=[JVM, JS, Native] } +MODULE common-2-3 { platform=[JVM, JS, Native] } + +MODULE jvm { platform=[JVM] } + +common-2-1 -> common-1 { kind=DEPENDS_ON } +common-2-2 -> common-1 { kind=DEPENDS_ON } +common-2-3 -> common-1 { kind=DEPENDS_ON } + +jvm -> common-2-1, common-2-2 { kind=DEPENDS_ON } +jvm -> common-2-3 { kind=DEPENDS_ON } + +jvm -> common-1 { kind=DEPENDS_ON } diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/graph.txt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/graph.txt new file mode 100644 index 00000000000..4fded797c58 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/graph.txt @@ -0,0 +1,25 @@ +This file presents modules dependency graph for the test (classes). +Please, use monospaced font. + + common-1-1 + / | \ + / | \ + / | \ + / | \ + / | \ + / | \ + / | \ + / | \ + / | \ + common-2-1 common-2-2 common-2-2 + \ | / + \ | / + \ | / + \ | / + \ | / + \ | / + \ | / + \ | / + \ | / + \ | / + jvm \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/jvm/jvm.kt new file mode 100644 index 00000000000..44718cdd647 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/jvm/jvm.kt @@ -0,0 +1,45 @@ +@file:Suppress("UNUSED_PARAMETER", "UNUSED_VARIABLE") +package sample + +interface D : A { + fun foo_B_1() + fun foo_B_2() + fun foo_C_1() + fun foo_C_2() + fun foo_D() +} + +actual typealias B = D +actual typealias C = D + +fun take0(x: D): Unit = null!! + +fun test_1(x: D) { + val res0: Unit = take0(x) + take1(x) + val res2: BB = take2(x) + val res3: BB = take3(x) + take4(x) +} + +fun test_2() { + val x = getB() + x.foo_A() + x.foo_A_3() + x.foo_B_1() + x.foo_B_2() + x.foo_C_1() + x.foo_C_2() + x.foo_D() +} + +fun test_3() { + val x = getB() + x.foo_A() + x.foo_A_3() + x.foo_B_1() + x.foo_B_2() + x.foo_C_1() + x.foo_C_2() + x.foo_D() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/extensionOnExpect/common/common.kt b/idea/testData/multiplatformTypeRefinement/extensionOnExpect/common/common.kt new file mode 100644 index 00000000000..f5ed5d3c5e8 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/extensionOnExpect/common/common.kt @@ -0,0 +1,3 @@ +expect class E { + fun commonMember() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/extensionOnExpect/dependencies.txt b/idea/testData/multiplatformTypeRefinement/extensionOnExpect/dependencies.txt new file mode 100644 index 00000000000..98f9e64620b --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/extensionOnExpect/dependencies.txt @@ -0,0 +1,6 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } +MODULE main { platform=[JVM]; root=main } + +jvm -> common { kind=DEPENDS_ON } +main -> jvm { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/extensionOnExpect/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/extensionOnExpect/jvm/jvm.kt new file mode 100644 index 00000000000..0bfd36b512d --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/extensionOnExpect/jvm/jvm.kt @@ -0,0 +1,5 @@ +actual class E { + actual fun commonMember() {} + + fun platformMember() {} +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/extensionOnExpect/main/main.kt b/idea/testData/multiplatformTypeRefinement/extensionOnExpect/main/main.kt new file mode 100644 index 00000000000..d4cf3f3ea58 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/extensionOnExpect/main/main.kt @@ -0,0 +1,4 @@ +fun E.test() { + commonMember() + platformMember() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/jsNameClash/common/common.kt b/idea/testData/multiplatformTypeRefinement/jsNameClash/common/common.kt new file mode 100644 index 00000000000..173ec86e912 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/jsNameClash/common/common.kt @@ -0,0 +1,7 @@ +package sample + +expect interface Input + +abstract class AbstractInput : Input { + val head: Int = null!! +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/jsNameClash/dependencies.txt b/idea/testData/multiplatformTypeRefinement/jsNameClash/dependencies.txt new file mode 100644 index 00000000000..157e0cfded1 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/jsNameClash/dependencies.txt @@ -0,0 +1,5 @@ +MODULE common { platform=[JVM, JS, Native] } + +MODULE js { platform=[JS] } + +js -> common { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/jsNameClash/js/js.kt b/idea/testData/multiplatformTypeRefinement/jsNameClash/js/js.kt new file mode 100644 index 00000000000..826ddab533e --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/jsNameClash/js/js.kt @@ -0,0 +1,10 @@ +package sample + +actual interface Input + +class JSInput : AbstractInput() + +// ------------------------------------ + +expect class ExpectInJsActualInJs +actual class ExpectInJsActualInJs \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/lambdas/common/common.kt b/idea/testData/multiplatformTypeRefinement/lambdas/common/common.kt new file mode 100644 index 00000000000..d99edc5c950 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/lambdas/common/common.kt @@ -0,0 +1,9 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +expect interface A + +fun useA(block: A.() -> Unit) {} + +fun anotherUseA(block: (A) -> Unit) {} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/lambdas/dependencies.txt b/idea/testData/multiplatformTypeRefinement/lambdas/dependencies.txt new file mode 100644 index 00000000000..549b0097cf5 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/lambdas/dependencies.txt @@ -0,0 +1,4 @@ +MODULE common { platform=[JVM, JS, Native] } +MODULE jvm { platform=[JVM] } + +jvm -> common { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/lambdas/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/lambdas/jvm/jvm.kt new file mode 100644 index 00000000000..e67f8c39f8f --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/lambdas/jvm/jvm.kt @@ -0,0 +1,23 @@ +package sample + +actual interface A { + fun foo() +} + +fun test() { + useA { + foo() + } + + anotherUseA { + foo() + } + + anotherUseA { + it.foo() + } + + anotherUseA { a -> + a.foo() + } +} diff --git a/idea/testData/multiplatformTypeRefinement/languageConstructions/common/common.kt b/idea/testData/multiplatformTypeRefinement/languageConstructions/common/common.kt new file mode 100644 index 00000000000..01466bf5ea4 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/languageConstructions/common/common.kt @@ -0,0 +1,10 @@ +package sample + +expect class A { + fun commonFun() + val x: Int + val y: Double + val z: String +} + +fun getCommonA(): A = null!! \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/languageConstructions/dependencies.txt b/idea/testData/multiplatformTypeRefinement/languageConstructions/dependencies.txt new file mode 100644 index 00000000000..9176664406b --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/languageConstructions/dependencies.txt @@ -0,0 +1,7 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } +MODULE main { platform=[JVM]; root=main } + +jvm -> common { kind=DEPENDS_ON } +jvm -> STDLIB_JVM { kind=DEPENDENCY } +main -> jvm, common { kind=DEPENDENCY } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/languageConstructions/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/languageConstructions/jvm/jvm.kt new file mode 100644 index 00000000000..d7e898984a7 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/languageConstructions/jvm/jvm.kt @@ -0,0 +1,14 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +actual data class A(actual val x: Int, actual val y: Double, val t: String) { + actual fun commonFun() {} + fun platformFun() {} + + actual val z: String by lazy { "" } + + operator fun iterator(): Iterator = null!! +} + +fun testDelegate(): String = getCommonA().z \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/languageConstructions/main/main.kt b/idea/testData/multiplatformTypeRefinement/languageConstructions/main/main.kt new file mode 100644 index 00000000000..fcb15eb4f9c --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/languageConstructions/main/main.kt @@ -0,0 +1,20 @@ +@file:Suppress("UNUSED_VARIABLE") + +package sample + +fun testDesctructing() { + val (x, y, t) = getCommonA() + val xx: Int = x + val yy: Double = y + val tt: String = t +} + +fun testIterator(): Int { + var counter: Int = 0 + for (x in getCommonA()) { + counter += x + } + return counter +} + +fun testDelegate(): String = getCommonA().z \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/multilevelParents/common-1/common-1.kt b/idea/testData/multiplatformTypeRefinement/multilevelParents/common-1/common-1.kt new file mode 100644 index 00000000000..9691edc3642 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/multilevelParents/common-1/common-1.kt @@ -0,0 +1,18 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +expect interface A { + fun common_1_A() +} + +expect interface B : A { + fun common_1_B() +} + +fun getB(): B = null!! + +class Out(val value: T) + +fun takeOutA_common_1(t: Out) {} +fun takeOutB_common_1(t: Out) {} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/multilevelParents/common-2/common-2.kt b/idea/testData/multiplatformTypeRefinement/multilevelParents/common-2/common-2.kt new file mode 100644 index 00000000000..091ad08f3e4 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/multilevelParents/common-2/common-2.kt @@ -0,0 +1,38 @@ +@file:Suppress("UNUSED_PARAMETER") + +package sample + +expect interface A_Common { + fun common_1_A() + fun common_2_A() +} + +actual typealias A = A_Common + +actual interface B : A { + actual fun common_1_B() + fun common_1_2_B() +} + +fun takeOutA_common_2(t: Out) {} +fun takeOutB_common_2(t: Out) {} +fun takeOutA_Common_common_2(t: Out) {} + +fun getOutA(): Out = null!! +fun getOutB(): Out = null!! +fun getOutA_Common(): Out = null!! + +fun test_case_2(x: B) { + x.common_1_A() + x.common_1_B() + x.common_2_A() + x.common_1_2_B() +} + +fun test_B() { + val x = getB() + x.common_1_A() + x.common_1_B() + x.common_2_A() + x.common_1_2_B() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/multilevelParents/dependencies.txt b/idea/testData/multiplatformTypeRefinement/multilevelParents/dependencies.txt new file mode 100644 index 00000000000..e0f8bf50196 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/multilevelParents/dependencies.txt @@ -0,0 +1,8 @@ +MODULE common-1 { platform=[JVM, JS, Native]; root=common-1 } +MODULE common-2 { platform=[JVM, JS, Native]; root=common-2 } + +MODULE jvm { platform=[JVM]; root=jvm } + +common-2 -> common-1 { kind=DEPENDS_ON } + +jvm -> common-2 { kind=DEPENDS_ON } diff --git a/idea/testData/multiplatformTypeRefinement/multilevelParents/graph.txt b/idea/testData/multiplatformTypeRefinement/multilevelParents/graph.txt new file mode 100644 index 00000000000..154e4157f7a --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/multilevelParents/graph.txt @@ -0,0 +1,17 @@ +This file presents modules dependency graph for the test (classes). +Please, use monospaced font. + + + common-1 + | + | + | + | + | + common-2 + | + | + | + | + | + jvm \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/multilevelParents/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/multilevelParents/jvm/jvm.kt new file mode 100644 index 00000000000..9492bff1f2f --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/multilevelParents/jvm/jvm.kt @@ -0,0 +1,53 @@ +package sample + +actual interface A_Common { + actual fun common_1_A() + actual fun common_2_A() + fun jvm_A() +} + +interface Case_2_3 : B { + fun jvm_Case_2_3() +} + +fun test_A(x: B) { + x.common_1_A() + x.common_1_B() + x.common_2_A() + x.common_1_2_B() + x.jvm_A() +} + +fun test_A(x: Case_2_3) { + x.common_1_A() + x.common_1_B() + x.common_2_A() + x.common_1_2_B() + x.jvm_A() + x.jvm_Case_2_3() +} + +fun test_B() { + val x = getB() + x.common_1_A() + x.common_1_B() + x.common_2_A() + x.common_1_2_B() + x.jvm_A() +} + +fun test_case_2_3() { + takeOutA_common_1(getOutB()) + takeOutB_common_1(getOutB()) + takeOutA_common_2(getOutB()) + takeOutB_common_2(getOutB()) + takeOutA_Common_common_2(getOutB()) + + takeOutA_common_1(getOutA()) + takeOutA_common_2(getOutA()) + takeOutA_Common_common_2(getOutA()) + + takeOutA_common_1(getOutA_Common()) + takeOutA_common_2(getOutA_Common()) + takeOutA_Common_common_2(getOutA_Common()) +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/common/common.kt b/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/common/common.kt new file mode 100644 index 00000000000..9ab6c434c83 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/common/common.kt @@ -0,0 +1,18 @@ +@file:Suppress("NO_ACTUAL_FOR_EXPECT") + +package foo + +expect interface A { + fun commonFun() + val b: B + fun bFun(): B +} + +expect interface B { + fun commonFunB() +} + +class Common { + val a: A get() = null!! + fun aFun(): A = null!! +} diff --git a/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/dependencies.txt b/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/dependencies.txt new file mode 100644 index 00000000000..98f9e64620b --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/dependencies.txt @@ -0,0 +1,6 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } +MODULE main { platform=[JVM]; root=main } + +jvm -> common { kind=DEPENDS_ON } +main -> jvm { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/jvm/platform.kt b/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/jvm/platform.kt new file mode 100644 index 00000000000..4a3de83d101 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/jvm/platform.kt @@ -0,0 +1,15 @@ +@file:Suppress("ACTUAL_WITHOUT_EXPECT") + +package foo + +actual interface A { + actual fun commonFun() + actual val b: B + actual fun bFun(): B + fun platformFun() +} + +actual interface B { + actual fun commonFunB() + fun platformFunB() +} diff --git a/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/main/main.kt b/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/main/main.kt new file mode 100644 index 00000000000..3f0924a9675 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/qualifiedReceiver/main/main.kt @@ -0,0 +1,33 @@ +package foo + +fun test_a(a: A) { + a.commonFun() + a.platformFun() + + a.b.commonFunB() + a.b.platformFunB() + + a.bFun().commonFunB() + a.bFun().platformFunB() +} + +fun test_c(c: Common) { + c.a.commonFun() + c.a.platformFun() + + c.aFun().commonFun() + c.aFun().platformFun() + + c.a.b.commonFunB() + c.a.b.platformFunB() + + c.aFun().b.commonFunB() + c.aFun().b.platformFunB() + + c.a.bFun().commonFunB() + c.a.bFun().platformFunB() + + c.aFun().bFun().commonFunB() + c.aFun().bFun().platformFunB() +} + diff --git a/idea/testData/multiplatformTypeRefinement/recursiveTypes/common/common.kt b/idea/testData/multiplatformTypeRefinement/recursiveTypes/common/common.kt new file mode 100644 index 00000000000..e5b96aa9888 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/recursiveTypes/common/common.kt @@ -0,0 +1,17 @@ +package sample + +expect interface A> { + fun foo(): T +} + +interface B : A + +fun test(a: A<*>) { + a.foo() + a.foo().foo() +} + +fun test(b: B) { + b.foo() + b.foo().foo() +} diff --git a/idea/testData/multiplatformTypeRefinement/recursiveTypes/dependencies.txt b/idea/testData/multiplatformTypeRefinement/recursiveTypes/dependencies.txt new file mode 100644 index 00000000000..549b0097cf5 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/recursiveTypes/dependencies.txt @@ -0,0 +1,4 @@ +MODULE common { platform=[JVM, JS, Native] } +MODULE jvm { platform=[JVM] } + +jvm -> common { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/recursiveTypes/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/recursiveTypes/jvm/jvm.kt new file mode 100644 index 00000000000..cf9524cb7d3 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/recursiveTypes/jvm/jvm.kt @@ -0,0 +1,24 @@ +package sample + +actual interface A> { + actual fun foo(): T + fun bar() : T +} + +fun test_1(a: A<*>) { + a.foo() + a.bar() + a.foo().foo() + a.bar().bar() + a.foo().bar() + a.bar().foo() +} + +fun test_2(b: B) { + b.foo() + b.bar() + b.foo().foo() + b.bar().bar() + b.foo().bar() + b.bar().foo() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/simple/d1/d1.kt b/idea/testData/multiplatformTypeRefinement/simple/d1/d1.kt new file mode 100644 index 00000000000..d87b0d6a28e --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/simple/d1/d1.kt @@ -0,0 +1,2 @@ +package foo +expect class A \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/simple/d2/d2.kt b/idea/testData/multiplatformTypeRefinement/simple/d2/d2.kt new file mode 100644 index 00000000000..49d2e4f24dc --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/simple/d2/d2.kt @@ -0,0 +1,4 @@ +package bar +import foo.A + +fun baz(): A = null!! \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/simple/d3/d3.kt b/idea/testData/multiplatformTypeRefinement/simple/d3/d3.kt new file mode 100644 index 00000000000..30c50ee61f4 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/simple/d3/d3.kt @@ -0,0 +1,5 @@ +package foo + +actual class A { + fun foo() {} +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/simple/d4/d4.kt b/idea/testData/multiplatformTypeRefinement/simple/d4/d4.kt new file mode 100644 index 00000000000..7dfc10ee63a --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/simple/d4/d4.kt @@ -0,0 +1,6 @@ +package foobar +import bar.baz + +fun main() { + baz().foo() +} diff --git a/idea/testData/multiplatformTypeRefinement/simple/dependencies.txt b/idea/testData/multiplatformTypeRefinement/simple/dependencies.txt new file mode 100644 index 00000000000..1ed64dfbc66 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/simple/dependencies.txt @@ -0,0 +1,8 @@ +MODULE d1 { platform=[JVM, JS, Native]; root=d1 } +MODULE d2 { platform=[JVM, JS, Native]; root=d2 } +MODULE d3 { platform=[JVM]; root=d3 } +MODULE d4 { platform=[JVM]; root=d4 } + +d2 -> d1 { kind=DEPENDS_ON } +d3 -> d2 { kind=DEPENDS_ON } +d4 -> d3 { kind=DEPENDS_ON } diff --git a/idea/testData/multiplatformTypeRefinement/supertypes/d0/d0.kt b/idea/testData/multiplatformTypeRefinement/supertypes/d0/d0.kt new file mode 100644 index 00000000000..93989981f6d --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/supertypes/d0/d0.kt @@ -0,0 +1,5 @@ +package d0 + +interface AnotherSupertype { + fun another() +} diff --git a/idea/testData/multiplatformTypeRefinement/supertypes/d1/d1.kt b/idea/testData/multiplatformTypeRefinement/supertypes/d1/d1.kt new file mode 100644 index 00000000000..e44b00b5ecf --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/supertypes/d1/d1.kt @@ -0,0 +1,9 @@ +@file:Suppress("NO_ACTUAL_FOR_EXPECT") + +package foo + +expect interface Supertype + +class A : Supertype + + diff --git a/idea/testData/multiplatformTypeRefinement/supertypes/d2/d2.kt b/idea/testData/multiplatformTypeRefinement/supertypes/d2/d2.kt new file mode 100644 index 00000000000..f41b453f201 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/supertypes/d2/d2.kt @@ -0,0 +1,10 @@ +@file:Suppress("ACTUAL_WITHOUT_EXPECT") + +package foo +import d0.AnotherSupertype + +actual interface Supertype : AnotherSupertype { + fun foo() {} +} + + diff --git a/idea/testData/multiplatformTypeRefinement/supertypes/d3/d3.kt b/idea/testData/multiplatformTypeRefinement/supertypes/d3/d3.kt new file mode 100644 index 00000000000..d453d411b98 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/supertypes/d3/d3.kt @@ -0,0 +1,4 @@ +package bar +import foo.A + +fun baz(): A = A() diff --git a/idea/testData/multiplatformTypeRefinement/supertypes/d4/d4.kt b/idea/testData/multiplatformTypeRefinement/supertypes/d4/d4.kt new file mode 100644 index 00000000000..340aa34e219 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/supertypes/d4/d4.kt @@ -0,0 +1,21 @@ +package foobar + +import bar.baz +import d0.AnotherSupertype + +fun expectAnotherSupertype(x: T, y: T): T { + x.hashCode() + y.hashCode() + return x +} + +fun foo(x: AnotherSupertype) { + x.hashCode() +} + +fun main(x: AnotherSupertype) { + baz().foo() + // TODO: support subtyping too + foo(baz()) + + expectAnotherSupertype(x, baz()).another() +} diff --git a/idea/testData/multiplatformTypeRefinement/supertypes/dependencies.txt b/idea/testData/multiplatformTypeRefinement/supertypes/dependencies.txt new file mode 100644 index 00000000000..29bea4af875 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/supertypes/dependencies.txt @@ -0,0 +1,11 @@ +MODULE d0 { platform=[JVM, JS, Native]; root=d0 } +MODULE d1 { platform=[JVM, JS, Native]; root=d1 } +MODULE d2 { platform=[JVM, JS, Native]; root=d2 } +MODULE d3 { platform=[JVM]; root=d3 } +MODULE d4 { platform=[JVM]; root=d4 } + +d2 -> d0 { kind=DEPENDS_ON } +d3 -> d1 { kind=DEPENDS_ON } +d4 -> d0, d1, d2, d3 { kind=DEPENDS_ON } + + diff --git a/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/common/common.kt b/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/common/common.kt new file mode 100644 index 00000000000..d4559d2f090 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/common/common.kt @@ -0,0 +1,5 @@ +expect class A { + fun commonMember() +} + +typealias TypealiasFromCommon = A \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/dependencies.txt b/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/dependencies.txt new file mode 100644 index 00000000000..549b0097cf5 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/dependencies.txt @@ -0,0 +1,4 @@ +MODULE common { platform=[JVM, JS, Native] } +MODULE jvm { platform=[JVM] } + +jvm -> common { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/jvm/jvm.kt b/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/jvm/jvm.kt new file mode 100644 index 00000000000..f1c603df801 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/jvm/jvm.kt @@ -0,0 +1,10 @@ +actual class A { + actual fun commonMember() { } + + fun platformMember() { } +} + +fun test() { + TypealiasFromCommon().commonMember() + TypealiasFromCommon().platformwMember() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeAliases/common/aliases.kt b/idea/testData/multiplatformTypeRefinement/typeAliases/common/aliases.kt new file mode 100644 index 00000000000..765e15b6532 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeAliases/common/aliases.kt @@ -0,0 +1,17 @@ +@file:Suppress("NO_ACTUAL_FOR_EXPECT") + +package aliases + +expect interface A { + fun commonFun() +} + +typealias A1 = A + +expect interface B { + fun commonFun() +} + +typealias B1 = B + +class CommonInv(val value: T) \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeAliases/dependencies.txt b/idea/testData/multiplatformTypeRefinement/typeAliases/dependencies.txt new file mode 100644 index 00000000000..98f9e64620b --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeAliases/dependencies.txt @@ -0,0 +1,6 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } +MODULE main { platform=[JVM]; root=main } + +jvm -> common { kind=DEPENDS_ON } +main -> jvm { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeAliases/jvm/aliases.kt b/idea/testData/multiplatformTypeRefinement/typeAliases/jvm/aliases.kt new file mode 100644 index 00000000000..6fe1183ea57 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeAliases/jvm/aliases.kt @@ -0,0 +1,18 @@ +@file:Suppress("ACTUAL_WITHOUT_EXPECT") + +package aliases + +actual interface A { + actual fun commonFun() + fun platformFun() +} + +typealias A2 = A1 +typealias A3 = A + +actual typealias B = A + +typealias B2 = B +typealias B3 = B1 + +class PlatformInv(val value: T) \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeAliases/main/main.kt b/idea/testData/multiplatformTypeRefinement/typeAliases/main/main.kt new file mode 100644 index 00000000000..80a35d6a0ec --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeAliases/main/main.kt @@ -0,0 +1,123 @@ +package aliases + +fun test_1_1(a: A) { + a.commonFun() + a.platformFun() +} + +fun test_1_2(a: A1) { + a.commonFun() + a.platformFun() +} + +fun test_1_3(a: A2) { + a.commonFun() + a.platformFun() +} + +fun test_1_4(a: A3) { + a.commonFun() + a.platformFun() +} + +fun test_1_5(x: CommonInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_1_6(x: CommonInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_1_7(x: CommonInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_1_8(x: CommonInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_1_9(x: PlatformInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_1_10(x: PlatformInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_1_11(x: PlatformInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_1_12(x: PlatformInv) { + x.value.commonFun() + x.value.platformFun() +} + +/////////////////////////////////////////////////////////////////////// + +fun test_2_1(a: B) { + a.commonFun() + a.platformFun() +} + +fun test_2_2(a: B1) { + a.commonFun() + a.platformFun() +} + +fun test_2_3(a: B2) { + a.commonFun() + a.platformFun() +} + +fun test_2_4(a: B3) { + a.commonFun() + a.platformFun() +} + +fun test_2_5(x: CommonInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_2_6(x: CommonInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_2_7(x: CommonInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_2_8(x: CommonInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_2_9(x: PlatformInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_2_10(x: PlatformInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_2_11(x: PlatformInv) { + x.value.commonFun() + x.value.platformFun() +} + +fun test_2_12(x: PlatformInv) { + x.value.commonFun() + x.value.platformFun() +} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeParameters/common/common.kt b/idea/testData/multiplatformTypeRefinement/typeParameters/common/common.kt new file mode 100644 index 00000000000..83a15f8e137 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeParameters/common/common.kt @@ -0,0 +1,15 @@ +@file:Suppress("NO_ACTUAL_FOR_EXPECT") + +package foo + +expect interface A { + fun commonFun() +} + +class CommonGen { + val a: T get() = null!! +} + +class List(val value: T) + +fun getList(): List = null!! \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeParameters/dependencies.txt b/idea/testData/multiplatformTypeRefinement/typeParameters/dependencies.txt new file mode 100644 index 00000000000..98f9e64620b --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeParameters/dependencies.txt @@ -0,0 +1,6 @@ +MODULE common { platform=[JVM, JS, Native]; root=common } +MODULE jvm { platform=[JVM]; root=jvm } +MODULE main { platform=[JVM]; root=main } + +jvm -> common { kind=DEPENDS_ON } +main -> jvm { kind=DEPENDS_ON } \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeParameters/jvm/platform.kt b/idea/testData/multiplatformTypeRefinement/typeParameters/jvm/platform.kt new file mode 100644 index 00000000000..9376a93e679 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeParameters/jvm/platform.kt @@ -0,0 +1,19 @@ +@file:Suppress("ACTUAL_WITHOUT_EXPECT") + +package foo + +interface B + +actual interface A : B { + actual fun commonFun() + + fun platformFun() +} + +class AImpl : A { + override fun commonFun() {} + override fun platformFun() {} +} + +@Suppress("UNUSED_PARAMETER") +fun takeList(inv: List) {} \ No newline at end of file diff --git a/idea/testData/multiplatformTypeRefinement/typeParameters/main/main.kt b/idea/testData/multiplatformTypeRefinement/typeParameters/main/main.kt new file mode 100644 index 00000000000..440c38e1bc4 --- /dev/null +++ b/idea/testData/multiplatformTypeRefinement/typeParameters/main/main.kt @@ -0,0 +1,30 @@ +package foo + +fun test_1(gen: CommonGen) { + gen.a.commonFun() + gen.a.platformFun() +} + +fun test_2(gen: CommonGen) { + gen.a.commonFun() + gen.a.platformFun() +} + +fun test_3(gen: CommonGen<*>) { + gen.a.commonFun() + gen.a.platformFun() +} + +fun test_4(gen: CommonGen) { + gen.a.commonFun() + gen.a.platformFun() +} + +fun test_5(gen: CommonGen) { + gen.a.commonFun() + gen.a.platformFun() +} + +fun test_6() { + takeList(getList()) +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiplatformAnalysisTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiplatformAnalysisTestGenerated.java new file mode 100644 index 00000000000..10ce67ec3ec --- /dev/null +++ b/idea/tests/org/jetbrains/kotlin/idea/caches/resolve/MultiplatformAnalysisTestGenerated.java @@ -0,0 +1,147 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.idea.caches.resolve; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@RunWith(JUnit3RunnerWithInners.class) +public class MultiplatformAnalysisTestGenerated extends AbstractMultiplatformAnalysisTest { + @TestMetadata("idea/testData/multiplatform") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Multiplatform extends AbstractMultiplatformAnalysisTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + public void testAllFilesPresentInMultiplatform() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/multiplatform"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false); + } + + @TestMetadata("internalFromDependsOn") + public void testInternalFromDependsOn() throws Exception { + runTest("idea/testData/multiplatform/internalFromDependsOn/"); + } + + @TestMetadata("internalFromDependsOnOfProduction") + public void testInternalFromDependsOnOfProduction() throws Exception { + runTest("idea/testData/multiplatform/internalFromDependsOnOfProduction/"); + } + + @TestMetadata("internalFromProduction") + public void testInternalFromProduction() throws Exception { + runTest("idea/testData/multiplatform/internalFromProduction/"); + } + } + + @TestMetadata("idea/testData/multiplatformTypeRefinement") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class MultiplatformTypeRefinement extends AbstractMultiplatformAnalysisTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); + } + + @TestMetadata("aliasesTypeMismatch") + public void testAliasesTypeMismatch() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/aliasesTypeMismatch/"); + } + + public void testAllFilesPresentInMultiplatformTypeRefinement() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/multiplatformTypeRefinement"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false); + } + + @TestMetadata("callableReferences") + public void testCallableReferences() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/callableReferences/"); + } + + @TestMetadata("constructorsOfExpect") + public void testConstructorsOfExpect() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/constructorsOfExpect/"); + } + + @TestMetadata("diamondModuleDependency1") + public void testDiamondModuleDependency1() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/diamondModuleDependency1/"); + } + + @TestMetadata("diamondModuleDependency2") + public void testDiamondModuleDependency2() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/diamondModuleDependency2/"); + } + + @TestMetadata("extensionOnExpect") + public void testExtensionOnExpect() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/extensionOnExpect/"); + } + + @TestMetadata("jsNameClash") + public void testJsNameClash() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/jsNameClash/"); + } + + @TestMetadata("lambdas") + public void testLambdas() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/lambdas/"); + } + + @TestMetadata("languageConstructions") + public void testLanguageConstructions() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/languageConstructions/"); + } + + @TestMetadata("multilevelParents") + public void testMultilevelParents() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/multilevelParents/"); + } + + @TestMetadata("qualifiedReceiver") + public void testQualifiedReceiver() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/qualifiedReceiver/"); + } + + @TestMetadata("recursiveTypes") + public void testRecursiveTypes() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/recursiveTypes/"); + } + + @TestMetadata("simple") + public void testSimple() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/simple/"); + } + + @TestMetadata("supertypes") + public void testSupertypes() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/supertypes/"); + } + + @TestMetadata("typeAliasToExpectClassExplicitReference") + public void testTypeAliasToExpectClassExplicitReference() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/typeAliasToExpectClassExplicitReference/"); + } + + @TestMetadata("typeAliases") + public void testTypeAliases() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/typeAliases/"); + } + + @TestMetadata("typeParameters") + public void testTypeParameters() throws Exception { + runTest("idea/testData/multiplatformTypeRefinement/typeParameters/"); + } + } +} diff --git a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt index a2f69b60153..28e0c481445 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/stubs/AbstractMultiModuleTest.kt @@ -114,7 +114,7 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() { val facetSettings = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this) facetSettings.useProjectSettings = false facetSettings.compilerSettings = CompilerSettings().apply { - additionalArguments += " -Xmulti-platform" + additionalArguments += " -Xmulti-platform -XXtype-refinement" } }