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 related_types; | 5 library related_types; |
6 | 6 |
7 import 'package:compiler/src/commandline_options.dart'; | 7 import 'package:compiler/src/commandline_options.dart'; |
8 import 'package:compiler/src/compiler.dart'; | 8 import 'package:compiler/src/compiler.dart'; |
9 import 'package:compiler/src/core_types.dart'; | 9 import 'package:compiler/src/core_types.dart'; |
10 import 'package:compiler/src/dart_types.dart'; | 10 import 'package:compiler/src/dart_types.dart'; |
(...skipping 18 matching lines...) Expand all Loading... |
29 checkRelatedTypes(result.compiler); | 29 checkRelatedTypes(result.compiler); |
30 } | 30 } |
31 } else { | 31 } else { |
32 print('Usage dart related_types.dart <entry-point>'); | 32 print('Usage dart related_types.dart <entry-point>'); |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 /// Check all loaded libraries in [compiler] for unrelated types. | 36 /// Check all loaded libraries in [compiler] for unrelated types. |
37 void checkRelatedTypes(Compiler compiler) { | 37 void checkRelatedTypes(Compiler compiler) { |
38 compiler.closeResolution(); | 38 compiler.closeResolution(); |
39 compiler.closedWorld; | |
40 for (LibraryElement library in compiler.libraryLoader.libraries) { | 39 for (LibraryElement library in compiler.libraryLoader.libraries) { |
41 checkLibraryElement(compiler, library); | 40 checkLibraryElement(compiler, library); |
42 } | 41 } |
43 } | 42 } |
44 | 43 |
45 /// Check [library] for unrelated types. | 44 /// Check [library] for unrelated types. |
46 void checkLibraryElement(Compiler compiler, LibraryElement library) { | 45 void checkLibraryElement(Compiler compiler, LibraryElement library) { |
47 library.forEachLocalMember((Element element) { | 46 library.forEachLocalMember((Element element) { |
48 if (element.isClass) { | 47 if (element.isClass) { |
49 ClassElement cls = element; | 48 ClassElement cls = element; |
(...skipping 21 matching lines...) Expand all Loading... |
71 } | 70 } |
72 | 71 |
73 class RelatedTypesChecker extends TraversalVisitor<DartType, dynamic> { | 72 class RelatedTypesChecker extends TraversalVisitor<DartType, dynamic> { |
74 final Compiler compiler; | 73 final Compiler compiler; |
75 final ResolvedAst resolvedAst; | 74 final ResolvedAst resolvedAst; |
76 | 75 |
77 RelatedTypesChecker(this.compiler, ResolvedAst resolvedAst) | 76 RelatedTypesChecker(this.compiler, ResolvedAst resolvedAst) |
78 : this.resolvedAst = resolvedAst, | 77 : this.resolvedAst = resolvedAst, |
79 super(resolvedAst.elements); | 78 super(resolvedAst.elements); |
80 | 79 |
81 ClosedWorld get world => compiler.closedWorld; | 80 ClosedWorld get world => compiler.resolverWorld.closedWorldForTesting; |
82 | 81 |
83 CoreClasses get coreClasses => compiler.coreClasses; | 82 CoreClasses get coreClasses => compiler.coreClasses; |
84 | 83 |
85 CoreTypes get coreTypes => compiler.coreTypes; | 84 CoreTypes get coreTypes => compiler.coreTypes; |
86 | 85 |
87 DiagnosticReporter get reporter => compiler.reporter; | 86 DiagnosticReporter get reporter => compiler.reporter; |
88 | 87 |
89 InterfaceType get thisType => resolvedAst.element.enclosingClass.thisType; | 88 InterfaceType get thisType => resolvedAst.element.enclosingClass.thisType; |
90 | 89 |
91 /// Returns `true` if there exists no common subtype of [left] and [right]. | 90 /// Returns `true` if there exists no common subtype of [left] and [right]. |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 ClassElement findClass(DartType type) => type.accept(this, null); | 411 ClassElement findClass(DartType type) => type.accept(this, null); |
413 | 412 |
414 @override | 413 @override |
415 ClassElement visitType(DartType type, _) => null; | 414 ClassElement visitType(DartType type, _) => null; |
416 | 415 |
417 @override | 416 @override |
418 ClassElement visitInterfaceType(InterfaceType type, _) { | 417 ClassElement visitInterfaceType(InterfaceType type, _) { |
419 return type.element; | 418 return type.element; |
420 } | 419 } |
421 } | 420 } |
OLD | NEW |