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

Side by Side Diff: pkg/compiler/lib/src/resolution/secret_tree_element.dart

Issue 2722043002: Make TreeElementMixin._elements public to avoid out-of-library private overrides (Closed)
Patch Set: Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Encapsulates the field [TreeElementMixin._element]. 6 * Encapsulates the field [TreeElementMixin._element].
7 * 7 *
8 * This library is an implementation detail of dart2js, and should not 8 * This library is an implementation detail of dart2js, and should not
9 * be imported except by resolution and tree node libraries, or for 9 * be imported except by resolution and tree node libraries, or for
10 * testing. 10 * testing.
11 * 11 *
12 * We have taken great care to ensure AST nodes can be cached between 12 * We have taken great care to ensure AST nodes can be cached between
13 * compiler instances. Part of this requires that we always access 13 * compiler instances. Part of this requires that we always access
14 * resolution results through TreeElements. 14 * resolution results through TreeElements.
15 * 15 *
16 * So please, do not add additional elements to this library, and do 16 * So please, do not add additional elements to this library, and do
17 * not import it. 17 * not import it.
18 */ 18 */
19 library dart2js.resolution.secret_tree_element; 19 library dart2js.resolution.secret_tree_element;
20 20
21 import '../common.dart'; 21 import '../common.dart';
22 22
23 /// Interface for associating 23 /// Interface for associating
24 abstract class TreeElementMixin { 24 abstract class TreeElementMixin {
25 Object get _element; 25 // We would prefer [resolutionSecretTreeElement] to be a private property, but
26 void set _element(Object value); 26 // that is a problem for DDC's separate compilation model where private
27 // overrides are disallowed.
28 // [See](https://github.com/dart-lang/sdk/issues/28809) for more context.
29 Object get resolutionSecretTreeElement;
30 void set resolutionSecretTreeElement(Object value);
27 } 31 }
28 32
29 /// Null implementation of [TreeElementMixin] which does not allow association 33 /// Null implementation of [TreeElementMixin] which does not allow association
30 /// of elements. 34 /// of elements.
31 /// 35 ///
32 /// This class is the superclass of all AST nodes. 36 /// This class is the superclass of all AST nodes.
33 abstract class NullTreeElementMixin implements TreeElementMixin, Spannable { 37 abstract class NullTreeElementMixin implements TreeElementMixin, Spannable {
34 // Deliberately using [Object] here to thwart code completion. 38 // Deliberately using [Object] here to thwart code completion.
35 // You're not really supposed to access this field anyways. 39 // You're not really supposed to access this field anyways.
36 Object get _element => null; 40 Object get resolutionSecretTreeElement => null;
37 set _element(_) { 41 set resolutionSecretTreeElement(_) {
38 assert(invariant(this, false, 42 assert(invariant(this, false,
39 message: "Elements cannot be associated with ${runtimeType}.")); 43 message: "Elements cannot be associated with ${runtimeType}."));
40 } 44 }
41 } 45 }
42 46
43 /// Actual implementation of [TreeElementMixin] which stores the associated 47 /// Actual implementation of [TreeElementMixin] which stores the associated
44 /// element in the private field [_element]. 48 /// element in the private field [resolutionSecretTreeElement].
45 /// 49 ///
46 /// This class is mixed into the node classes that are actually associated with 50 /// This class is mixed into the node classes that are actually associated with
47 /// elements. 51 /// elements.
48 abstract class StoredTreeElementMixin implements TreeElementMixin { 52 abstract class StoredTreeElementMixin implements TreeElementMixin {
49 Object _element; 53 Object resolutionSecretTreeElement;
50 } 54 }
51 55
52 /** 56 /**
53 * Do not call this method directly. Instead, use an instance of 57 * Do not call this method directly. Instead, use an instance of
54 * TreeElements. 58 * TreeElements.
55 * 59 *
56 * Using [Object] as return type to thwart code completion. 60 * Using [Object] as return type to thwart code completion.
57 */ 61 */
58 Object getTreeElement(TreeElementMixin node) => node._element; 62 Object getTreeElement(TreeElementMixin node) =>
63 node.resolutionSecretTreeElement;
59 64
60 /** 65 /**
61 * Do not call this method directly. Instead, use an instance of 66 * Do not call this method directly. Instead, use an instance of
62 * TreeElements. 67 * TreeElements.
63 */ 68 */
64 void setTreeElement(TreeElementMixin node, Object value) { 69 void setTreeElement(TreeElementMixin node, Object value) {
65 node._element = value; 70 node.resolutionSecretTreeElement = value;
66 } 71 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698