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

Side by Side Diff: pkg/analyzer/lib/src/generated/element_resolver.dart

Issue 2252183002: Fix calling object methods and properties on function types (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix calling object methods and properties on function types Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library analyzer.src.generated.element_resolver; 5 library analyzer.src.generated.element_resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
2221 if (element == null) { 2221 if (element == null) {
2222 // 2222 //
2223 // If there's no method, then it's possible that 'm' is a getter that 2223 // If there's no method, then it's possible that 'm' is a getter that
2224 // returns a function. 2224 // returns a function.
2225 // 2225 //
2226 // TODO (collinsn): need to add union type support here too, in the 2226 // TODO (collinsn): need to add union type support here too, in the
2227 // style of [lookUpMethod]. 2227 // style of [lookUpMethod].
2228 element = _lookUpGetter(target, targetType, methodName.name); 2228 element = _lookUpGetter(target, targetType, methodName.name);
2229 } 2229 }
2230 return element; 2230 return element;
2231 } else if (targetType is FunctionType &&
2232 _resolver.typeProvider.isObjectMethod(methodName)) {
2233 return _resolver.typeProvider.objectType.element
2234 .getMethod(methodName.name);
2231 } else if (target is SimpleIdentifier) { 2235 } else if (target is SimpleIdentifier) {
2232 Element targetElement = target.staticElement; 2236 Element targetElement = target.staticElement;
2233 if (targetType is FunctionType && 2237 if (targetType is FunctionType &&
2234 methodName.name == FunctionElement.CALL_METHOD_NAME) { 2238 methodName.name == FunctionElement.CALL_METHOD_NAME) {
2235 return targetElement; 2239 return targetElement;
2236 } 2240 }
2237 if (targetElement is PrefixElement) { 2241 if (targetElement is PrefixElement) {
2238 if (isConditional) { 2242 if (isConditional) {
2239 _resolver.errorReporter.reportErrorForNode( 2243 _resolver.errorReporter.reportErrorForNode(
2240 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT, 2244 CompileTimeErrorCode.PREFIX_IDENTIFIER_NOT_FOLLOWED_BY_DOT,
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
2630 2634
2631 @override 2635 @override
2632 Element get staticElement => null; 2636 Element get staticElement => null;
2633 2637
2634 @override 2638 @override
2635 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null; 2639 dynamic/*=E*/ accept/*<E>*/(AstVisitor/*<E>*/ visitor) => null;
2636 2640
2637 @override 2641 @override
2638 void visitChildren(AstVisitor visitor) {} 2642 void visitChildren(AstVisitor visitor) {}
2639 } 2643 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/resolver.dart » ('j') | pkg/analyzer/lib/src/generated/resolver.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698