| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 final TypeProvider typeProvider; | 68 final TypeProvider typeProvider; |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * The type system used to compute the least upper bound of types. | 71 * The type system used to compute the least upper bound of types. |
| 72 */ | 72 */ |
| 73 TypeSystem typeSystem; | 73 TypeSystem typeSystem; |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * The inheritance manager used to find overridden method. | 76 * The inheritance manager used to find overridden method. |
| 77 */ | 77 */ |
| 78 InheritanceManager inheritanceManager; | 78 final InheritanceManager inheritanceManager; |
| 79 | 79 |
| 80 /** | 80 /** |
| 81 * The classes that have been visited while attempting to infer the types of | 81 * The classes that have been visited while attempting to infer the types of |
| 82 * instance members of some base class. | 82 * instance members of some base class. |
| 83 */ | 83 */ |
| 84 HashSet<ClassElementImpl> elementsBeingInferred = | 84 HashSet<ClassElementImpl> elementsBeingInferred = |
| 85 new HashSet<ClassElementImpl>(); | 85 new HashSet<ClassElementImpl>(); |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * Initialize a newly create inferrer. | 88 * Initialize a newly create inferrer. |
| 89 */ | 89 */ |
| 90 InstanceMemberInferrer(this.typeProvider, {TypeSystem typeSystem}) | 90 InstanceMemberInferrer(this.typeProvider, this.inheritanceManager, |
| 91 {TypeSystem typeSystem}) |
| 91 : typeSystem = (typeSystem != null) ? typeSystem : new TypeSystemImpl(); | 92 : typeSystem = (typeSystem != null) ? typeSystem : new TypeSystemImpl(); |
| 92 | 93 |
| 93 /** | 94 /** |
| 94 * Infer type information for all of the instance members in the given | 95 * Infer type information for all of the instance members in the given |
| 95 * compilation [unit]. | 96 * compilation [unit]. |
| 96 */ | 97 */ |
| 97 void inferCompilationUnit(CompilationUnitElement unit) { | 98 void inferCompilationUnit(CompilationUnitElement unit) { |
| 98 inheritanceManager = new InheritanceManager(unit.library); | |
| 99 unit.types.forEach((ClassElement classElement) { | 99 unit.types.forEach((ClassElement classElement) { |
| 100 try { | 100 try { |
| 101 _inferClass(classElement); | 101 _inferClass(classElement); |
| 102 } on _CycleException { | 102 } on _CycleException { |
| 103 // This is a short circuit return to prevent types that inherit from | 103 // This is a short circuit return to prevent types that inherit from |
| 104 // types containing a circular reference from being inferred. | 104 // types containing a circular reference from being inferred. |
| 105 } | 105 } |
| 106 }); | 106 }); |
| 107 } | 107 } |
| 108 | 108 |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 results.add(element); | 476 results.add(element); |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * A class of exception that is not used anywhere else. | 483 * A class of exception that is not used anywhere else. |
| 484 */ | 484 */ |
| 485 class _CycleException implements Exception {} | 485 class _CycleException implements Exception {} |
| OLD | NEW |