mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 06:31:30 +00:00
Force resolution on metadata of static members
R=kasperl@google.com Review URL: https://codereview.chromium.org//26800008 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@28847 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
24fded56bc
commit
09116b857b
|
@ -736,6 +736,21 @@ class ResolverTask extends CompilerTask {
|
|||
for (MetadataAnnotation metadata in element.metadata) {
|
||||
metadata.ensureResolved(compiler);
|
||||
}
|
||||
|
||||
// Force resolution of metadata on non-instance members since they may be
|
||||
// inspected by the backend while emitting. Metadata on instance members is
|
||||
// handled as a result of processing instantiated class members in the
|
||||
// enqueuer.
|
||||
// TODO(ahe): Avoid this eager resolution.
|
||||
element.forEachMember((_, Element member) {
|
||||
if (!member.isInstanceMember()) {
|
||||
compiler.withCurrentElement(member, () {
|
||||
for (MetadataAnnotation metadata in member.metadata) {
|
||||
metadata.ensureResolved(compiler);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void checkClass(ClassElement element) {
|
||||
|
|
32
tests/lib/mirrors/static_metatarget_test.dart
Normal file
32
tests/lib/mirrors/static_metatarget_test.dart
Normal file
|
@ -0,0 +1,32 @@
|
|||
// Copyright (c) 2013, 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.
|
||||
|
||||
// Regression test for the combined use of metatargets and static fields with
|
||||
// annotations.
|
||||
|
||||
@MirrorsUsed(metaTargets:const [Reflectable])
|
||||
import 'dart:mirrors';
|
||||
|
||||
class A {
|
||||
@reflectable var reflectableField = 0; /// 01: ok
|
||||
|
||||
@UsedOnlyAsMetadata() var unreflectableField = 1; /// 02: ok
|
||||
|
||||
@reflectable static var reflectableStaticField = 2; /// 03: ok
|
||||
|
||||
@UsedOnlyAsMetadata() static var unreflectableStaticField = 3;
|
||||
}
|
||||
|
||||
class Reflectable {
|
||||
const Reflectable();
|
||||
}
|
||||
const Reflectable reflectable = const Reflectable();
|
||||
|
||||
class UsedOnlyAsMetadata {
|
||||
const UsedOnlyAsMetadata();
|
||||
}
|
||||
|
||||
void main() {
|
||||
print(new A());
|
||||
}
|
Loading…
Reference in a new issue