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 library analyzer.src.task.strong_mode; | 5 library analyzer.src.task.strong_mode; |
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 | 66 |
67 /** | 67 /** |
68 * The inheritance manager used to find overridden method. | 68 * The inheritance manager used to find overridden method. |
69 */ | 69 */ |
70 final InheritanceManager inheritanceManager; | 70 final InheritanceManager inheritanceManager; |
71 | 71 |
72 /** | 72 /** |
73 * The classes that have been visited while attempting to infer the types of | 73 * The classes that have been visited while attempting to infer the types of |
74 * instance members of some base class. | 74 * instance members of some base class. |
75 */ | 75 */ |
76 HashSet<ClassElementImpl> elementsBeingInferred = | 76 HashSet<AbstractClassElementImpl> elementsBeingInferred = |
Brian Wilkerson
2016/06/01 18:41:40
I don't think we actually infer enum members, so i
| |
77 new HashSet<ClassElementImpl>(); | 77 new HashSet<AbstractClassElementImpl>(); |
78 | 78 |
79 /** | 79 /** |
80 * Initialize a newly create inferrer. | 80 * Initialize a newly create inferrer. |
81 */ | 81 */ |
82 InstanceMemberInferrer(this.typeProvider, this.inheritanceManager, | 82 InstanceMemberInferrer(this.typeProvider, this.inheritanceManager, |
83 {TypeSystem typeSystem}) | 83 {TypeSystem typeSystem}) |
84 : typeSystem = (typeSystem != null) ? typeSystem : new TypeSystemImpl(); | 84 : typeSystem = (typeSystem != null) ? typeSystem : new TypeSystemImpl(); |
85 | 85 |
86 /** | 86 /** |
87 * Infer type information for all of the instance members in the given | 87 * Infer type information for all of the instance members in the given |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 return matchingParameter == null | 195 return matchingParameter == null |
196 ? typeProvider.dynamicType | 196 ? typeProvider.dynamicType |
197 : matchingParameter.type; | 197 : matchingParameter.type; |
198 } | 198 } |
199 | 199 |
200 /** | 200 /** |
201 * Infer type information for all of the instance members in the given | 201 * Infer type information for all of the instance members in the given |
202 * [classElement]. | 202 * [classElement]. |
203 */ | 203 */ |
204 void _inferClass(ClassElement classElement) { | 204 void _inferClass(ClassElement classElement) { |
205 if (classElement is ClassElementImpl) { | 205 if (classElement is AbstractClassElementImpl) { |
206 if (classElement.hasBeenInferred) { | 206 if (classElement.hasBeenInferred) { |
207 return; | 207 return; |
208 } | 208 } |
209 if (!elementsBeingInferred.add(classElement)) { | 209 if (!elementsBeingInferred.add(classElement)) { |
210 // We have found a circularity in the class hierarchy. For now we just | 210 // We have found a circularity in the class hierarchy. For now we just |
211 // stop trying to infer any type information for any classes that | 211 // stop trying to infer any type information for any classes that |
212 // inherit from any class in the cycle. We could potentially limit the | 212 // inherit from any class in the cycle. We could potentially limit the |
213 // algorithm to only not inferring types in the classes in the cycle, | 213 // algorithm to only not inferring types in the classes in the cycle, |
214 // but it isn't clear that the results would be significantly better. | 214 // but it isn't clear that the results would be significantly better. |
215 throw new _CycleException(); | 215 throw new _CycleException(); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 results.add(element); | 471 results.add(element); |
472 } | 472 } |
473 } | 473 } |
474 } | 474 } |
475 } | 475 } |
476 | 476 |
477 /** | 477 /** |
478 * A class of exception that is not used anywhere else. | 478 * A class of exception that is not used anywhere else. |
479 */ | 479 */ |
480 class _CycleException implements Exception {} | 480 class _CycleException implements Exception {} |
OLD | NEW |