Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1760)

Unified Diff: runtime/vm/object.cc

Issue 2835363002: Properly handle implicit closure function when a generic function. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 08821a27c542653e4afa6d19076ed8b2754b7551..28b4dbee71ec0f81088e2fe66f1415791c8db73e 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -5616,6 +5616,11 @@ void Function::set_parent_function(const Function& value) const {
bool Function::HasGenericParent() const {
+ if (IsImplicitClosureFunction()) {
+ // The parent function of an implicit closure function is not the enclosing
+ // function we are asking about here.
+ return false;
+ }
Function& parent = Function::Handle(parent_function());
while (!parent.IsNull()) {
if (parent.IsGeneric()) {
@@ -6014,6 +6019,9 @@ intptr_t Function::NumTypeParameters(Thread* thread) const {
intptr_t Function::NumParentTypeParameters() const {
+ if (IsImplicitClosureFunction()) {
+ return 0;
+ }
Thread* thread = Thread::Current();
Function& parent = Function::Handle(parent_function());
intptr_t num_parent_type_params = 0;
@@ -6052,6 +6060,11 @@ RawTypeParameter* Function::LookupTypeParameter(
}
}
}
+ if (function.IsImplicitClosureFunction()) {
+ // The parent function is not the enclosing function, but the closurized
+ // function with identical type parameters.
+ break;
+ }
function ^= function.parent_function();
if (function_level != NULL) {
(*function_level)--;
@@ -6343,11 +6356,14 @@ enum QualifiedFunctionLibKind {
static intptr_t ConstructFunctionFullyQualifiedCString(
- const Function& function,
+ const Function& fun,
char** chars,
intptr_t reserve_len,
bool with_lib,
QualifiedFunctionLibKind lib_kind) {
+ // Hide implicit closure functions.
+ const Function& function = Function::Handle(
rmacnak 2017/04/25 19:21:42 I think this output is only used for debug printin
regis 2017/04/25 19:57:26 OK, I removed the change.
+ fun.IsImplicitClosureFunction() ? fun.parent_function() : fun.raw());
const char* name = String::Handle(function.name()).ToCString();
const char* function_format = (reserve_len == 0) ? "%s" : "%s_";
reserve_len += OS::SNPrint(NULL, 0, function_format, name);
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698