diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/PropertyAccessTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/PropertyAccessTest.java index af856b38ea7..b4c8c33094f 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/PropertyAccessTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/PropertyAccessTest.java @@ -102,6 +102,10 @@ public final class PropertyAccessTest extends SingleFileTranslationTest { checkFooBoxIsOk(); } + public void testPrivatePropertyAccessFromMethod() throws Exception { + checkFooBoxIsOk(); + } + @Override @NotNull protected List additionalJsFiles(@NotNull EcmaVersion ecmaVersion) { diff --git a/js/js.translator/testData/propertyAccess/cases/privatePropertyAccessFromMethod.kt b/js/js.translator/testData/propertyAccess/cases/privatePropertyAccessFromMethod.kt new file mode 100644 index 00000000000..4b9bb7b7d97 --- /dev/null +++ b/js/js.translator/testData/propertyAccess/cases/privatePropertyAccessFromMethod.kt @@ -0,0 +1,22 @@ +package foo + +object A { + private val foo = 23 + + fun bar(): Int { + // Erase object so that we ensure that access to 'foo' property is performed via 'this' + // It's no crucial from runtime standpoind, but JS code looks more concise and natural this way. + erase() + return foo + } + + fun erase() { + js("_.foo.A = null") + } +} + +fun box(): String { + var result = A.bar() + if (result != 23) return "failed: ${result}" + return "OK" +} \ No newline at end of file