From 50dd1e31c35298cbc703770ea0cfad9265a61028 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 31 May 2016 14:28:54 +0300 Subject: [PATCH] KT-2752: move tests, that check whether there's no name clash, to JS backend tests --- ...pertiesWithDifferentReceiversDoNotClash.kt | 11 ----- ...ertiesWithDifferentReceiversDoNotClash.txt | 20 --------- .../extensionPropertyAndMethodDoNotClash.kt | 8 ---- .../extensionPropertyAndMethodDoNotClash.txt | 13 ------ .../name/jsNameAndPrivateDontClash.kt | 5 --- .../name/jsNameAndPrivateDontClash.txt | 6 --- .../methodAndPrivatePropertyDoNotClash.kt | 5 --- .../methodAndPrivatePropertyDoNotClash.txt | 6 --- .../name/packageAndMangledMethodDoNotClash.kt | 11 ----- .../packageAndMangledMethodDoNotClash.txt | 9 ---- ...packageAndPrivateDeclarationsDoNotClash.kt | 13 ------ ...ackageAndPrivateDeclarationsDoNotClash.txt | 10 ----- .../name/propertyAndNativeMethodDoNotClash.kt | 5 --- .../propertyAndNativeMethodDoNotClash.txt | 6 --- .../DiagnosticsTestWithJsStdLibGenerated.java | 42 ------------------- .../kotlin/js/PredefinedAnnotation.kt | 3 +- .../js/translate/utils/AnnotationsUtils.java | 3 +- .../packageAndMangledMethodDoNotClash/foo.kt | 9 ++++ .../foobar.kt | 3 ++ .../foo.kt | 13 ++++++ .../foobar.kt | 3 ++ ...tensionPropertiesWithDifferentReceivers.kt | 18 ++++++++ .../cases/extensionPropertyAndMethod.kt | 15 +++++++ .../nameClashes/cases/jsNameAndPrivate.kt | 12 ++++++ .../cases/methodAndPrivateProperty.kt | 12 ++++++ .../cases/propertyAndNativeMethod.kt | 16 +++++++ 26 files changed, 104 insertions(+), 173 deletions(-) delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.kt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.txt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.kt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.txt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.kt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.txt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.kt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.txt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.kt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.txt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.kt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.txt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.kt delete mode 100644 compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.txt create mode 100644 js/js.translator/testData/multiFile/cases/packageAndMangledMethodDoNotClash/foo.kt create mode 100644 js/js.translator/testData/multiFile/cases/packageAndMangledMethodDoNotClash/foobar.kt create mode 100644 js/js.translator/testData/multiFile/cases/packageAndPrivateDeclarationDoNotClash/foo.kt create mode 100644 js/js.translator/testData/multiFile/cases/packageAndPrivateDeclarationDoNotClash/foobar.kt create mode 100644 js/js.translator/testData/nameClashes/cases/extensionPropertiesWithDifferentReceivers.kt create mode 100644 js/js.translator/testData/nameClashes/cases/extensionPropertyAndMethod.kt create mode 100644 js/js.translator/testData/nameClashes/cases/jsNameAndPrivate.kt create mode 100644 js/js.translator/testData/nameClashes/cases/methodAndPrivateProperty.kt create mode 100644 js/js.translator/testData/nameClashes/cases/propertyAndNativeMethod.kt diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.kt deleted file mode 100644 index 1fbc24f8073..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.kt +++ /dev/null @@ -1,11 +0,0 @@ -package foo - -class A - -class B - -val A.foo: Int - get() = 32 - -val B.foo: Int - get() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.txt deleted file mode 100644 index 8221186c213..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.txt +++ /dev/null @@ -1,20 +0,0 @@ -package - -package foo { - public val foo.A.foo: kotlin.Int - public val foo.B.foo: kotlin.Int - - public final class A { - public constructor A() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } - - public final class B { - public constructor B() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.kt deleted file mode 100644 index 4819f4ad2c6..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.kt +++ /dev/null @@ -1,8 +0,0 @@ -package foo - -class A - -fun A.bar() = 32 - -val A.bar: Int - get() = 32 diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.txt deleted file mode 100644 index 8132618654f..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.txt +++ /dev/null @@ -1,13 +0,0 @@ -package - -package foo { - public val foo.A.bar: kotlin.Int - public fun foo.A.bar(): kotlin.Int - - public final class A { - public constructor A() - public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean - public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int - public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.kt deleted file mode 100644 index 211ec56a648..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.kt +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -@JsName("bar") fun foo(x: Int) = x - -private fun bar() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.txt deleted file mode 100644 index 7198e8d83fa..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.txt +++ /dev/null @@ -1,6 +0,0 @@ -package - -package foo { - private fun bar(): kotlin.Int - @kotlin.js.JsName(name = "bar") public fun foo(/*0*/ x: kotlin.Int): kotlin.Int -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.kt deleted file mode 100644 index 0be8d4cfdc5..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.kt +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -fun bar() = 23 - -private val bar = 32 \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.txt deleted file mode 100644 index 942f6deaa0b..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.txt +++ /dev/null @@ -1,6 +0,0 @@ -package - -package foo { - private val bar: kotlin.Int = 32 - public fun bar(): kotlin.Int -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.kt deleted file mode 100644 index 2a47e165ab2..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.kt +++ /dev/null @@ -1,11 +0,0 @@ -// FILE: foo.kt - -package foo - -fun bar(x: Int) = x - -// FILE: foobar.kt - -package foo.bar - -val x = 42 diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.txt deleted file mode 100644 index 62873f6bfec..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.txt +++ /dev/null @@ -1,9 +0,0 @@ -package - -package foo { - public fun bar(/*0*/ x: kotlin.Int): kotlin.Int - - package foo.bar { - public val x: kotlin.Int = 42 - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.kt deleted file mode 100644 index 5334f1ad88f..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.kt +++ /dev/null @@ -1,13 +0,0 @@ -// FILE: foo.kt - -package foo - -private fun bar() = 23 - -private val bar = 42 - -// FILE: foobar.kt - -package foo.bar - -val x = 42 diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.txt deleted file mode 100644 index 16ee05a24f7..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.txt +++ /dev/null @@ -1,10 +0,0 @@ -package - -package foo { - private val bar: kotlin.Int = 42 - private fun bar(): kotlin.Int - - package foo.bar { - public val x: kotlin.Int = 42 - } -} diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.kt b/compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.kt deleted file mode 100644 index 8be66dee682..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.kt +++ /dev/null @@ -1,5 +0,0 @@ -package foo - -@native fun bar() = 23 - -val bar = 32 \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.txt b/compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.txt deleted file mode 100644 index 1c452ee3c26..00000000000 --- a/compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.txt +++ /dev/null @@ -1,6 +0,0 @@ -package - -package foo { - public val bar: kotlin.Int = 32 - @kotlin.js.native() public fun bar(): kotlin.Int -} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java index 41000c75beb..2a5b3a8bb55 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithJsStdLibGenerated.java @@ -301,36 +301,18 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes doTest(fileName); } - @TestMetadata("extensionPropertiesWithDifferentReceiversDoNotClash.kt") - public void testExtensionPropertiesWithDifferentReceiversDoNotClash() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.kt"); - doTest(fileName); - } - @TestMetadata("extensionPropertyAndMethod.kt") public void testExtensionPropertyAndMethod() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethod.kt"); doTest(fileName); } - @TestMetadata("extensionPropertyAndMethodDoNotClash.kt") - public void testExtensionPropertyAndMethodDoNotClash() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.kt"); - doTest(fileName); - } - @TestMetadata("jsNameAndOverridden.kt") public void testJsNameAndOverridden() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndOverridden.kt"); doTest(fileName); } - @TestMetadata("jsNameAndPrivateDontClash.kt") - public void testJsNameAndPrivateDontClash() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.kt"); - doTest(fileName); - } - @TestMetadata("jsNameClash.kt") public void testJsNameClash() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameClash.kt"); @@ -349,30 +331,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes doTest(fileName); } - @TestMetadata("methodAndPrivatePropertyDoNotClash.kt") - public void testMethodAndPrivatePropertyDoNotClash() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.kt"); - doTest(fileName); - } - - @TestMetadata("packageAndMangledMethodDoNotClash.kt") - public void testPackageAndMangledMethodDoNotClash() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.kt"); - doTest(fileName); - } - @TestMetadata("packageAndMethod.kt") public void testPackageAndMethod() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMethod.kt"); doTest(fileName); } - @TestMetadata("packageAndPrivateDeclarationsDoNotClash.kt") - public void testPackageAndPrivateDeclarationsDoNotClash() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.kt"); - doTest(fileName); - } - @TestMetadata("packageAndProperty.kt") public void testPackageAndProperty() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndProperty.kt"); @@ -391,12 +355,6 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes doTest(fileName); } - @TestMetadata("propertyAndNativeMethodDoNotClash.kt") - public void testPropertyAndNativeMethodDoNotClash() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.kt"); - doTest(fileName); - } - @TestMetadata("topLevelMethodAndJsNameConstructor.kt") public void testTopLevelMethodAndJsNameConstructor() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/topLevelMethodAndJsNameConstructor.kt"); diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt index 4bb71fbb188..112df9a087b 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/PredefinedAnnotation.kt @@ -23,8 +23,7 @@ enum class PredefinedAnnotation(fqName: String) { NATIVE("kotlin.js.native"), NATIVE_INVOKE("kotlin.js.nativeInvoke"), NATIVE_GETTER("kotlin.js.nativeGetter"), - NATIVE_SETTER("kotlin.js.nativeSetter"), - JS_NAME("kotlin.js.JsName"); + NATIVE_SETTER("kotlin.js.nativeSetter"); val fqName: FqName = FqName(fqName) diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java b/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java index 76aa0c7cf0b..5c248c7e938 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/translate/utils/AnnotationsUtils.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.Set; public final class AnnotationsUtils { + private static final String JS_NAME = "kotlin.js.JsName"; private AnnotationsUtils() { } @@ -128,7 +129,7 @@ public final class AnnotationsUtils { @Nullable public static String getJsName(@NotNull DeclarationDescriptor descriptor) { - AnnotationDescriptor annotation = getAnnotationByName(descriptor, PredefinedAnnotation.JS_NAME.getFqName()); + AnnotationDescriptor annotation = getAnnotationByName(descriptor, new FqName(JS_NAME)); if (annotation == null) return null; ConstantValue value = annotation.getAllValueArguments().values().iterator().next(); diff --git a/js/js.translator/testData/multiFile/cases/packageAndMangledMethodDoNotClash/foo.kt b/js/js.translator/testData/multiFile/cases/packageAndMangledMethodDoNotClash/foo.kt new file mode 100644 index 00000000000..17e9af71c48 --- /dev/null +++ b/js/js.translator/testData/multiFile/cases/packageAndMangledMethodDoNotClash/foo.kt @@ -0,0 +1,9 @@ +package foo + +fun bar(x: Int) = x + +fun box(): Boolean { + assertEquals(23, bar(23)) + assertEquals(42, foo.bar.x) + return true +} \ No newline at end of file diff --git a/js/js.translator/testData/multiFile/cases/packageAndMangledMethodDoNotClash/foobar.kt b/js/js.translator/testData/multiFile/cases/packageAndMangledMethodDoNotClash/foobar.kt new file mode 100644 index 00000000000..98df7475285 --- /dev/null +++ b/js/js.translator/testData/multiFile/cases/packageAndMangledMethodDoNotClash/foobar.kt @@ -0,0 +1,3 @@ +package foo.bar + +val x = 42 \ No newline at end of file diff --git a/js/js.translator/testData/multiFile/cases/packageAndPrivateDeclarationDoNotClash/foo.kt b/js/js.translator/testData/multiFile/cases/packageAndPrivateDeclarationDoNotClash/foo.kt new file mode 100644 index 00000000000..daf48a4ca52 --- /dev/null +++ b/js/js.translator/testData/multiFile/cases/packageAndPrivateDeclarationDoNotClash/foo.kt @@ -0,0 +1,13 @@ +package foo + +private fun bar() = 23 + +private val bar = 42 + +fun box(): Boolean { + assertEquals(23, bar()) + assertEquals(42, bar) + assertEquals(32, foo.bar.x) + + return true +} \ No newline at end of file diff --git a/js/js.translator/testData/multiFile/cases/packageAndPrivateDeclarationDoNotClash/foobar.kt b/js/js.translator/testData/multiFile/cases/packageAndPrivateDeclarationDoNotClash/foobar.kt new file mode 100644 index 00000000000..dcce29f891e --- /dev/null +++ b/js/js.translator/testData/multiFile/cases/packageAndPrivateDeclarationDoNotClash/foobar.kt @@ -0,0 +1,3 @@ +package foo.bar + +val x = 32 diff --git a/js/js.translator/testData/nameClashes/cases/extensionPropertiesWithDifferentReceivers.kt b/js/js.translator/testData/nameClashes/cases/extensionPropertiesWithDifferentReceivers.kt new file mode 100644 index 00000000000..b7480bb7697 --- /dev/null +++ b/js/js.translator/testData/nameClashes/cases/extensionPropertiesWithDifferentReceivers.kt @@ -0,0 +1,18 @@ +package foo + +class A + +class B + +val A.foo: Int + get() = 32 + +val B.foo: Int + get() = 42 + +fun box(): String { + assertEquals(32, A().foo) + assertEquals(42, B().foo) + + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/nameClashes/cases/extensionPropertyAndMethod.kt b/js/js.translator/testData/nameClashes/cases/extensionPropertyAndMethod.kt new file mode 100644 index 00000000000..2858308188c --- /dev/null +++ b/js/js.translator/testData/nameClashes/cases/extensionPropertyAndMethod.kt @@ -0,0 +1,15 @@ +package foo + +class A + +fun A.bar() = 23 + +val A.bar: Int + get() = 42 + +fun box(): String { + assertEquals(23, A().bar()) + assertEquals(42, A().bar) + + return "OK" +} diff --git a/js/js.translator/testData/nameClashes/cases/jsNameAndPrivate.kt b/js/js.translator/testData/nameClashes/cases/jsNameAndPrivate.kt new file mode 100644 index 00000000000..29990bca281 --- /dev/null +++ b/js/js.translator/testData/nameClashes/cases/jsNameAndPrivate.kt @@ -0,0 +1,12 @@ +package foo + +@JsName("bar") fun foo(x: Int) = x + +private fun bar() = 42 + +fun box(): String { + assertEquals(23, foo(23)) + assertEquals(42, bar()) + + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/nameClashes/cases/methodAndPrivateProperty.kt b/js/js.translator/testData/nameClashes/cases/methodAndPrivateProperty.kt new file mode 100644 index 00000000000..10fa3267cdf --- /dev/null +++ b/js/js.translator/testData/nameClashes/cases/methodAndPrivateProperty.kt @@ -0,0 +1,12 @@ +package foo + +fun bar() = 23 + +private val bar = 32 + +fun box(): String { + assertEquals(23, bar()) + assertEquals(32, bar) + + return "OK" +} \ No newline at end of file diff --git a/js/js.translator/testData/nameClashes/cases/propertyAndNativeMethod.kt b/js/js.translator/testData/nameClashes/cases/propertyAndNativeMethod.kt new file mode 100644 index 00000000000..9cedb56e5ca --- /dev/null +++ b/js/js.translator/testData/nameClashes/cases/propertyAndNativeMethod.kt @@ -0,0 +1,16 @@ +package foo + +@native fun bar() + +val bar = 32 + +fun createNativeBar() = js("bar = function() { return 23; };") + +fun box(): String { + createNativeBar() + + assertEquals(23, bar()) + assertEquals(32, bar) + + return "OK" +} \ No newline at end of file