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 6783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6794 } | 6794 } |
6795 FunctionType expectedClosureType = mayByFunctionType as FunctionType; | 6795 FunctionType expectedClosureType = mayByFunctionType as FunctionType; |
6796 // If the expectedClosureType is not more specific than the static type, | 6796 // If the expectedClosureType is not more specific than the static type, |
6797 // return. | 6797 // return. |
6798 DartType staticClosureType = | 6798 DartType staticClosureType = |
6799 resolutionMap.elementDeclaredByFunctionExpression(closure)?.type; | 6799 resolutionMap.elementDeclaredByFunctionExpression(closure)?.type; |
6800 if (staticClosureType != null && | 6800 if (staticClosureType != null && |
6801 !FunctionTypeImpl.relate( | 6801 !FunctionTypeImpl.relate( |
6802 expectedClosureType, | 6802 expectedClosureType, |
6803 staticClosureType, | 6803 staticClosureType, |
6804 (DartType t, DartType s, _, __) => | 6804 (s, t) => true, |
6805 (t as TypeImpl).isMoreSpecificThan(s), | |
6806 new TypeSystemImpl(typeProvider).instantiateToBounds, | 6805 new TypeSystemImpl(typeProvider).instantiateToBounds, |
6807 returnRelation: (s, t) => true)) { | 6806 parameterRelation: (t, s) => |
| 6807 (t.type as TypeImpl).isMoreSpecificThan(s.type))) { |
6808 return; | 6808 return; |
6809 } | 6809 } |
6810 // set propagated type for the closure | 6810 // set propagated type for the closure |
6811 if (!strongMode) { | 6811 if (!strongMode) { |
6812 closure.propagatedType = expectedClosureType; | 6812 closure.propagatedType = expectedClosureType; |
6813 } | 6813 } |
6814 // set inferred types for parameters | 6814 // set inferred types for parameters |
6815 NodeList<FormalParameter> parameters = closure.parameters.parameters; | 6815 NodeList<FormalParameter> parameters = closure.parameters.parameters; |
6816 List<ParameterElement> expectedParameters = expectedClosureType.parameters; | 6816 List<ParameterElement> expectedParameters = expectedClosureType.parameters; |
6817 for (int i = 0; | 6817 for (int i = 0; |
(...skipping 4118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10936 return null; | 10936 return null; |
10937 } | 10937 } |
10938 if (identical(node.staticElement, variable)) { | 10938 if (identical(node.staticElement, variable)) { |
10939 if (node.inSetterContext()) { | 10939 if (node.inSetterContext()) { |
10940 result = true; | 10940 result = true; |
10941 } | 10941 } |
10942 } | 10942 } |
10943 return null; | 10943 return null; |
10944 } | 10944 } |
10945 } | 10945 } |
OLD | NEW |