Skip to content

Commit 363bc92

Browse files
authored
Remove new target workaround from super call (#4447)
After #4372 and #4369 all builtin constructors have new target support. This patch fixes #4446. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik [email protected]
1 parent df6d430 commit 363bc92

File tree

3 files changed

+34
-37
lines changed

3 files changed

+34
-37
lines changed

jerry-core/vm/opcodes.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1184,30 +1184,13 @@ ecma_op_implicit_constructor_handler_heritage_cb (const ecma_value_t function_ob
11841184

11851185
if (ecma_is_value_object (result))
11861186
{
1187-
ecma_value_t proto_value = ecma_op_object_get_by_magic_id (JERRY_CONTEXT (current_new_target),
1188-
LIT_MAGIC_STRING_PROTOTYPE);
1189-
if (ECMA_IS_VALUE_ERROR (proto_value))
1187+
ecma_value_t fields_value = opfunc_init_class_fields (function_obj, result);
1188+
1189+
if (ECMA_IS_VALUE_ERROR (fields_value))
11901190
{
11911191
ecma_free_value (result);
11921192
result = ECMA_VALUE_ERROR;
11931193
}
1194-
else
1195-
{
1196-
if (ecma_is_value_object (proto_value))
1197-
{
1198-
ECMA_SET_POINTER (ecma_get_object_from_value (result)->u2.prototype_cp,
1199-
ecma_get_object_from_value (proto_value));
1200-
}
1201-
1202-
ecma_value_t fields_value = opfunc_init_class_fields (function_obj, result);
1203-
1204-
if (ECMA_IS_VALUE_ERROR (fields_value))
1205-
{
1206-
ecma_free_value (result);
1207-
result = ECMA_VALUE_ERROR;
1208-
}
1209-
}
1210-
ecma_free_value (proto_value);
12111194
}
12121195

12131196
ecma_deref_object (super_ctor_p);

jerry-core/vm/vm.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -606,23 +606,6 @@ vm_super_call (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
606606
arguments_p,
607607
arguments_list_len);
608608

609-
if (ecma_is_value_object (completion_value))
610-
{
611-
ecma_value_t proto_value = ecma_op_object_get_by_magic_id (JERRY_CONTEXT (current_new_target),
612-
LIT_MAGIC_STRING_PROTOTYPE);
613-
if (ECMA_IS_VALUE_ERROR (proto_value))
614-
{
615-
ecma_free_value (completion_value);
616-
completion_value = ECMA_VALUE_ERROR;
617-
}
618-
else if (ecma_is_value_object (proto_value))
619-
{
620-
ECMA_SET_POINTER (ecma_get_object_from_value (completion_value)->u2.prototype_cp,
621-
ecma_get_object_from_value (proto_value));
622-
}
623-
ecma_free_value (proto_value);
624-
}
625-
626609
if (!ECMA_IS_VALUE_ERROR (completion_value) && ecma_op_this_binding_is_initialized (environment_record_p))
627610
{
628611
ecma_free_value (completion_value);
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright JS Foundation and other contributors, http://js.foundation
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
class Base {
16+
constructor() {
17+
return new Proxy(this, {
18+
defineProperty(target, p, desc) {
19+
return Reflect.defineProperty(target, p, desc);
20+
}
21+
});
22+
}
23+
}
24+
25+
let computedKey = "test";
26+
class BasicTPK extends Base {
27+
[computedKey] = "basic";
28+
}
29+
30+
let instance = new BasicTPK;
31+
assert(instance instanceof BasicTPK);

0 commit comments

Comments
 (0)