diff --git a/src/objects-inl.h b/src/objects-inl.h index ce82bdec88..94dcba827d 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -8215,16 +8215,6 @@ static inline Handle MakeEntryPair(Isolate* isolate, Handle key, FAST_ELEMENTS, 2); } -JSIteratorResult* JSIteratorResult::cast(Object* object) { - SLOW_DCHECK(object->IsJSObject() && - JSObject::cast(object)->map() == - JSObject::cast(object) - ->GetIsolate() - ->native_context() - ->iterator_result_map()); - return reinterpret_cast(object); -} - ACCESSORS(JSIteratorResult, value, Object, kValueOffset) ACCESSORS(JSIteratorResult, done, Object, kDoneOffset) diff --git a/src/objects.cc b/src/objects.cc index 8d73561210..6e9a12001d 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -20031,8 +20031,12 @@ MaybeHandle Module::Evaluate(Handle module) { ASSIGN_RETURN_ON_EXCEPTION( isolate, result, Execution::Call(isolate, resume, generator, 0, nullptr), Object); - DCHECK(Handle::cast(result)->done()->BooleanValue()); - return handle(Handle::cast(result)->value(), isolate); + DCHECK(static_cast(JSObject::cast(*result)) + ->done() + ->BooleanValue()); + return handle( + static_cast(JSObject::cast(*result))->value(), + isolate); } namespace { diff --git a/src/objects.h b/src/objects.h index c847173d0d..ee86d15773 100644 --- a/src/objects.h +++ b/src/objects.h @@ -2639,9 +2639,8 @@ class JSDataPropertyDescriptor: public JSObject { // as specified by ES6 section 25.1.1.3 The IteratorResult Interface class JSIteratorResult: public JSObject { public: - DECLARE_CAST(JSIteratorResult) - DECL_ACCESSORS(value, Object) + DECL_ACCESSORS(done, Object) // Offsets of object fields. diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc index 68c5e0fdb8..11af9cb159 100644 --- a/src/parsing/parser.cc +++ b/src/parsing/parser.cc @@ -1508,12 +1508,14 @@ Statement* Parser::DeclareClass(const AstRawString* variable_name, Declaration* decl = DeclareVariable(variable_name, LET, class_token_pos, CHECK_OK); decl->proxy()->var()->set_initializer_position(end_pos); + if (names) names->Add(variable_name, zone()); + Assignment* assignment = factory()->NewAssignment(Token::INIT, decl->proxy(), value, class_token_pos); - Statement* assignment_statement = - factory()->NewExpressionStatement(assignment, kNoSourcePosition); - if (names) names->Add(variable_name, zone()); - return assignment_statement; + Block* block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition); + block->statements()->Add( + factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone()); + return block; } Statement* Parser::DeclareNative(const AstRawString* name, int pos, bool* ok) { diff --git a/test/cctest/test-modules.cc b/test/cctest/test-modules.cc index 52c7eeddba..9e8bf100d5 100644 --- a/test/cctest/test-modules.cc +++ b/test/cctest/test-modules.cc @@ -104,14 +104,21 @@ TEST(ModuleEvaluationCompletion1) { LocalContext env; const char* sources[] = { - "", "var a = 1", "import '42'", "export * from '42'", - "export {} from '42'", "export {}", "var a = 1; export {a}", + "", + "var a = 1", + "import '42'", + "export * from '42'", + "export {} from '42'", + "export {}", + "var a = 1; export {a}", "export function foo() {}", - // TODO(neis): v8:6022 "export class C extends null {}", - "export let a = 1", "export default 1", - "export default function foo() {}", "export default function () {}", + "export class C extends null {}", + "export let a = 1", + "export default 1", + "export default function foo() {}", + "export default function () {}", "export default (function () {})", - // TODO(neis): v8:6022 "export default class C extends null {}", + "export default class C extends null {}", "export default (class C extends null {})", "for (var i = 0; i < 5; ++i) {}", }; @@ -134,16 +141,21 @@ TEST(ModuleEvaluationCompletion2) { LocalContext env; const char* sources[] = { - "'gaga'; ", "'gaga'; var a = 1", "'gaga'; import '42'", - "'gaga'; export * from '42'", "'gaga'; export {} from '42'", - "'gaga'; export {}", "'gaga'; var a = 1; export {a}", + "'gaga'; ", + "'gaga'; var a = 1", + "'gaga'; import '42'", + "'gaga'; export * from '42'", + "'gaga'; export {} from '42'", + "'gaga'; export {}", + "'gaga'; var a = 1; export {a}", "'gaga'; export function foo() {}", - // TODO(neis): v8:6022 "'gaga'; export class C extends null {}", - "'gaga'; export let a = 1", "'gaga'; export default 1", + "'gaga'; export class C extends null {}", + "'gaga'; export let a = 1", + "'gaga'; export default 1", "'gaga'; export default function foo() {}", "'gaga'; export default function () {}", "'gaga'; export default (function () {})", - // TODO(neis): v8:6022 "'gaga'; export default class C extends null {}", + "'gaga'; export default class C extends null {}", "'gaga'; export default (class C extends null {})", }; diff --git a/test/mjsunit/es6/classes.js b/test/mjsunit/es6/classes.js index 816d113263..f8a1499aef 100644 --- a/test/mjsunit/es6/classes.js +++ b/test/mjsunit/es6/classes.js @@ -628,7 +628,7 @@ function assertAccessorDescriptor(object, name) { (function TestConstructorCall(){ var realmIndex = Realm.create(); var otherTypeError = Realm.eval(realmIndex, "TypeError"); - var A = Realm.eval(realmIndex, '"use strict"; class A {}'); + var A = Realm.eval(realmIndex, '"use strict"; class A {}; A'); var instance = new A(); var constructor = instance.constructor; var otherTypeError = Realm.eval(realmIndex, 'TypeError'); diff --git a/test/mjsunit/es6/completion.js b/test/mjsunit/es6/completion.js index 9d84a90406..b9d93f41c0 100644 --- a/test/mjsunit/es6/completion.js +++ b/test/mjsunit/es6/completion.js @@ -8,6 +8,16 @@ function assertUndef(x) { } +// ClassDeclaration + +assertUndef(eval('class C {}')); +assertUndef(eval('class C {m() {}}')); +assertUndef(eval('class C extends null {}')); +assertEquals(42, eval('42; class C {}')); +assertEquals(42, eval('42; class C {m() {}}')); +assertEquals(42, eval('42; class C extends null {}')); + + // IfStatement [13.6.7] assertUndef(eval('42; if (true) ; else 0;')); // ES5: 42