Treat functions generated for closurization as equivalent to their source functions.

BUG=http://dartbug.com/22601
R=asiva@google.com, gbracha@google.com

Review URL: https://codereview.chromium.org//973913002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44674 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
rmacnak@google.com 2015-03-24 20:06:40 +00:00
parent 3d8bd5fcb6
commit 60fd23bffc
3 changed files with 35 additions and 0 deletions

View file

@ -1366,6 +1366,13 @@ DEFINE_NATIVE_ENTRY(ClosureMirror_function, 1) {
Function& function = Function::Handle();
bool callable = closure.IsCallable(&function);
if (callable) {
if (function.IsImplicitClosureFunction()) {
// The VM uses separate Functions for tear-offs, but the mirrors consider
// the tear-offs to be the same as the torn-off methods. Avoid handing out
// a reference to the tear-off here to avoid a special case in the
// the equality test.
function = function.parent_function();
}
return CreateMethodMirror(function, Instance::null_instance());
}
return Instance::null();

View file

@ -19,6 +19,7 @@ math/random_big_test: RuntimeError # Using bigint seeds for random.
mirrors/abstract_class_test: RuntimeError # Issue 12826
mirrors/class_declarations_test/none: RuntimeError # Issue 13440
mirrors/class_mirror_location_test: RuntimeError # Issue 6490
mirrors/closurization_equivalence_test: RuntimeError # Issue 6490
mirrors/constructor_kinds_test: RuntimeError # Issue 13799
mirrors/constructor_private_name_test: CompileTimeError # Issue 13597
mirrors/enum_test: RuntimeError # Issue 6490

View file

@ -0,0 +1,27 @@
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:mirrors';
import 'package:expect/expect.dart';
topLevelMethod() {}
class C {
static staticMethod() {}
instanceMethod() {}
}
main() {
LibraryMirror thisLibrary = reflectClass(C).owner;
Expect.equals(thisLibrary.declarations[#topLevelMethod],
(reflect(topLevelMethod) as ClosureMirror).function,
"topLevel");
Expect.equals(reflectClass(C).declarations[#staticMethod],
(reflect(C.staticMethod) as ClosureMirror).function,
"static");
Expect.equals(reflectClass(C).declarations[#instanceMethod],
(reflect(new C().instanceMethod) as ClosureMirror).function,
"instance");
}