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

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

Issue 1504483002: Allow explicitly passing generic function type args (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: format 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 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 engine.resolver.element_resolver; 5 library engine.resolver.element_resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'ast.dart'; 9 import 'ast.dart';
10 import 'element.dart'; 10 import 'element.dart';
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 target, staticType, methodName, isConditional); 628 target, staticType, methodName, isConditional);
629 // If we have propagated type information use it (since it should 629 // If we have propagated type information use it (since it should
630 // not be redundant with the staticType). Otherwise, don't produce 630 // not be redundant with the staticType). Otherwise, don't produce
631 // a propagatedElement which duplicates the staticElement. 631 // a propagatedElement which duplicates the staticElement.
632 if (propagatedType is InterfaceType) { 632 if (propagatedType is InterfaceType) {
633 propagatedElement = _resolveInvokedElementWithTarget( 633 propagatedElement = _resolveInvokedElementWithTarget(
634 target, propagatedType, methodName, isConditional); 634 target, propagatedType, methodName, isConditional);
635 } 635 }
636 } 636 }
637 } 637 }
638 //
639 // Check for a generic method & apply type arguments if any were passed.
640 //
641 if (staticElement is MethodElement || staticElement is FunctionElement) {
642 FunctionType type = (staticElement as ExecutableElement).type;
643 List<TypeParameterElement> parameters = type.boundTypeParameters;
644
645 NodeList<TypeName> arguments = node.typeArguments?.arguments;
646 if (arguments != null && arguments.length != parameters.length) {
647 // Wrong number of type arguments. Ignore them
648 arguments = null;
649 _resolver.reportErrorForNode(
650 StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS,
651 methodName,
652 [type, parameters.length, arguments.length]);
653 }
654 if (parameters.isNotEmpty) {
655 List<DartType> typeArgs;
656 if (arguments == null) {
657 typeArgs = new List<DartType>.filled(
658 parameters.length, DynamicTypeImpl.instance);
659 } else {
660 typeArgs = new List<DartType>.from(arguments.map((n) => n.type));
661 }
662 type = type.instantiate(typeArgs);
663
664 if (staticElement is MethodMember) {
665 MethodMember member = staticElement;
666 staticElement =
667 new MethodMember(member.baseElement, member.definingType, type);
668 } else if (staticElement is MethodElement) {
669 ClassElement clazz = staticElement.enclosingElement;
670 staticElement = new MethodMember(staticElement, clazz.type, type);
671 } else {
672 staticElement =
673 new FunctionMember(staticElement as FunctionElement, type);
674 }
675 }
676 }
677
638 staticElement = _convertSetterToGetter(staticElement); 678 staticElement = _convertSetterToGetter(staticElement);
639 propagatedElement = _convertSetterToGetter(propagatedElement); 679 propagatedElement = _convertSetterToGetter(propagatedElement);
640 // 680 //
641 // Record the results. 681 // Record the results.
642 // 682 //
643 methodName.staticElement = staticElement; 683 methodName.staticElement = staticElement;
644 methodName.propagatedElement = propagatedElement; 684 methodName.propagatedElement = propagatedElement;
645 ArgumentList argumentList = node.argumentList; 685 ArgumentList argumentList = node.argumentList;
646 if (staticElement != null) { 686 if (staticElement != null) {
647 List<ParameterElement> parameters = 687 List<ParameterElement> parameters =
(...skipping 1947 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 2635
2596 @override 2636 @override
2597 Element get staticElement => null; 2637 Element get staticElement => null;
2598 2638
2599 @override 2639 @override
2600 accept(AstVisitor visitor) => null; 2640 accept(AstVisitor visitor) => null;
2601 2641
2602 @override 2642 @override
2603 void visitChildren(AstVisitor visitor) {} 2643 void visitChildren(AstVisitor visitor) {}
2604 } 2644 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698