diff --git a/compiler/testData/klib/partial-linkage/__utils__/__utils__.kt b/compiler/testData/klib/partial-linkage/__utils__/__utils__.kt index dc96cacfcce..76445eeac91 100644 --- a/compiler/testData/klib/partial-linkage/__utils__/__utils__.kt +++ b/compiler/testData/klib/partial-linkage/__utils__/__utils__.kt @@ -27,6 +27,7 @@ private typealias Block = () -> T data class TestMode( val isJs: Boolean = false, val isNative: Boolean = false, + val isWasm: Boolean = false, val staticCache: Scope = Scope.NOWHERE, val lazyIr: Scope = Scope.NOWHERE ) { @@ -39,7 +40,7 @@ data class TestMode( } init { - check(isJs xor isNative) + check(isJs xor isNative xor isWasm) check(isNative || staticCache.notUsed) check(isNative || lazyIr.notUsed) } diff --git a/compiler/testData/klib/partial-linkage/classTransformations/main/m.kt b/compiler/testData/klib/partial-linkage/classTransformations/main/m.kt index 2ed0bcf00e9..af93abc750d 100644 --- a/compiler/testData/klib/partial-linkage/classTransformations/main/m.kt +++ b/compiler/testData/klib/partial-linkage/classTransformations/main/m.kt @@ -159,10 +159,12 @@ fun box() = abiTest { expectFailure(linkage("Function 'getAnnotationClassWithParameterOfParameterThatDisappearsInline' can not be called: Function uses unlinked class symbol '/AnnotationClassThatDisappears' (via annotation class 'AnnotationClassWithParameterOfParameterThatDisappears')")) { getAnnotationClassWithParameterOfParameterThatDisappearsInline() } expectFailure(linkage("Constructor 'AnnotationClassThatDisappears.' can not be called: No constructor found for symbol '/AnnotationClassThatDisappears.'")) { getAnnotationClassWithParameterThatDisappearsAsAny() } expectFailure(linkage("Constructor 'AnnotationClassThatDisappears.' can not be called: No constructor found for symbol '/AnnotationClassThatDisappears.'")) { getAnnotationClassWithParameterThatDisappearsAsAnyInline() } - expectSuccess("@AnnotationClassWithRenamedParameters(xi=129, xs=Banana)") { getAnnotationClassWithRenamedParameters().toString() } - expectSuccess("@AnnotationClassWithRenamedParameters(xi=130, xs=Pear)") { getAnnotationClassWithRenamedParametersInline().toString() } - expectSuccess("@AnnotationClassWithRenamedParameters(xi=131, xs=Orange)") { getAnnotationClassWithRenamedParametersAsAny().toString() } - expectSuccess("@AnnotationClassWithRenamedParameters(xi=132, xs=Peach)") { getAnnotationClassWithRenamedParametersAsAnyInline().toString() } + if (!testMode.isWasm) { //toString for annotation classes are not supported KT-66385 + expectSuccess("@AnnotationClassWithRenamedParameters(xi=129, xs=Banana)") { getAnnotationClassWithRenamedParameters().toString() } + expectSuccess("@AnnotationClassWithRenamedParameters(xi=130, xs=Pear)") { getAnnotationClassWithRenamedParametersInline().toString() } + expectSuccess("@AnnotationClassWithRenamedParameters(xi=131, xs=Orange)") { getAnnotationClassWithRenamedParametersAsAny().toString() } + expectSuccess("@AnnotationClassWithRenamedParameters(xi=132, xs=Peach)") { getAnnotationClassWithRenamedParametersAsAnyInline().toString() } + } expectFailure(linkage("Constructor 'AnnotationClassWithReorderedParameters.' can not be called: No constructor found for symbol '/AnnotationClassWithReorderedParameters.'")) { getAnnotationClassWithReorderedParameters() } expectFailure(linkage("Constructor 'AnnotationClassWithReorderedParameters.' can not be called: No constructor found for symbol '/AnnotationClassWithReorderedParameters.'")) { getAnnotationClassWithReorderedParametersInline() } expectFailure(linkage("Constructor 'AnnotationClassWithReorderedParameters.' can not be called: No constructor found for symbol '/AnnotationClassWithReorderedParameters.'")) { getAnnotationClassWithReorderedParametersAsAny() } diff --git a/compiler/testData/klib/partial-linkage/externalDeclarations/lib2/l2.kt b/compiler/testData/klib/partial-linkage/externalDeclarations/lib2/l2.kt index 59a0fd4459e..204046b7ddc 100644 --- a/compiler/testData/klib/partial-linkage/externalDeclarations/lib2/l2.kt +++ b/compiler/testData/klib/partial-linkage/externalDeclarations/lib2/l2.kt @@ -6,13 +6,6 @@ external class ExternalClassInheritedFromAbstractExternalClass : AbstractExterna fun ExternalClassInheritedFromAbstractExternalClass.callRemovedFunction() = removedFunction() -class RegularClassInheritedFromAbstractExternalClass : AbstractExternalClass() { - override fun abstractFunction() = "RegularClassInheritedFromAbstractExternalClass.abstractFunction" - override fun removedAbstractFunction() = "RegularClassInheritedFromAbstractExternalClass.removedAbstractFunction" -} - -fun RegularClassInheritedFromAbstractExternalClass.callRemovedFunction() = removedFunction() - open external class OpenExternalClass { fun function(): String } @@ -24,15 +17,4 @@ external interface ExternalInterfaceInheritedFromOpenExternalClass : OpenExterna external class ExternalClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass : ExternalInterfaceInheritedFromOpenExternalClass { override fun abstractFunction(): String -} - -class RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass : - ExternalInterfaceInheritedFromOpenExternalClass, - /* Note: Have to explicitly inherit from 'OpenExternalClass' becase otherwise JS codegen sees that - * class 'RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass' is inherited only from - * interface 'ExternalInterfaceInheritedFromOpenExternalClass' and does not figure out that a bridge has to be - * generated for function 'function' inherited from 'OpenExternalClass'. - */ - OpenExternalClass() { - override fun abstractFunction(): String = "RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass.abstractFunction" -} +} \ No newline at end of file diff --git a/compiler/testData/klib/partial-linkage/externalDeclarations/main/m.kt b/compiler/testData/klib/partial-linkage/externalDeclarations/main/m.kt index a9c0a4784a5..cd3fb04f599 100644 --- a/compiler/testData/klib/partial-linkage/externalDeclarations/main/m.kt +++ b/compiler/testData/klib/partial-linkage/externalDeclarations/main/m.kt @@ -3,28 +3,23 @@ import abitestutils.TestBuilder fun box() = abiTest { val ecifaec = ExternalClassInheritedFromAbstractExternalClass() - val rcifaec = RegularClassInheritedFromAbstractExternalClass() val ecifeiifoec = ExternalClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass() - val rcifeiifoec = RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass() expectSuccess("ExternalClassInheritedFromAbstractExternalClass.abstractFunction") { ecifaec.abstractFunction() } expectSuccess("ExternalClassInheritedFromAbstractExternalClass.removedAbstractFunction") { ecifaec.removedAbstractFunction() } - expectRuntimeFailure("Calling abstract function AbstractExternalClass.addedAbstractFunction") { ecifaec.addedAbstractFunction() } + + val expectedExceptionMessage = when (testMode.isWasm) { + true -> "Exception was thrown while running JavaScript code" + else -> "Calling abstract function AbstractExternalClass.addedAbstractFunction" + } + expectRuntimeFailure(expectedExceptionMessage) { ecifaec.addedAbstractFunction() } + expectSuccess("AbstractExternalClass.function") { ecifaec.function() } expectFailure(linkage("Function 'removedFunction' can not be called: No function found for symbol '/ExternalClassInheritedFromAbstractExternalClass.removedFunction'")) { ecifaec.callRemovedFunction() } expectSuccess("AbstractExternalClass.addedFunction") { ecifaec.addedFunction() } - expectSuccess("RegularClassInheritedFromAbstractExternalClass.abstractFunction") { rcifaec.abstractFunction() } - expectSuccess("RegularClassInheritedFromAbstractExternalClass.removedAbstractFunction") { rcifaec.removedAbstractFunction() } - expectFailure(nonImplementedCallable("function 'addedAbstractFunction'", "class 'RegularClassInheritedFromAbstractExternalClass'")) { rcifaec.addedAbstractFunction() } - expectSuccess("AbstractExternalClass.function") { rcifaec.function() } - expectFailure(linkage("Function 'removedFunction' can not be called: No function found for symbol '/RegularClassInheritedFromAbstractExternalClass.removedFunction'")) { rcifaec.callRemovedFunction() } - expectSuccess("AbstractExternalClass.addedFunction") { rcifaec.addedFunction() } - expectSuccess("OpenExternalClass.function") { ecifeiifoec.function() } expectSuccess("ExternalClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass.abstractFunction") { ecifeiifoec.abstractFunction() } - expectSuccess("OpenExternalClass.function") { rcifeiifoec.function() } - expectSuccess("RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass.abstractFunction") { rcifeiifoec.abstractFunction() } } private fun TestBuilder.expectRuntimeFailure(errorMessage: String, block: () -> Any) = diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.js b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.js new file mode 100644 index 00000000000..f385080f145 --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.js @@ -0,0 +1,19 @@ +function AbstractExternalClass() {} +AbstractExternalClass.prototype.abstractFunction = function() { + throw new Error("Calling abstract function AbstractExternalClass.abstractFunction"); +} +AbstractExternalClass.prototype.removedAbstractFunction = function() { + throw new Error("Calling abstract function AbstractExternalClass.removedAbstractFunction"); +} +// AbstractExternalClass.prototype.addedAbstractFunction = function() { +// throw new Error("Calling abstract function AbstractExternalClass.addedAbstractFunction"); +// } +AbstractExternalClass.prototype.function = function() { + return "AbstractExternalClass.function"; +} +AbstractExternalClass.prototype.removedFunction = function() { + return "AbstractExternalClass.removedFunction"; +} +// AbstractExternalClass.prototype.addedFunction = function() { +// return "AbstractExternalClass.addedFunction"; +// } diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.js.1 b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.js.1 new file mode 100644 index 00000000000..2c96afe3fce --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.js.1 @@ -0,0 +1,19 @@ +function AbstractExternalClass() {} +AbstractExternalClass.prototype.abstractFunction = function() { + throw new Error("Calling abstract function AbstractExternalClass.abstractFunction"); +} +// AbstractExternalClass.prototype.removedAbstractFunction = function() { +// throw new Error("Calling abstract function AbstractExternalClass.removedAbstractFunction"); +// } +AbstractExternalClass.prototype.addedAbstractFunction = function() { + throw new Error("Calling abstract function AbstractExternalClass.addedAbstractFunction"); +} +AbstractExternalClass.prototype.function = function() { + return "AbstractExternalClass.function"; +} +// AbstractExternalClass.prototype.removedFunction = function() { +// return "AbstractExternalClass.removedFunction"; +// } +AbstractExternalClass.prototype.addedFunction = function() { + return "AbstractExternalClass.addedFunction"; +} diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.kt b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.kt new file mode 100644 index 00000000000..31ce392c215 --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.kt @@ -0,0 +1,9 @@ +abstract external class AbstractExternalClass { + abstract fun abstractFunction(): String + abstract fun removedAbstractFunction(): String +// abstract fun addedAbstractFunction(): String + + fun function(): String + fun removedFunction(): String +// fun addedFunction(): String +} diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.kt.1 b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.kt.1 new file mode 100644 index 00000000000..62e98c38af6 --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/l1.kt.1 @@ -0,0 +1,9 @@ +abstract external class AbstractExternalClass { + abstract fun abstractFunction(): String +// abstract fun removedAbstractFunction(): String + abstract fun addedAbstractFunction(): String + + fun function(): String +// fun removedFunction(): String + fun addedFunction(): String +} diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/module.info b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/module.info new file mode 100644 index 00000000000..c80e48ec945 --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib1/module.info @@ -0,0 +1,7 @@ +STEP 0: + dependencies: stdlib +STEP 1: + dependencies: stdlib + modifications: + U : l1.kt.1 -> l1.kt + U : l1.js.1 -> l1.js diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/l2.js b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/l2.js new file mode 100644 index 00000000000..4e00895729a --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/l2.js @@ -0,0 +1,10 @@ +function OpenExternalClass() {} +OpenExternalClass.prototype.function = function() { + return "OpenExternalClass.function" +} + +function ExternalInterfaceInheritedFromOpenExternalClass() {} +ExternalInterfaceInheritedFromOpenExternalClass.prototype = Object.create(OpenExternalClass.prototype); +ExternalInterfaceInheritedFromOpenExternalClass.prototype.abstractFunction = function() { + throw new Error("Calling abstract function ExternalInterfaceInheritedFromOpenExternalClass.abstractFunction"); +} diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/l2.kt b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/l2.kt new file mode 100644 index 00000000000..afdf05f31c3 --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/l2.kt @@ -0,0 +1,26 @@ +class RegularClassInheritedFromAbstractExternalClass : AbstractExternalClass() { + override fun abstractFunction() = "RegularClassInheritedFromAbstractExternalClass.abstractFunction" + override fun removedAbstractFunction() = "RegularClassInheritedFromAbstractExternalClass.removedAbstractFunction" +} + +fun RegularClassInheritedFromAbstractExternalClass.callRemovedFunction() = removedFunction() + +open external class OpenExternalClass { + fun function(): String +} + +@Suppress("INTERFACE_WITH_SUPERCLASS") +external interface ExternalInterfaceInheritedFromOpenExternalClass : OpenExternalClass { + fun abstractFunction(): String +} + +class RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass : + ExternalInterfaceInheritedFromOpenExternalClass, + /* Note: Have to explicitly inherit from 'OpenExternalClass' becase otherwise JS codegen sees that + * class 'RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass' is inherited only from + * interface 'ExternalInterfaceInheritedFromOpenExternalClass' and does not figure out that a bridge has to be + * generated for function 'function' inherited from 'OpenExternalClass'. + */ + OpenExternalClass() { + override fun abstractFunction(): String = "RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass.abstractFunction" +} diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/module.info b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/module.info new file mode 100644 index 00000000000..391aab979a6 --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/lib2/module.info @@ -0,0 +1,2 @@ +STEP 0: + dependencies: stdlib, lib1 \ No newline at end of file diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/main/m.kt b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/main/m.kt new file mode 100644 index 00000000000..cd0c1cc28e0 --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/main/m.kt @@ -0,0 +1,20 @@ +import abitestutils.abiTest +import abitestutils.TestBuilder + +fun box() = abiTest { + val rcifaec = RegularClassInheritedFromAbstractExternalClass() + val rcifeiifoec = RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass() + + expectSuccess("RegularClassInheritedFromAbstractExternalClass.abstractFunction") { rcifaec.abstractFunction() } + expectSuccess("RegularClassInheritedFromAbstractExternalClass.removedAbstractFunction") { rcifaec.removedAbstractFunction() } + expectFailure(nonImplementedCallable("function 'addedAbstractFunction'", "class 'RegularClassInheritedFromAbstractExternalClass'")) { rcifaec.addedAbstractFunction() } + expectSuccess("AbstractExternalClass.function") { rcifaec.function() } + expectFailure(linkage("Function 'removedFunction' can not be called: No function found for symbol '/RegularClassInheritedFromAbstractExternalClass.removedFunction'")) { rcifaec.callRemovedFunction() } + expectSuccess("AbstractExternalClass.addedFunction") { rcifaec.addedFunction() } + + expectSuccess("OpenExternalClass.function") { rcifeiifoec.function() } + expectSuccess("RegularClassInheritedFromExternalInterfaceInheritedFromOpenExternalClass.abstractFunction") { rcifeiifoec.abstractFunction() } +} + +private fun TestBuilder.expectRuntimeFailure(errorMessage: String, block: () -> Any) = + expectFailure(custom { throwable -> throwable !is Exception && throwable.message == errorMessage }) { block() } diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/main/module.info b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/main/module.info new file mode 100644 index 00000000000..959e68004dc --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/main/module.info @@ -0,0 +1,2 @@ +STEP 1: + dependencies: stdlib, lib1, lib2 diff --git a/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/project.info b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/project.info new file mode 100644 index 00000000000..d175e5f27f1 --- /dev/null +++ b/compiler/testData/klib/partial-linkage/externalDeclarationsKJS/project.info @@ -0,0 +1,7 @@ +MODULES: lib1, lib2, main + +STEP 0: + libs: lib1, lib2 + +STEP 1: + libs: lib1, main diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/FirJsPartialLinkageNoICTestCaseGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/FirJsPartialLinkageNoICTestCaseGenerated.java index 51b9ecade8b..4405ba5e58a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/FirJsPartialLinkageNoICTestCaseGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/FirJsPartialLinkageNoICTestCaseGenerated.java @@ -66,6 +66,12 @@ public class FirJsPartialLinkageNoICTestCaseGenerated extends AbstractFirJsParti runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); } + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + @Test @TestMetadata("functionTransformations") public void testFunctionTransformations() { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageNoICES6TestCaseGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageNoICES6TestCaseGenerated.java index 151c65b51dc..ce581aed930 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageNoICES6TestCaseGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageNoICES6TestCaseGenerated.java @@ -66,6 +66,12 @@ public class JsPartialLinkageNoICES6TestCaseGenerated extends AbstractJsPartialL runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); } + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + @Test @TestMetadata("functionTransformations") public void testFunctionTransformations() { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageNoICTestCaseGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageNoICTestCaseGenerated.java index 985c5751175..cb946bbc26a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageNoICTestCaseGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageNoICTestCaseGenerated.java @@ -66,6 +66,12 @@ public class JsPartialLinkageNoICTestCaseGenerated extends AbstractJsPartialLink runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); } + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + @Test @TestMetadata("functionTransformations") public void testFunctionTransformations() { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageWithICTestCaseGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageWithICTestCaseGenerated.java index c7151ab5764..9b1a6aa40fe 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageWithICTestCaseGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/JsPartialLinkageWithICTestCaseGenerated.java @@ -66,6 +66,12 @@ public class JsPartialLinkageWithICTestCaseGenerated extends AbstractJsPartialLi runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); } + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + @Test @TestMetadata("functionTransformations") public void testFunctionTransformations() { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativePartialLinkageTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativePartialLinkageTestGenerated.java index 66d0ffa087c..b615e3d8531 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativePartialLinkageTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativePartialLinkageTestGenerated.java @@ -69,6 +69,12 @@ public class FirNativePartialLinkageTestGenerated extends AbstractNativePartialL runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); } + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + @Test @TestMetadata("functionTransformations") public void testFunctionTransformations() { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativePartialLinkageTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativePartialLinkageTestGenerated.java index 5bf958d7980..2941d6999ff 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativePartialLinkageTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativePartialLinkageTestGenerated.java @@ -65,6 +65,12 @@ public class NativePartialLinkageTestGenerated extends AbstractNativePartialLink runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); } + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + @Test @TestMetadata("functionTransformations") public void testFunctionTransformations() { diff --git a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativePartialLinkageTest.kt b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativePartialLinkageTest.kt index 6b764c1ba58..2f328602c5e 100644 --- a/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativePartialLinkageTest.kt +++ b/native/native.tests/tests/org/jetbrains/kotlin/konan/test/blackbox/AbstractNativePartialLinkageTest.kt @@ -69,7 +69,7 @@ abstract class AbstractNativePartialLinkageTest : AbstractNativeSimpleTest() { override fun onNonEmptyBuildDirectory(directory: File) = backupDirectoryContents(directory) override fun isIgnoredTest(projectInfo: ProjectInfo) = - super.isIgnoredTest(projectInfo) || projectInfo.name == "externalDeclarations" + super.isIgnoredTest(projectInfo) || projectInfo.name == "externalDeclarations" || projectInfo.name == "externalDeclarationsKJS" override fun onIgnoredTest() = throw TestAbortedException() } diff --git a/wasm/wasm.tests/test/org/jetbrains/kotlin/generators/tests/GenerateWasmTests.kt b/wasm/wasm.tests/test/org/jetbrains/kotlin/generators/tests/GenerateWasmTests.kt index cbe346aeded..3fe37bed1bb 100644 --- a/wasm/wasm.tests/test/org/jetbrains/kotlin/generators/tests/GenerateWasmTests.kt +++ b/wasm/wasm.tests/test/org/jetbrains/kotlin/generators/tests/GenerateWasmTests.kt @@ -7,6 +7,8 @@ package org.jetbrains.kotlin.generators.tests import org.jetbrains.kotlin.generators.generateTestGroupSuiteWithJUnit5 import org.jetbrains.kotlin.generators.util.TestGeneratorUtil +import org.jetbrains.kotlin.wasm.test.AbstractWasmPartialLinkageWithICTestCase +import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.wasm.test.* import org.jetbrains.kotlin.wasm.test.diagnostics.AbstractDiagnosticsWasmTest import org.jetbrains.kotlin.wasm.test.diagnostics.AbstractDiagnosticsFirWasmTest @@ -29,6 +31,26 @@ fun main(args: Array) { "crossModuleRef", "crossModuleRefPerFile", "crossModuleRefPerModule" ) + generateTestGroupSuiteWithJUnit5(args) { + testGroup("wasm/wasm.tests/tests-gen", "compiler/testData") { + testClass { + model("klib/partial-linkage/", pattern = "^([^_](.+))$", targetBackend = TargetBackend.WASM, recursive = false) + } + } + + testGroup("wasm/wasm.tests/tests-gen", "compiler/testData") { + testClass { + model("klib/partial-linkage/", pattern = "^([^_](.+))$", targetBackend = TargetBackend.WASM, recursive = false) + } + } + + testGroup("wasm/wasm.tests/tests-gen", "compiler/testData") { + testClass { + model("klib/partial-linkage/", pattern = "^([^_](.+))$", targetBackend = TargetBackend.WASM, recursive = false) + } + } + } + generateTestGroupSuiteWithJUnit5(args) { testGroup("wasm/wasm.tests/tests-gen", "compiler/testData") { testClass { diff --git a/wasm/wasm.tests/test/org/jetbrains/kotlin/wasm/test/AbstractWasmPartialLinkageTestCase.kt b/wasm/wasm.tests/test/org/jetbrains/kotlin/wasm/test/AbstractWasmPartialLinkageTestCase.kt new file mode 100644 index 00000000000..5838c513ead --- /dev/null +++ b/wasm/wasm.tests/test/org/jetbrains/kotlin/wasm/test/AbstractWasmPartialLinkageTestCase.kt @@ -0,0 +1,203 @@ +/* + * Copyright 2010-2022 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.wasm.test + +import com.intellij.testFramework.TestDataFile +import org.jetbrains.kotlin.cli.common.ExitCode +import org.jetbrains.kotlin.cli.js.K2JsIrCompiler +import org.jetbrains.kotlin.codegen.ProjectInfo +import org.jetbrains.kotlin.klib.PartialLinkageTestUtils +import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.Dependencies +import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.Dependency +import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.MAIN_MODULE_NAME +import org.jetbrains.kotlin.klib.PartialLinkageTestUtils.ModuleBuildDirs +import org.jetbrains.kotlin.wasm.test.tools.WasmVM +import org.junit.jupiter.api.AfterEach +import java.io.ByteArrayOutputStream +import java.io.File +import java.io.PrintStream +import kotlin.io.path.createTempDirectory + +abstract class AbstractWasmPartialLinkageNoICTestCase : AbstractWasmPartialLinkageTestCase(CompilerType.K1_NO_IC) +abstract class AbstractWasmPartialLinkageWithICTestCase : AbstractWasmPartialLinkageTestCase(CompilerType.K1_WITH_IC) +abstract class AbstractFirWasmPartialLinkageNoICTestCase : AbstractWasmPartialLinkageTestCase(CompilerType.K2_NO_IC) + +abstract class AbstractWasmPartialLinkageTestCase(private val compilerType: CompilerType) { + enum class CompilerType(val useFir: Boolean, val useIc: Boolean) { + K1_NO_IC(useFir = false, useIc = false), + K1_WITH_IC(useFir = false, useIc = true), + K2_NO_IC(useFir = true, useIc = false) + } + + private val buildDir: File = createTempDirectory().toFile().also { it.mkdirs() } + + @AfterEach + fun clearArtifacts() { + buildDir.deleteRecursively() + } + + private inner class WasmTestConfiguration(testPath: String) : PartialLinkageTestUtils.TestConfiguration { + override val testDir: File = File(testPath).absoluteFile + override val buildDir: File get() = this@AbstractWasmPartialLinkageTestCase.buildDir + override val stdlibFile: File get() = File("libraries/stdlib/build/classes/kotlin/wasmJs/main").absoluteFile + override val testModeConstructorParameters = mapOf("isWasm" to "true") + + override fun customizeModuleSources(moduleName: String, moduleSourceDir: File) { + if (moduleName == MAIN_MODULE_NAME) { + File(moduleSourceDir, "runner.kt") + .writeText("@kotlin.wasm.WasmExport fun runBoxTest() = println($BOX_FUN_FQN())") + } + } + + override fun buildKlib( + moduleName: String, + buildDirs: ModuleBuildDirs, + dependencies: Dependencies, + klibFile: File, + ) = this@AbstractWasmPartialLinkageTestCase.buildKlib(moduleName, buildDirs, dependencies, klibFile) + + override fun buildBinaryAndRun(mainModule: Dependency, otherDependencies: Dependencies) = + this@AbstractWasmPartialLinkageTestCase.buildBinaryAndRun(mainModule, otherDependencies) + + override fun onNonEmptyBuildDirectory(directory: File) { + directory.listFiles()?.forEach(File::deleteRecursively) + } + + override fun isIgnoredTest(projectInfo: ProjectInfo): Boolean = + super.isIgnoredTest(projectInfo) || projectInfo.name == "externalDeclarationsKJS" + + override fun onIgnoredTest() { + /* Do nothing specific. JUnit 3 does not support programmatic tests muting. */ + } + } + + // The entry point to generated test classes. + fun runTest(@TestDataFile testPath: String) = PartialLinkageTestUtils.runTest(WasmTestConfiguration(testPath)) + + fun buildKlib(moduleName: String, buildDirs: ModuleBuildDirs, dependencies: Dependencies, klibFile: File) { + val kotlinSourceFilePaths = mutableListOf() + + buildDirs.sourceDir.walkTopDown().forEach { sourceFile -> + if (sourceFile.isFile) when (sourceFile.extension) { + "kt" -> kotlinSourceFilePaths += sourceFile.absolutePath + "js" -> { + // This is needed to preserve *.js files from test data which are required for tests with `external` declarations: + sourceFile.copyTo(buildDirs.outputDir.resolve(sourceFile.relativeTo(buildDirs.sourceDir)), overwrite = true) + } + } + } + + // Build KLIB: + runCompilerViaCLI( + listOf( + "-Xir-produce-klib-file", + "-ir-output-dir", klibFile.parentFile.absolutePath, + "-ir-output-name", moduleName, + // Halt on any unexpected warning. + "-Werror", + // Tests suppress the INVISIBLE_REFERENCE check. + // However, JS doesn't produce the INVISIBLE_REFERENCE error; + // As result, it triggers a suppression error warning about the redundant suppression. + // This flag is used to disable the warning. + "-Xdont-warn-on-error-suppression", + "-Xwasm" + ), + dependencies.toCompilerArgs(), + listOf( + "-language-version", "2.0", + // Don't fail on language version warnings. + "-Xsuppress-version-warnings" + ).takeIf { compilerType.useFir }, + kotlinSourceFilePaths + ) + } + + private fun buildBinaryAndRun(mainModule: Dependency, otherDependencies: Dependencies) { + val binariesDir: File = File(buildDir, BIN_DIR_NAME).also { it.mkdirs() } + + runCompilerViaCLI( + listOf( + "-Xir-produce-js", + "-Xir-per-module", + "-module-kind", "plain", + "-Xinclude=${mainModule.libraryFile.absolutePath}", + "-ir-output-dir", binariesDir.absolutePath, + "-ir-output-name", MAIN_MODULE_NAME, + // IMPORTANT: Omitting PL arguments here. The default PL mode should be in effect. + // "-Xpartial-linkage=enable", "-Xpartial-linkage-loglevel=INFO", + "-Werror", + "-Xwasm", + ), + listOf( + "-Xcache-directory=${buildDir.resolve("libs-cache").absolutePath}", + ).takeIf { compilerType.useIc }, + otherDependencies.toCompilerArgs(), + ) + + val mainModuleMjsName = "$MAIN_MODULE_NAME.mjs" + val resultMjs = File(binariesDir, mainModuleMjsName) + if (!resultMjs.exists()) error("Produced binary not found") + + val runnerFileName = "runner.mjs" + File(binariesDir, runnerFileName).writeText( + """ + const { runBoxTest } = await import('./$mainModuleMjsName'); + runBoxTest(); + """, + ) + + val additionalJsFiles = mutableListOf() + additionalJsFiles.addAll(getAdditionalJsFiles(mainModule)) + otherDependencies.regularDependencies.flatMapTo(additionalJsFiles) { getAdditionalJsFiles(it) } + otherDependencies.friendDependencies.flatMapTo(additionalJsFiles) { getAdditionalJsFiles(it) } + + val result = WasmVM.V8.run(runnerFileName, additionalJsFiles.map { it.absolutePath }, binariesDir) + check("OK" == result.trim()) + } + + private fun Dependencies.toCompilerArgs(): List = buildList { + if (regularDependencies.isNotEmpty()) { + this += "-libraries" + this += regularDependencies.joinToString(File.pathSeparator) { it.libraryFile.absolutePath } + } + if (friendDependencies.isNotEmpty()) { + this += "-Xfriend-modules=${friendDependencies.joinToString(File.pathSeparator) { it.libraryFile.absolutePath }}" + } + } + + private fun getAdditionalJsFiles(dependency: Dependency): List { + val outputDirectory = dependency.libraryFile.let { + it.takeIf { it.isDirectory } ?: it.parentFile + } + return outputDirectory.listFiles()!!.filter { it.extension == "js" } + } + + private fun runCompilerViaCLI(vararg compilerArgs: List?) { + val allCompilerArgs = compilerArgs.flatMap { args -> args.orEmpty().filterNotNull() }.toTypedArray() + + val compilerXmlOutput = ByteArrayOutputStream() + val exitCode = PrintStream(compilerXmlOutput).use { printStream -> + K2JsIrCompiler().execFullPathsInMessages(printStream, allCompilerArgs) + } + + if (exitCode != ExitCode.OK) + throw AssertionError( + buildString { + appendLine("Compiler failure.") + appendLine("Exit code = $exitCode.") + appendLine("Compiler messages:") + appendLine("==========") + appendLine(compilerXmlOutput.toString(Charsets.UTF_8.name())) + appendLine("==========") + } + ) + } + + companion object { + private const val BIN_DIR_NAME = "_bins_wasm" + private const val BOX_FUN_FQN = "box" + } +} diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmPartialLinkageNoICTestCaseGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmPartialLinkageNoICTestCaseGenerated.java new file mode 100644 index 00000000000..d0f17913aee --- /dev/null +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmPartialLinkageNoICTestCaseGenerated.java @@ -0,0 +1,164 @@ +/* + * Copyright 2010-2024 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.wasm.test; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateWasmTestsKt}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/klib/partial-linkage") +@TestDataPath("$PROJECT_ROOT") +public class FirWasmPartialLinkageNoICTestCaseGenerated extends AbstractFirWasmPartialLinkageNoICTestCase { + @Test + @TestMetadata("addEnumEntry") + public void testAddEnumEntry() { + runTest("compiler/testData/klib/partial-linkage/addEnumEntry/"); + } + + @Test + @TestMetadata("addSealedSubclass") + public void testAddSealedSubclass() { + runTest("compiler/testData/klib/partial-linkage/addSealedSubclass/"); + } + + @Test + public void testAllFilesPresentInPartial_linkage() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klib/partial-linkage"), Pattern.compile("^([^_](.+))$"), null, TargetBackend.WASM, false); + } + + @Test + @TestMetadata("changeClassVisibility") + public void testChangeClassVisibility() { + runTest("compiler/testData/klib/partial-linkage/changeClassVisibility/"); + } + + @Test + @TestMetadata("changeFunctionVisibility") + public void testChangeFunctionVisibility() { + runTest("compiler/testData/klib/partial-linkage/changeFunctionVisibility/"); + } + + @Test + @TestMetadata("changePropertyVisibility") + public void testChangePropertyVisibility() { + runTest("compiler/testData/klib/partial-linkage/changePropertyVisibility/"); + } + + @Test + @TestMetadata("classTransformations") + public void testClassTransformations() { + runTest("compiler/testData/klib/partial-linkage/classTransformations/"); + } + + @Test + @TestMetadata("externalDeclarations") + public void testExternalDeclarations() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); + } + + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + + @Test + @TestMetadata("functionTransformations") + public void testFunctionTransformations() { + runTest("compiler/testData/klib/partial-linkage/functionTransformations/"); + } + + @Test + @TestMetadata("inheritanceIssues") + public void testInheritanceIssues() { + runTest("compiler/testData/klib/partial-linkage/inheritanceIssues/"); + } + + @Test + @TestMetadata("noNonImplementedCallableFalsePositives") + public void testNoNonImplementedCallableFalsePositives() { + runTest("compiler/testData/klib/partial-linkage/noNonImplementedCallableFalsePositives/"); + } + + @Test + @TestMetadata("nonAbstractCallableBecomesAbstract") + public void testNonAbstractCallableBecomesAbstract() { + runTest("compiler/testData/klib/partial-linkage/nonAbstractCallableBecomesAbstract/"); + } + + @Test + @TestMetadata("nonExhaustivenessOfWhenClause") + public void testNonExhaustivenessOfWhenClause() { + runTest("compiler/testData/klib/partial-linkage/nonExhaustivenessOfWhenClause/"); + } + + @Test + @TestMetadata("propertyTransformations") + public void testPropertyTransformations() { + runTest("compiler/testData/klib/partial-linkage/propertyTransformations/"); + } + + @Test + @TestMetadata("referencingUnusableDeclarations") + public void testReferencingUnusableDeclarations() { + runTest("compiler/testData/klib/partial-linkage/referencingUnusableDeclarations/"); + } + + @Test + @TestMetadata("removeAbstractCallableFromAbstractClassOrInterface") + public void testRemoveAbstractCallableFromAbstractClassOrInterface() { + runTest("compiler/testData/klib/partial-linkage/removeAbstractCallableFromAbstractClassOrInterface/"); + } + + @Test + @TestMetadata("removeCallable") + public void testRemoveCallable() { + runTest("compiler/testData/klib/partial-linkage/removeCallable/"); + } + + @Test + @TestMetadata("removeClass") + public void testRemoveClass() { + runTest("compiler/testData/klib/partial-linkage/removeClass/"); + } + + @Test + @TestMetadata("removeEnumEntry") + public void testRemoveEnumEntry() { + runTest("compiler/testData/klib/partial-linkage/removeEnumEntry/"); + } + + @Test + @TestMetadata("removeSealedSubclass") + public void testRemoveSealedSubclass() { + runTest("compiler/testData/klib/partial-linkage/removeSealedSubclass/"); + } + + @Test + @TestMetadata("replaceCallableReturnType") + public void testReplaceCallableReturnType() { + runTest("compiler/testData/klib/partial-linkage/replaceCallableReturnType/"); + } + + @Test + @TestMetadata("severalInheritedImplementations") + public void testSeveralInheritedImplementations() { + runTest("compiler/testData/klib/partial-linkage/severalInheritedImplementations/"); + } + + @Test + @TestMetadata("typeAliasChanges") + public void testTypeAliasChanges() { + runTest("compiler/testData/klib/partial-linkage/typeAliasChanges/"); + } +} diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/WasmPartialLinkageNoICTestCaseGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/WasmPartialLinkageNoICTestCaseGenerated.java new file mode 100644 index 00000000000..ef120076edf --- /dev/null +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/WasmPartialLinkageNoICTestCaseGenerated.java @@ -0,0 +1,164 @@ +/* + * Copyright 2010-2024 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.wasm.test; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateWasmTestsKt}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/klib/partial-linkage") +@TestDataPath("$PROJECT_ROOT") +public class WasmPartialLinkageNoICTestCaseGenerated extends AbstractWasmPartialLinkageNoICTestCase { + @Test + @TestMetadata("addEnumEntry") + public void testAddEnumEntry() { + runTest("compiler/testData/klib/partial-linkage/addEnumEntry/"); + } + + @Test + @TestMetadata("addSealedSubclass") + public void testAddSealedSubclass() { + runTest("compiler/testData/klib/partial-linkage/addSealedSubclass/"); + } + + @Test + public void testAllFilesPresentInPartial_linkage() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klib/partial-linkage"), Pattern.compile("^([^_](.+))$"), null, TargetBackend.WASM, false); + } + + @Test + @TestMetadata("changeClassVisibility") + public void testChangeClassVisibility() { + runTest("compiler/testData/klib/partial-linkage/changeClassVisibility/"); + } + + @Test + @TestMetadata("changeFunctionVisibility") + public void testChangeFunctionVisibility() { + runTest("compiler/testData/klib/partial-linkage/changeFunctionVisibility/"); + } + + @Test + @TestMetadata("changePropertyVisibility") + public void testChangePropertyVisibility() { + runTest("compiler/testData/klib/partial-linkage/changePropertyVisibility/"); + } + + @Test + @TestMetadata("classTransformations") + public void testClassTransformations() { + runTest("compiler/testData/klib/partial-linkage/classTransformations/"); + } + + @Test + @TestMetadata("externalDeclarations") + public void testExternalDeclarations() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); + } + + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + + @Test + @TestMetadata("functionTransformations") + public void testFunctionTransformations() { + runTest("compiler/testData/klib/partial-linkage/functionTransformations/"); + } + + @Test + @TestMetadata("inheritanceIssues") + public void testInheritanceIssues() { + runTest("compiler/testData/klib/partial-linkage/inheritanceIssues/"); + } + + @Test + @TestMetadata("noNonImplementedCallableFalsePositives") + public void testNoNonImplementedCallableFalsePositives() { + runTest("compiler/testData/klib/partial-linkage/noNonImplementedCallableFalsePositives/"); + } + + @Test + @TestMetadata("nonAbstractCallableBecomesAbstract") + public void testNonAbstractCallableBecomesAbstract() { + runTest("compiler/testData/klib/partial-linkage/nonAbstractCallableBecomesAbstract/"); + } + + @Test + @TestMetadata("nonExhaustivenessOfWhenClause") + public void testNonExhaustivenessOfWhenClause() { + runTest("compiler/testData/klib/partial-linkage/nonExhaustivenessOfWhenClause/"); + } + + @Test + @TestMetadata("propertyTransformations") + public void testPropertyTransformations() { + runTest("compiler/testData/klib/partial-linkage/propertyTransformations/"); + } + + @Test + @TestMetadata("referencingUnusableDeclarations") + public void testReferencingUnusableDeclarations() { + runTest("compiler/testData/klib/partial-linkage/referencingUnusableDeclarations/"); + } + + @Test + @TestMetadata("removeAbstractCallableFromAbstractClassOrInterface") + public void testRemoveAbstractCallableFromAbstractClassOrInterface() { + runTest("compiler/testData/klib/partial-linkage/removeAbstractCallableFromAbstractClassOrInterface/"); + } + + @Test + @TestMetadata("removeCallable") + public void testRemoveCallable() { + runTest("compiler/testData/klib/partial-linkage/removeCallable/"); + } + + @Test + @TestMetadata("removeClass") + public void testRemoveClass() { + runTest("compiler/testData/klib/partial-linkage/removeClass/"); + } + + @Test + @TestMetadata("removeEnumEntry") + public void testRemoveEnumEntry() { + runTest("compiler/testData/klib/partial-linkage/removeEnumEntry/"); + } + + @Test + @TestMetadata("removeSealedSubclass") + public void testRemoveSealedSubclass() { + runTest("compiler/testData/klib/partial-linkage/removeSealedSubclass/"); + } + + @Test + @TestMetadata("replaceCallableReturnType") + public void testReplaceCallableReturnType() { + runTest("compiler/testData/klib/partial-linkage/replaceCallableReturnType/"); + } + + @Test + @TestMetadata("severalInheritedImplementations") + public void testSeveralInheritedImplementations() { + runTest("compiler/testData/klib/partial-linkage/severalInheritedImplementations/"); + } + + @Test + @TestMetadata("typeAliasChanges") + public void testTypeAliasChanges() { + runTest("compiler/testData/klib/partial-linkage/typeAliasChanges/"); + } +} diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/WasmPartialLinkageWithICTestCaseGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/WasmPartialLinkageWithICTestCaseGenerated.java new file mode 100644 index 00000000000..289b1d2e45f --- /dev/null +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/WasmPartialLinkageWithICTestCaseGenerated.java @@ -0,0 +1,164 @@ +/* + * Copyright 2010-2024 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.wasm.test; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.util.KtTestUtil; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.GenerateWasmTestsKt}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/klib/partial-linkage") +@TestDataPath("$PROJECT_ROOT") +public class WasmPartialLinkageWithICTestCaseGenerated extends AbstractWasmPartialLinkageWithICTestCase { + @Test + @TestMetadata("addEnumEntry") + public void testAddEnumEntry() { + runTest("compiler/testData/klib/partial-linkage/addEnumEntry/"); + } + + @Test + @TestMetadata("addSealedSubclass") + public void testAddSealedSubclass() { + runTest("compiler/testData/klib/partial-linkage/addSealedSubclass/"); + } + + @Test + public void testAllFilesPresentInPartial_linkage() { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/klib/partial-linkage"), Pattern.compile("^([^_](.+))$"), null, TargetBackend.WASM, false); + } + + @Test + @TestMetadata("changeClassVisibility") + public void testChangeClassVisibility() { + runTest("compiler/testData/klib/partial-linkage/changeClassVisibility/"); + } + + @Test + @TestMetadata("changeFunctionVisibility") + public void testChangeFunctionVisibility() { + runTest("compiler/testData/klib/partial-linkage/changeFunctionVisibility/"); + } + + @Test + @TestMetadata("changePropertyVisibility") + public void testChangePropertyVisibility() { + runTest("compiler/testData/klib/partial-linkage/changePropertyVisibility/"); + } + + @Test + @TestMetadata("classTransformations") + public void testClassTransformations() { + runTest("compiler/testData/klib/partial-linkage/classTransformations/"); + } + + @Test + @TestMetadata("externalDeclarations") + public void testExternalDeclarations() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarations/"); + } + + @Test + @TestMetadata("externalDeclarationsKJS") + public void testExternalDeclarationsKJS() { + runTest("compiler/testData/klib/partial-linkage/externalDeclarationsKJS/"); + } + + @Test + @TestMetadata("functionTransformations") + public void testFunctionTransformations() { + runTest("compiler/testData/klib/partial-linkage/functionTransformations/"); + } + + @Test + @TestMetadata("inheritanceIssues") + public void testInheritanceIssues() { + runTest("compiler/testData/klib/partial-linkage/inheritanceIssues/"); + } + + @Test + @TestMetadata("noNonImplementedCallableFalsePositives") + public void testNoNonImplementedCallableFalsePositives() { + runTest("compiler/testData/klib/partial-linkage/noNonImplementedCallableFalsePositives/"); + } + + @Test + @TestMetadata("nonAbstractCallableBecomesAbstract") + public void testNonAbstractCallableBecomesAbstract() { + runTest("compiler/testData/klib/partial-linkage/nonAbstractCallableBecomesAbstract/"); + } + + @Test + @TestMetadata("nonExhaustivenessOfWhenClause") + public void testNonExhaustivenessOfWhenClause() { + runTest("compiler/testData/klib/partial-linkage/nonExhaustivenessOfWhenClause/"); + } + + @Test + @TestMetadata("propertyTransformations") + public void testPropertyTransformations() { + runTest("compiler/testData/klib/partial-linkage/propertyTransformations/"); + } + + @Test + @TestMetadata("referencingUnusableDeclarations") + public void testReferencingUnusableDeclarations() { + runTest("compiler/testData/klib/partial-linkage/referencingUnusableDeclarations/"); + } + + @Test + @TestMetadata("removeAbstractCallableFromAbstractClassOrInterface") + public void testRemoveAbstractCallableFromAbstractClassOrInterface() { + runTest("compiler/testData/klib/partial-linkage/removeAbstractCallableFromAbstractClassOrInterface/"); + } + + @Test + @TestMetadata("removeCallable") + public void testRemoveCallable() { + runTest("compiler/testData/klib/partial-linkage/removeCallable/"); + } + + @Test + @TestMetadata("removeClass") + public void testRemoveClass() { + runTest("compiler/testData/klib/partial-linkage/removeClass/"); + } + + @Test + @TestMetadata("removeEnumEntry") + public void testRemoveEnumEntry() { + runTest("compiler/testData/klib/partial-linkage/removeEnumEntry/"); + } + + @Test + @TestMetadata("removeSealedSubclass") + public void testRemoveSealedSubclass() { + runTest("compiler/testData/klib/partial-linkage/removeSealedSubclass/"); + } + + @Test + @TestMetadata("replaceCallableReturnType") + public void testReplaceCallableReturnType() { + runTest("compiler/testData/klib/partial-linkage/replaceCallableReturnType/"); + } + + @Test + @TestMetadata("severalInheritedImplementations") + public void testSeveralInheritedImplementations() { + runTest("compiler/testData/klib/partial-linkage/severalInheritedImplementations/"); + } + + @Test + @TestMetadata("typeAliasChanges") + public void testTypeAliasChanges() { + runTest("compiler/testData/klib/partial-linkage/typeAliasChanges/"); + } +}