Chromium Code Reviews| Index: pkg/analyzer/lib/src/summary/link.dart |
| diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart |
| index 2972635963e6dd7fceae815f92bfb949e3001a72..d98fa63bb4d1ba09ffca8816b9ad4b077697932d 100644 |
| --- a/pkg/analyzer/lib/src/summary/link.dart |
| +++ b/pkg/analyzer/lib/src/summary/link.dart |
| @@ -3124,18 +3124,23 @@ abstract class Node<NodeType> { |
| } |
| /** |
| - * Element used for references that result from trying to access a nonstatic |
| + * Element used for references that result from trying to access a non-static |
| * member of an element that is not a container (e.g. accessing the "length" |
| * property of a constant). |
| */ |
| class NonstaticMemberElementForLink implements ReferenceableElementForLink { |
| /** |
| + * The non-static element of this link element. |
| + */ |
| + final Element element; |
| + |
| + /** |
| * If the thing from which a member was accessed is a constant, the |
| * associated [ConstNode]. Otherwise `null`. |
| */ |
| final ConstVariableNode _constNode; |
| - NonstaticMemberElementForLink(this._constNode); |
| + NonstaticMemberElementForLink(this.element, this._constNode); |
| @override |
| ConstructorElementForLink get asConstructor => null; |
| @@ -3145,6 +3150,10 @@ class NonstaticMemberElementForLink implements ReferenceableElementForLink { |
| @override |
| DartType get asStaticType { |
| + Element element = this.element; |
| + if (element is PropertyAccessorElement && element.isGetter) { |
| + return element.returnType; |
| + } |
| // TODO(paulberry): implement. |
| return DynamicTypeImpl.instance; |
| } |
| @@ -3161,7 +3170,19 @@ class NonstaticMemberElementForLink implements ReferenceableElementForLink { |
| DynamicTypeImpl.instance; |
| @override |
| - ReferenceableElementForLink getContainedName(String name) => this; |
| + ReferenceableElementForLink getContainedName(String name) { |
| + if (element != null) { |
| + DartType type = asStaticType; |
| + if (type is InterfaceType) { |
| + PropertyAccessorElement getter = |
| + type.lookUpGetter(name, element.library); |
| + if (getter != null) { |
| + return new NonstaticMemberElementForLink(getter, _constNode); |
| + } |
|
Paul Berry
2016/04/16 14:50:09
else {
return new NonStaticMemberElementForLink(
scheglov
2016/04/17 02:38:26
Done.
|
| + } |
| + } |
| + return this; |
| + } |
| } |
| /** |
| @@ -4134,9 +4155,25 @@ class VariableElementForLink |
| DynamicTypeImpl.instance; |
| ReferenceableElementForLink getContainedName(String name) { |
| - return new NonstaticMemberElementForLink(_constNode); |
| + Element element = _getContainedElement(name); |
| + return new NonstaticMemberElementForLink(element, _constNode); |
| } |
| @override |
| noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| + |
| + /** |
| + * Return the contained element with the given [name], or `null` if the lookup |
| + * fails. |
|
Paul Berry
2016/04/16 14:50:09
Comment should reflect the fact that we don't do t
scheglov
2016/04/17 02:38:26
Done.
|
| + */ |
| + Element _getContainedElement(String name) { |
| + Linker linker = compilationUnit.library._linker; |
| + if (linker.strongMode) { |
| + DartType type = asStaticType; |
| + if (type is InterfaceType) { |
| + return type.lookUpGetter(name, compilationUnit.library); |
| + } |
| + } |
| + return null; |
| + } |
| } |