Index: lib/compiler/implementation/tree/nodes.dart |
diff --git a/lib/compiler/implementation/tree/nodes.dart b/lib/compiler/implementation/tree/nodes.dart |
index 1e356539a9434db3c0ed19a13c0affec3fb8bd34..f9221992684a4cc7c0982c2c1cef82edf0825849 100644 |
--- a/lib/compiler/implementation/tree/nodes.dart |
+++ b/lib/compiler/implementation/tree/nodes.dart |
@@ -385,6 +385,25 @@ class NewExpression extends Expression { |
Token getBeginToken() => newToken; |
Token getEndToken() => send.getEndToken(); |
+ |
+ /** |
+ * Returns the type annotation of this new expression. The type annotation |
+ * is either the `send.selector` for invocations of unnamed constructors like |
+ * `new Class()`, or `send.selector.receiver` for named constructors like |
+ * `new Class.named()`. |
+ */ |
+ TypeAnnotation getTypeAnnotation() { |
+ if (send.selector.asTypeAnnotation() !== null) { |
+ return send.selector; |
+ } else if (send.selector.asSend() !== null) { |
+ Send selector = send.selector; |
+ if (selector.receiver.asTypeAnnotation() !== null) { |
+ return selector.receiver; |
+ } |
+ } else { |
+ return null; |
+ } |
+ } |
} |
class NodeList extends Node implements Iterable<Node> { |