[JS IR] Fix generating property accessors

TL;DR, before we were emitting this JS code:
  Object.defineProperty(Base.prototype, 'bar', {
    configurable: true,
    get: Base.prototype._get_bar__0_k$,
    set: Base.prototype._set_bar__a4enbm_k$
  });

Now we emit this code instead:
  Object.defineProperty(Base.prototype, 'bar', {
    configurable: true,
    get: function () {
      return this._get_bar__0_k$();
    },
    set: function (value) {
      this._set_bar__a4enbm_k$(value);
    }
  });

This fixes the issue where if we had a @JsExport'ed base class with a
public property overridden in a non-exported derived class, we couldn't
access that property from JS if we were given an instance of
the derived class.

#KT-41912 Fixed
This commit is contained in:
Sergej Jaskiewicz
2021-09-09 17:37:28 +03:00
committed by TeamCityServer
parent 841f5a583e
commit f0f60907e2
6 changed files with 251 additions and 6 deletions
@@ -6990,6 +6990,11 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
runTest("js/js.translator/testData/box/propertyOverride/checkSupertypeOrder.kt");
}
@TestMetadata("exportedBaseClass.kt")
public void testExportedBaseClass() throws Exception {
runTest("js/js.translator/testData/box/propertyOverride/exportedBaseClass.kt");
}
@TestMetadata("initOverrideInConstructor.kt")
public void testInitOverrideInConstructor() throws Exception {
runTest("js/js.translator/testData/box/propertyOverride/initOverrideInConstructor.kt");
@@ -6990,6 +6990,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
runTest("js/js.translator/testData/box/propertyOverride/checkSupertypeOrder.kt");
}
@TestMetadata("exportedBaseClass.kt")
public void testExportedBaseClass() throws Exception {
runTest("js/js.translator/testData/box/propertyOverride/exportedBaseClass.kt");
}
@TestMetadata("initOverrideInConstructor.kt")
public void testInitOverrideInConstructor() throws Exception {
runTest("js/js.translator/testData/box/propertyOverride/initOverrideInConstructor.kt");
@@ -7010,6 +7010,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
runTest("js/js.translator/testData/box/propertyOverride/checkSupertypeOrder.kt");
}
@TestMetadata("exportedBaseClass.kt")
public void testExportedBaseClass() throws Exception {
runTest("js/js.translator/testData/box/propertyOverride/exportedBaseClass.kt");
}
@TestMetadata("initOverrideInConstructor.kt")
public void testInitOverrideInConstructor() throws Exception {
runTest("js/js.translator/testData/box/propertyOverride/initOverrideInConstructor.kt");