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

Unified Diff: pkg/analyzer/lib/src/generated/element_resolver.dart

Issue 1519583002: Issue 25218. The reference type of 'A' in 'A..foo' is 'Type'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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 | « no previous file | pkg/analyzer/test/generated/static_type_warning_code_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/element_resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/element_resolver.dart b/pkg/analyzer/lib/src/generated/element_resolver.dart
index b7342b30f7c66ea639df4e55953ea67e8a3649d7..70defdf999475ca316dc0ea42cdd9504d300e810 100644
--- a/pkg/analyzer/lib/src/generated/element_resolver.dart
+++ b/pkg/analyzer/lib/src/generated/element_resolver.dart
@@ -102,7 +102,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
/**
* The type representing the type 'type'.
*/
- DartType _typeType;
+ InterfaceType _typeType;
/**
* A utility class for the resolver to answer the question of "what are my
@@ -594,8 +594,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
Element staticElement;
Element propagatedElement;
- DartType staticType = null;
- DartType propagatedType = null;
if (target == null) {
staticElement = _resolveInvokedElement(methodName);
propagatedElement = null;
@@ -611,8 +609,6 @@ class ElementResolver extends SimpleAstVisitor<Object> {
methodName.staticElement = importedLibrary.loadLibraryFunction;
return null;
} else {
- staticType = _getStaticType(target);
- propagatedType = _getPropagatedType(target);
//
// If this method invocation is of the form 'C.m' where 'C' is a class,
// then we don't call resolveInvokedElement(...) which walks up the class
@@ -622,8 +618,13 @@ class ElementResolver extends SimpleAstVisitor<Object> {
bool isConditional = node.operator.type == sc.TokenType.QUESTION_PERIOD;
ClassElementImpl typeReference = getTypeReference(target);
if (typeReference != null) {
+ if (node.isCascaded) {
+ typeReference = _typeType.element;
+ }
staticElement = _resolveElement(typeReference, methodName);
} else {
+ DartType staticType = _getStaticType(target);
+ DartType propagatedType = _getPropagatedType(target);
staticElement = _resolveInvokedElementWithTarget(
target, staticType, methodName, isConditional);
// If we have propagated type information use it (since it should
@@ -773,17 +774,19 @@ class ElementResolver extends SimpleAstVisitor<Object> {
// resolveArgumentsToParameters(node.getArgumentList(), invokedFunction);
return null;
}
- ClassElementImpl typeReference = getTypeReference(target);
- if (typeReference != null) {
- ConstructorElement constructor =
- typeReference.getNamedConstructor(methodName.name);
- if (constructor != null) {
- _recordUndefinedNode(
- typeReference,
- StaticTypeWarningCode.UNDEFINED_METHOD_WITH_CONSTRUCTOR,
- methodName,
- [methodName.name, typeReference.name]);
- return null;
+ if (!node.isCascaded) {
+ ClassElementImpl typeReference = getTypeReference(target);
+ if (typeReference != null) {
+ ConstructorElement constructor =
+ typeReference.getNamedConstructor(methodName.name);
+ if (constructor != null) {
+ _recordUndefinedNode(
+ typeReference,
+ StaticTypeWarningCode.UNDEFINED_METHOD_WITH_CONSTRUCTOR,
+ methodName,
+ [methodName.name, typeReference.name]);
+ return null;
+ }
}
}
targetTypeName = targetType == null ? null : targetType.displayName;
@@ -923,7 +926,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
// Otherwise, the prefix is really an expression that happens to be a simple
// identifier and this is really equivalent to a property access node.
//
- _resolvePropertyAccess(prefix, identifier);
+ _resolvePropertyAccess(prefix, identifier, false);
return null;
}
@@ -979,7 +982,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
return null;
}
SimpleIdentifier propertyName = node.propertyName;
- _resolvePropertyAccess(target, propertyName);
+ _resolvePropertyAccess(target, propertyName, node.isCascaded);
return null;
}
@@ -2251,7 +2254,7 @@ class ElementResolver extends SimpleAstVisitor<Object> {
}
void _resolvePropertyAccess(
- Expression target, SimpleIdentifier propertyName) {
+ Expression target, SimpleIdentifier propertyName, bool isCascaded) {
DartType staticType = _getStaticType(target);
DartType propagatedType = _getPropagatedType(target);
Element staticElement = null;
@@ -2264,6 +2267,9 @@ class ElementResolver extends SimpleAstVisitor<Object> {
//
ClassElementImpl typeReference = getTypeReference(target);
if (typeReference != null) {
+ if (isCascaded) {
+ typeReference = _typeType.element;
+ }
// TODO(brianwilkerson) Why are we setting the propagated element here?
// It looks wrong.
staticElement =
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/static_type_warning_code_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698