Chromium Code Reviews| 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..d1ad0d84a0ea6b6f999ff13b50176db46b0a41ff 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,28 @@ |
| */ |
| library secret_tree_element; |
| -/** |
| - * The superclass of all AST nodes. |
| - */ |
| -abstract class TreeElementMixin { |
| +import '../dart2jslib.dart' show invariant, Spannable; |
| + |
| +/// The superclass of all AST nodes. |
| +/// |
| +/// This is the empty implementation which does not allow association of |
| +/// elements. |
| +abstract class TreeElementMixin implements Spannable { |
|
floitsch
2014/07/25 12:30:08
Let's go for an interface and two implementations:
Johnni Winther
2014/08/04 06:59:09
Done.
|
| // 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 nodes classes that are actually associated with |
| +/// elements. |
| +abstract class TreeElementMixinImpl implements TreeElementMixin { |
| Object _element; |
| } |
| @@ -33,9 +49,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 |