OLD | NEW |
---|---|
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be | 5 // TODO(jmesserly): this was ported from package:dev_compiler, and needs to be |
6 // refactored to fit into analyzer. | 6 // refactored to fit into analyzer. |
7 library analyzer.src.task.strong.checker; | 7 library analyzer.src.task.strong.checker; |
8 | 8 |
9 import 'package:analyzer/analyzer.dart'; | 9 import 'package:analyzer/analyzer.dart'; |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1022 | 1022 |
1023 /// Returns `true` if the target expression is dynamic. | 1023 /// Returns `true` if the target expression is dynamic. |
1024 bool _isDynamicTarget(Expression node) { | 1024 bool _isDynamicTarget(Expression node) { |
1025 if (node == null) return false; | 1025 if (node == null) return false; |
1026 | 1026 |
1027 if (_isLibraryPrefix(node)) return false; | 1027 if (_isLibraryPrefix(node)) return false; |
1028 | 1028 |
1029 // Null type happens when we have unknown identifiers, like a dart: import | 1029 // Null type happens when we have unknown identifiers, like a dart: import |
1030 // that doesn't resolve. | 1030 // that doesn't resolve. |
1031 var type = node.staticType; | 1031 var type = node.staticType; |
1032 return type == null || type.isDynamic; | 1032 var element = type?.element; |
1033 return type == null || | |
1034 type.isDynamic || | |
1035 (element is ClassElement && element.isOrInheritsProxy); | |
vsm
2016/08/09 15:20:51
Is this too conservative if there is an actual met
Jennifer Messerly
2016/08/09 15:31:11
This path actually only handles operators. Method/
| |
1033 } | 1036 } |
1034 | 1037 |
1035 bool _isLibraryPrefix(Expression node) => | 1038 bool _isLibraryPrefix(Expression node) => |
1036 node is SimpleIdentifier && node.staticElement is PrefixElement; | 1039 node is SimpleIdentifier && node.staticElement is PrefixElement; |
1037 | 1040 |
1038 bool _isObjectGetter(Expression target, SimpleIdentifier id) { | 1041 bool _isObjectGetter(Expression target, SimpleIdentifier id) { |
1039 PropertyAccessorElement element = | 1042 PropertyAccessorElement element = |
1040 typeProvider.objectType.element.getGetter(id.name); | 1043 typeProvider.objectType.element.getGetter(id.name); |
1041 return (element != null && !element.isStatic); | 1044 return (element != null && !element.isStatic); |
1042 } | 1045 } |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1514 var visited = new Set<InterfaceType>(); | 1517 var visited = new Set<InterfaceType>(); |
1515 do { | 1518 do { |
1516 visited.add(current); | 1519 visited.add(current); |
1517 current.mixins.reversed.forEach( | 1520 current.mixins.reversed.forEach( |
1518 (m) => _checkIndividualOverridesFromClass(node, m, seen, true)); | 1521 (m) => _checkIndividualOverridesFromClass(node, m, seen, true)); |
1519 _checkIndividualOverridesFromClass(node, current.superclass, seen, true); | 1522 _checkIndividualOverridesFromClass(node, current.superclass, seen, true); |
1520 current = current.superclass; | 1523 current = current.superclass; |
1521 } while (!current.isObject && !visited.contains(current)); | 1524 } while (!current.isObject && !visited.contains(current)); |
1522 } | 1525 } |
1523 } | 1526 } |
OLD | NEW |