| OLD | NEW |
| 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/visitor.dart'; | 10 import 'package:analyzer/dart/ast/visitor.dart'; |
| (...skipping 1501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1512 */ | 1512 */ |
| 1513 DartType _instantiateGenericMethod( | 1513 DartType _instantiateGenericMethod( |
| 1514 DartType invokeType, TypeArgumentList typeArguments, AstNode node) { | 1514 DartType invokeType, TypeArgumentList typeArguments, AstNode node) { |
| 1515 // TODO(jmesserly): support generic "call" methods on InterfaceType. | 1515 // TODO(jmesserly): support generic "call" methods on InterfaceType. |
| 1516 if (invokeType is FunctionType) { | 1516 if (invokeType is FunctionType) { |
| 1517 FunctionType type = invokeType; | 1517 FunctionType type = invokeType; |
| 1518 List<TypeParameterElement> parameters = type.typeFormals; | 1518 List<TypeParameterElement> parameters = type.typeFormals; |
| 1519 | 1519 |
| 1520 NodeList<TypeName> arguments = typeArguments?.arguments; | 1520 NodeList<TypeName> arguments = typeArguments?.arguments; |
| 1521 if (arguments != null && arguments.length != parameters.length) { | 1521 if (arguments != null && arguments.length != parameters.length) { |
| 1522 // Wrong number of type arguments. Ignore them | |
| 1523 arguments = null; | |
| 1524 _resolver.reportErrorForNode( | 1522 _resolver.reportErrorForNode( |
| 1525 StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS, | 1523 StaticTypeWarningCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS, |
| 1526 node, | 1524 node, |
| 1527 [type, parameters.length, arguments?.length ?? 0]); | 1525 [type, parameters.length, arguments?.length ?? 0]); |
| 1526 |
| 1527 // Wrong number of type arguments. Ignore them. |
| 1528 arguments = null; |
| 1528 } | 1529 } |
| 1529 if (parameters.isNotEmpty) { | 1530 if (parameters.isNotEmpty) { |
| 1530 if (arguments == null) { | 1531 if (arguments == null) { |
| 1531 invokeType = _resolver.typeSystem.instantiateToBounds(type); | 1532 invokeType = _resolver.typeSystem.instantiateToBounds(type); |
| 1532 } else { | 1533 } else { |
| 1533 invokeType = type.instantiate(arguments.map((n) => n.type).toList()); | 1534 invokeType = type.instantiate(arguments.map((n) => n.type).toList()); |
| 1534 } | 1535 } |
| 1535 } | 1536 } |
| 1536 } | 1537 } |
| 1537 return invokeType; | 1538 return invokeType; |
| (...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2593 | 2594 |
| 2594 @override | 2595 @override |
| 2595 Element get staticElement => null; | 2596 Element get staticElement => null; |
| 2596 | 2597 |
| 2597 @override | 2598 @override |
| 2598 accept(AstVisitor visitor) => null; | 2599 accept(AstVisitor visitor) => null; |
| 2599 | 2600 |
| 2600 @override | 2601 @override |
| 2601 void visitChildren(AstVisitor visitor) {} | 2602 void visitChildren(AstVisitor visitor) {} |
| 2602 } | 2603 } |
| OLD | NEW |