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

Unified Diff: pkg/compiler/lib/src/tree/nodes.dart

Issue 2722923002: Move TreeElementMixin to avoid out-of-library private overrides (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « pkg/compiler/lib/src/resolution/secret_tree_element.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/tree/nodes.dart
diff --git a/pkg/compiler/lib/src/tree/nodes.dart b/pkg/compiler/lib/src/tree/nodes.dart
index 744bdfe62a7ba6005864941db4dbab9f54016db4..216b51cb26890ce297327b1059aee58f9f48f8a1 100644
--- a/pkg/compiler/lib/src/tree/nodes.dart
+++ b/pkg/compiler/lib/src/tree/nodes.dart
@@ -6,8 +6,6 @@ import 'dart:collection' show IterableMixin;
import '../common.dart';
import '../elements/elements.dart' show MetadataAnnotation;
-import '../resolution/secret_tree_element.dart'
- show NullTreeElementMixin, StoredTreeElementMixin;
import 'package:front_end/src/fasta/scanner/precedence.dart' as Precedence
show FUNCTION_INFO;
import 'package:front_end/src/fasta/scanner.dart' show BeginGroupToken, Token;
@@ -3224,3 +3222,62 @@ class ErrorNode extends Node
get formals => null;
get typedefKeyword => null;
}
+
+/**
+ * Encapsulates the field [TreeElementMixin._element].
+ *
+ * This library is an implementation detail of dart2js, and should not
+ * be imported except by resolution and tree node libraries, or for
+ * testing.
+ *
+ * We have taken great care to ensure AST nodes can be cached between
+ * compiler instances. Part of this requires that we always access
+ * resolution results through TreeElements.
+ *
+ * So please, do not add additional elements to this library, and do
+ * not import it.
+ */
+/// 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;
+}
+
+/**
+ * Do not call this method directly. Instead, use an instance of
+ * TreeElements.
+ *
+ * Using [Object] as return type to thwart code completion.
+ */
+Object getTreeElement(TreeElementMixin node) => node._element;
+
+/**
+ * Do not call this method directly. Instead, use an instance of
+ * TreeElements.
+ */
+void setTreeElement(TreeElementMixin node, Object value) {
+ node._element = value;
+}
« no previous file with comments | « pkg/compiler/lib/src/resolution/secret_tree_element.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698