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/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 } | 526 } |
527 } | 527 } |
528 return problemReported; | 528 return problemReported; |
529 } | 529 } |
530 | 530 |
531 /** | 531 /** |
532 * Produce a hint if the given [target] could have a value of `null`, and | 532 * Produce a hint if the given [target] could have a value of `null`, and |
533 * [identifier] is not a name of a getter or a method that exists in the | 533 * [identifier] is not a name of a getter or a method that exists in the |
534 * class [Null]. | 534 * class [Null]. |
535 */ | 535 */ |
536 void _checkForCanBeNullAfterNullAware( | 536 void _checkForCanBeNullAfterNullAware(Expression target, Token operator, |
537 Expression target, Token operator, SimpleIdentifier propertyName, SimpleId
entifier methodName) { | 537 SimpleIdentifier propertyName, SimpleIdentifier methodName) { |
538 if (operator?.type == TokenType.QUESTION_PERIOD) { | 538 if (operator?.type == TokenType.QUESTION_PERIOD) { |
539 return; | 539 return; |
540 } | 540 } |
541 bool isNullTypeMember() { | 541 bool isNullTypeMember() { |
542 if (propertyName != null) { | 542 if (propertyName != null) { |
543 String name = propertyName.name; | 543 String name = propertyName.name; |
544 return _nullType.lookUpGetter(name, _currentLibrary) != null; | 544 return _nullType.lookUpGetter(name, _currentLibrary) != null; |
545 } | 545 } |
546 if (methodName != null) { | 546 if (methodName != null) { |
547 String name = methodName.name; | 547 String name = methodName.name; |
(...skipping 6773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7321 return; | 7321 return; |
7322 } | 7322 } |
7323 FunctionType expectedClosureType = mayByFunctionType as FunctionType; | 7323 FunctionType expectedClosureType = mayByFunctionType as FunctionType; |
7324 // If the expectedClosureType is not more specific than the static type, | 7324 // If the expectedClosureType is not more specific than the static type, |
7325 // return. | 7325 // return. |
7326 DartType staticClosureType = closure.element?.type; | 7326 DartType staticClosureType = closure.element?.type; |
7327 if (staticClosureType != null && | 7327 if (staticClosureType != null && |
7328 !FunctionTypeImpl.relate( | 7328 !FunctionTypeImpl.relate( |
7329 expectedClosureType, | 7329 expectedClosureType, |
7330 staticClosureType, | 7330 staticClosureType, |
7331 (DartType t, DartType s) => (t as TypeImpl).isMoreSpecificThan(s), | 7331 (DartType t, DartType s, _, __) => |
| 7332 (t as TypeImpl).isMoreSpecificThan(s), |
7332 new TypeSystemImpl().instantiateToBounds, | 7333 new TypeSystemImpl().instantiateToBounds, |
7333 returnRelation: (s, t) => true)) { | 7334 returnRelation: (s, t) => true)) { |
7334 return; | 7335 return; |
7335 } | 7336 } |
7336 // set propagated type for the closure | 7337 // set propagated type for the closure |
7337 closure.propagatedType = expectedClosureType; | 7338 closure.propagatedType = expectedClosureType; |
7338 // set inferred types for parameters | 7339 // set inferred types for parameters |
7339 NodeList<FormalParameter> parameters = closure.parameters.parameters; | 7340 NodeList<FormalParameter> parameters = closure.parameters.parameters; |
7340 List<ParameterElement> expectedParameters = expectedClosureType.parameters; | 7341 List<ParameterElement> expectedParameters = expectedClosureType.parameters; |
7341 for (int i = 0; | 7342 for (int i = 0; |
(...skipping 3819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11161 return null; | 11162 return null; |
11162 } | 11163 } |
11163 if (identical(node.staticElement, variable)) { | 11164 if (identical(node.staticElement, variable)) { |
11164 if (node.inSetterContext()) { | 11165 if (node.inSetterContext()) { |
11165 result = true; | 11166 result = true; |
11166 } | 11167 } |
11167 } | 11168 } |
11168 return null; | 11169 return null; |
11169 } | 11170 } |
11170 } | 11171 } |
OLD | NEW |