[JS BE] Make properties configurable when implementing an interface by delegation

#KT-42364 Fixed
This commit is contained in:
Victor Turansky
2020-10-20 15:49:29 +03:00
committed by GitHub
parent 2ad13847d1
commit 4d4aabab8d
2 changed files with 15 additions and 1 deletions
@@ -194,6 +194,7 @@ class DelegationTranslator(
} }
else { else {
val literal = JsObjectLiteral(true) val literal = JsObjectLiteral(true)
literal.propertyInitializers += JsPropertyInitializer(JsStringLiteral("configurable"), JsBooleanLiteral(true))
literal.propertyInitializers.addGetterAndSetter(descriptor, ::generateDelegateGetter, ::generateDelegateSetter) literal.propertyInitializers.addGetterAndSetter(descriptor, ::generateDelegateGetter, ::generateDelegateSetter)
context().addAccessorsToPrototype(classDescriptor, descriptor, literal) context().addAccessorsToPrototype(classDescriptor, descriptor, literal)
} }
@@ -1,4 +1,4 @@
// EXPECTED_REACHABLE_NODES: 1325 // EXPECTED_REACHABLE_NODES: 1345
// KJS_WITH_FULL_RUNTIME // KJS_WITH_FULL_RUNTIME
package foo package foo
@@ -15,11 +15,18 @@ class P : EP {
get() = true get() = true
} }
class PD : EP by P()
fun usages() { fun usages() {
val p = P() val p = P()
assertEquals(13, p.simpleProp) assertEquals(13, p.simpleProp)
assertEquals("42", p.anotherProp) assertEquals("42", p.anotherProp)
assertEquals(true, p.propWithGetter) assertEquals(true, p.propWithGetter)
val pd = PD()
assertEquals(13, pd.simpleProp)
assertEquals("42", pd.anotherProp)
assertEquals(true, pd.propWithGetter)
} }
fun box(): String { fun box(): String {
@@ -31,6 +38,12 @@ fun box(): String {
assertTrue(isConfigurable(prototype, "anotherProp")) assertTrue(isConfigurable(prototype, "anotherProp"))
assertTrue(isConfigurable(prototype, "propWithGetter")) assertTrue(isConfigurable(prototype, "propWithGetter"))
val delegatePrototype = PD::class.js.asDynamic().prototype
assertTrue(isConfigurable(delegatePrototype, "simpleProp"))
assertTrue(isConfigurable(delegatePrototype, "anotherProp"))
assertTrue(isConfigurable(delegatePrototype, "propWithGetter"))
return "OK" return "OK"
} }