mirror of
https://github.com/dart-lang/sdk
synced 2024-09-19 20:41:45 +00:00
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:
parent
3d8bd5fcb6
commit
60fd23bffc
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
27
tests/lib/mirrors/closurization_equivalence_test.dart
Normal file
27
tests/lib/mirrors/closurization_equivalence_test.dart
Normal 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");
|
||||
}
|
Loading…
Reference in a new issue