Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

Commit

Permalink
Generate inferred names for es6 class functions
Browse files Browse the repository at this point in the history
Inferred names are currently generated for FunctionLiterals but not generated
for ClassLiterals. Without them, DevTools does not have enough information to
make descriptive descriptions.

E.g.
var x = {y: class{}};
var a = new x.y();
console.log(a);

This shows "Object{}" when it could be more descriptive "x.y {}"

BUG=v8:5621
CQ_INCLUDE_TRYBOTS=master.tryserver.blink:linux_precise_blink_rel

Review-Url: https://codereview.chromium.org/2488193003
Cr-Commit-Position: refs/heads/master@{#41013}
  • Loading branch information
psybuzz authored and Commit bot committed Nov 15, 2016
1 parent 2f06095 commit e80cfa0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/parsing/parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3622,6 +3622,7 @@ Expression* Parser::RewriteClassLiteral(const AstRawString* name,
}
do_block->set_scope(scope()->FinalizeBlockScope());
do_expr->set_represented_function(class_info->constructor);
AddFunctionForNameInference(class_info->constructor);

return do_expr;
}
Expand Down
13 changes: 13 additions & 0 deletions test/cctest/test-func-name-inference.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ TEST(LocalVar) {
CheckFunctionName(script, "return 2", "fun2");
}

TEST(ObjectProperty) {
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());

v8::Local<v8::Script> script =
Compile(CcTest::isolate(),
"var obj = {\n"
" fun1: function() { return 1; },\n"
" fun2: class { constructor() { return 2; } }\n"
"}");
CheckFunctionName(script, "return 1", "obj.fun1");
CheckFunctionName(script, "return 2", "obj.fun2");
}

TEST(InConstructor) {
CcTest::InitializeVM();
Expand Down

0 comments on commit e80cfa0

Please sign in to comment.