Commit e80cfa00 authored by luoe's avatar luoe Committed by Commit bot

Generate inferred names for es6 class functions

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}
parent 2f060955
......@@ -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;
}
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment