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

Unified Diff: pkg/checked_mirrors/example/symbol.dart

Issue 111643015: Preliminary checked mirrors (not ready for review yet) (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « pkg/checked_mirrors/example/meta_target.dart ('k') | pkg/checked_mirrors/example/target.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/checked_mirrors/example/symbol.dart
diff --git a/pkg/checked_mirrors/example/symbol.dart b/pkg/checked_mirrors/example/symbol.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5ccb1aa2fb4a65edf5a95bfb633855dd3078a2ce
--- /dev/null
+++ b/pkg/checked_mirrors/example/symbol.dart
@@ -0,0 +1,35 @@
+// 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.
+
+/// Example illustrating how to use checked_mirrors, and how it works when you
+/// declare a symbol with [MirrorsUsed].
+library checked_mirrors.example.symbol;
+
+import 'package:checked_mirrors/checked_mirrors.dart';
+import 'package:checked_mirrors/control.dart' as control;
+import 'package:logging/logging.dart';
+
+// Typically this annotation goes in an import to 'dart:mirrors', we would like
+// to put it in the import of checked_mirrors, but we moved it here until
+// dartbug.com/10360 is fixed.
+@MirrorsUsed(symbols: 'x')
+const checked_mirrors_workaround_for_issue_10360 = 0;
+
+var a = new A();
+
+main() {
+ // This loads up the rules declared with @MirrorsUsed.
+ control.initialize(log: true);
+
+ // Print the warnings to the console.
+ Logger.root.onRecord.listen((r) => print(r));
+
+ // These are OK:
+ MirrorSystem.getName(#x);
+ MirrorSystem.getSymbol('x');
+
+ // These will issue a warning:
+ MirrorSystem.getName(#y);
+ MirrorSystem.getSymbol('y');
+}
« no previous file with comments | « pkg/checked_mirrors/example/meta_target.dart ('k') | pkg/checked_mirrors/example/target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698