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.resolver; | 5 library analyzer.src.generated.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/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
(...skipping 6497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6508 } | 6508 } |
6509 FunctionType expectedClosureType = mayByFunctionType as FunctionType; | 6509 FunctionType expectedClosureType = mayByFunctionType as FunctionType; |
6510 // If the expectedClosureType is not more specific than the static type, | 6510 // If the expectedClosureType is not more specific than the static type, |
6511 // return. | 6511 // return. |
6512 DartType staticClosureType = | 6512 DartType staticClosureType = |
6513 resolutionMap.elementDeclaredByFunctionExpression(closure)?.type; | 6513 resolutionMap.elementDeclaredByFunctionExpression(closure)?.type; |
6514 if (staticClosureType != null && | 6514 if (staticClosureType != null && |
6515 !FunctionTypeImpl.relate( | 6515 !FunctionTypeImpl.relate( |
6516 expectedClosureType, | 6516 expectedClosureType, |
6517 staticClosureType, | 6517 staticClosureType, |
6518 (DartType t, DartType s, _, __) => | 6518 (s, t) => true, |
6519 (t as TypeImpl).isMoreSpecificThan(s), | |
6520 new TypeSystemImpl(typeProvider).instantiateToBounds, | 6519 new TypeSystemImpl(typeProvider).instantiateToBounds, |
6521 returnRelation: (s, t) => true)) { | 6520 parameterRelation: (t, s) => |
| 6521 (t.type as TypeImpl).isMoreSpecificThan(s.type))) { |
6522 return; | 6522 return; |
6523 } | 6523 } |
6524 // set propagated type for the closure | 6524 // set propagated type for the closure |
6525 if (!strongMode) { | 6525 if (!strongMode) { |
6526 closure.propagatedType = expectedClosureType; | 6526 closure.propagatedType = expectedClosureType; |
6527 } | 6527 } |
6528 // set inferred types for parameters | 6528 // set inferred types for parameters |
6529 NodeList<FormalParameter> parameters = closure.parameters.parameters; | 6529 NodeList<FormalParameter> parameters = closure.parameters.parameters; |
6530 List<ParameterElement> expectedParameters = expectedClosureType.parameters; | 6530 List<ParameterElement> expectedParameters = expectedClosureType.parameters; |
6531 for (int i = 0; | 6531 for (int i = 0; |
(...skipping 4126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10658 return null; | 10658 return null; |
10659 } | 10659 } |
10660 if (identical(node.staticElement, variable)) { | 10660 if (identical(node.staticElement, variable)) { |
10661 if (node.inSetterContext()) { | 10661 if (node.inSetterContext()) { |
10662 result = true; | 10662 result = true; |
10663 } | 10663 } |
10664 } | 10664 } |
10665 return null; | 10665 return null; |
10666 } | 10666 } |
10667 } | 10667 } |
OLD | NEW |