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

Unified Diff: sdk/lib/_internal/compiler/implementation/resolution/secret_tree_element.dart

Issue 422483002: Mix in [TreeElementMixin] only on nodes that need it. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 4 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
Index: sdk/lib/_internal/compiler/implementation/resolution/secret_tree_element.dart
diff --git a/sdk/lib/_internal/compiler/implementation/resolution/secret_tree_element.dart b/sdk/lib/_internal/compiler/implementation/resolution/secret_tree_element.dart
index 665938e9472e0da988a5123613d9cd1d88312c91..16216df5c1da550216ab1951769db62f1c040166 100644
--- a/sdk/lib/_internal/compiler/implementation/resolution/secret_tree_element.dart
+++ b/sdk/lib/_internal/compiler/implementation/resolution/secret_tree_element.dart
@@ -18,12 +18,35 @@
*/
library secret_tree_element;
-/**
- * The superclass of all AST nodes.
- */
+import '../dart2jslib.dart' show invariant, Spannable;
+
+/// Interface for associating
abstract class TreeElementMixin {
+ Object get _element;
+ void set _element(Object value);
+}
+
+/// Null implementation of [TreeElementMixin] which does not allow association
+/// of elements.
+///
+/// This class is the superclass of all AST nodes.
+abstract class NullTreeElementMixin implements TreeElementMixin, Spannable {
+
// Deliberately using [Object] here to thwart code completion.
// You're not really supposed to access this field anyways.
+ Object get _element => null;
+ set _element(_) {
+ assert(invariant(this, false,
+ message: "Elements cannot be associated with ${runtimeType}."));
+ }
+}
+
+/// Actual implementation of [TreeElementMixin] which stores the associated
+/// element in the private field [_element].
+///
+/// This class is mixed into the node classes that are actually associated with
+/// elements.
+abstract class StoredTreeElementMixin implements TreeElementMixin {
Object _element;
}
@@ -33,9 +56,7 @@ abstract class TreeElementMixin {
*
* Using [Object] as return type to thwart code completion.
*/
-Object getTreeElement(TreeElementMixin node) {
- return node._element;
-}
+Object getTreeElement(TreeElementMixin node) => node._element;
/**
* Do not call this method directly. Instead, use an instance of

Powered by Google App Engine
This is Rietveld 408576698