Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: tests/compiler/dart2js/kernel/closed_world2_test.dart

Issue 2847143002: Fix KernelEquivalence.entityEquivalence for equi-named instance/top-level members (Closed)
Patch Set: Updated cf. comment Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 // Partial test that the closed world computed from [WorldImpact]s derived from 5 // Partial test that the closed world computed from [WorldImpact]s derived from
6 // kernel is equivalent to the original computed from resolution. 6 // kernel is equivalent to the original computed from resolution.
7 library dart2js.kernel.closed_world2_test; 7 library dart2js.kernel.closed_world2_test;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 10
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 class Mixin { 65 class Mixin {
66 method1() {} 66 method1() {}
67 method2() {} 67 method2() {}
68 method3() {} 68 method3() {}
69 } 69 }
70 class Class1 = Object with Mixin; 70 class Class1 = Object with Mixin;
71 class Class2 extends Object with Mixin { 71 class Class2 extends Object with Mixin {
72 method3() {} 72 method3() {}
73 } 73 }
74 74
75 method1() {} // Deliberately the same name as the instance member in Mixin.
75 76
76 @NoInline() 77 @NoInline()
77 main() { 78 main() {
78 print('Hello World'); 79 print('Hello World');
79 ''.contains; // Trigger member closurization. 80 ''.contains; // Trigger member closurization.
80 new Element.div(); 81 new Element.div();
81 new ClassWithSetter().setter = null; 82 new ClassWithSetter().setter = null;
82 new Class1().method1(); 83 new Class1().method1();
83 new Class2().method2(); 84 new Class2().method2();
84 new Class2().method3(); 85 new Class2().method3();
85 null is List<int>; 86 null is List<int>;
87 method1(); // Both top level and instance method named 'method1' are live.
86 } 88 }
87 ''' 89 '''
88 }; 90 };
89 91
90 main(List<String> args) { 92 main(List<String> args) {
91 asyncTest(() async { 93 asyncTest(() async {
92 await mainInternal(args); 94 await mainInternal(args);
93 }); 95 });
94 } 96 }
95 97
96 Future mainInternal(List<String> args, 98 enum ResultKind { crashes, errors, warnings, success, failure }
99
100 Future<ResultKind> mainInternal(List<String> args,
97 {bool skipWarnings: false, bool skipErrors: false}) async { 101 {bool skipWarnings: false, bool skipErrors: false}) async {
98 Arguments arguments = new Arguments.from(args); 102 Arguments arguments = new Arguments.from(args);
99 Uri entryPoint; 103 Uri entryPoint;
100 Map<String, String> memorySourceFiles; 104 Map<String, String> memorySourceFiles;
101 if (arguments.uri != null) { 105 if (arguments.uri != null) {
102 entryPoint = arguments.uri; 106 entryPoint = arguments.uri;
103 memorySourceFiles = const <String, String>{}; 107 memorySourceFiles = const <String, String>{};
104 } else { 108 } else {
105 entryPoint = Uri.parse('memory:main.dart'); 109 entryPoint = Uri.parse('memory:main.dart');
106 memorySourceFiles = SOURCE; 110 memorySourceFiles = SOURCE;
107 } 111 }
108 112
109 enableDebugMode(); 113 enableDebugMode();
110 114
111 print('---- analyze-only ------------------------------------------------'); 115 print('---- analyze-only ------------------------------------------------');
112 DiagnosticCollector collector = new DiagnosticCollector(); 116 DiagnosticCollector collector = new DiagnosticCollector();
113 Compiler compiler1 = compilerFor( 117 Compiler compiler1 = compilerFor(
114 entryPoint: entryPoint, 118 entryPoint: entryPoint,
115 memorySourceFiles: memorySourceFiles, 119 memorySourceFiles: memorySourceFiles,
116 diagnosticHandler: collector, 120 diagnosticHandler: collector,
117 options: [Flags.analyzeOnly, Flags.enableAssertMessage]); 121 options: [Flags.analyzeOnly, Flags.enableAssertMessage]);
118 ElementResolutionWorldBuilder.useInstantiationMap = true; 122 ElementResolutionWorldBuilder.useInstantiationMap = true;
119 compiler1.resolution.retainCachesForTesting = true; 123 compiler1.resolution.retainCachesForTesting = true;
120 await compiler1.run(entryPoint); 124 await compiler1.run(entryPoint);
125 if (collector.crashes.isNotEmpty) {
126 print('Skipping due to crashes.');
127 return ResultKind.crashes;
128 }
121 if (collector.errors.isNotEmpty && skipErrors) { 129 if (collector.errors.isNotEmpty && skipErrors) {
122 print('Skipping due to errors.'); 130 print('Skipping due to errors.');
123 return; 131 return ResultKind.errors;
124 } 132 }
125 if (collector.warnings.isNotEmpty && skipWarnings) { 133 if (collector.warnings.isNotEmpty && skipWarnings) {
126 print('Skipping due to warnings.'); 134 print('Skipping due to warnings.');
127 return; 135 return ResultKind.warnings;
128 } 136 }
129 Expect.isFalse(compiler1.compilationFailed); 137 Expect.isFalse(compiler1.compilationFailed);
130 ResolutionEnqueuer enqueuer1 = compiler1.enqueuer.resolution; 138 ResolutionEnqueuer enqueuer1 = compiler1.enqueuer.resolution;
131 BackendUsage backendUsage1 = compiler1.backend.backendUsage; 139 BackendUsage backendUsage1 = compiler1.backend.backendUsage;
132 ClosedWorld closedWorld1 = compiler1.resolutionWorldBuilder.closeWorld(); 140 ClosedWorld closedWorld1 = compiler1.resolutionWorldBuilder.closeWorld();
133 141
134 print('---- analyze-all -------------------------------------------------'); 142 print('---- analyze-all -------------------------------------------------');
135 Compiler compiler = compilerFor( 143 Compiler compiler = compilerFor(
136 entryPoint: entryPoint, 144 entryPoint: entryPoint,
137 memorySourceFiles: memorySourceFiles, 145 memorySourceFiles: memorySourceFiles,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 checkBackendUsage(backendUsage1, backendUsage2, equivalence); 180 checkBackendUsage(backendUsage1, backendUsage2, equivalence);
173 181
174 checkResolutionEnqueuers(backendUsage1, backendUsage2, enqueuer1, enqueuer2, 182 checkResolutionEnqueuers(backendUsage1, backendUsage2, enqueuer1, enqueuer2,
175 elementEquivalence: equivalence.entityEquivalence, 183 elementEquivalence: equivalence.entityEquivalence,
176 typeEquivalence: (ResolutionDartType a, DartType b) { 184 typeEquivalence: (ResolutionDartType a, DartType b) {
177 return equivalence.typeEquivalence(unalias(a), b); 185 return equivalence.typeEquivalence(unalias(a), b);
178 }, elementFilter: elementFilter, verbose: arguments.verbose); 186 }, elementFilter: elementFilter, verbose: arguments.verbose);
179 187
180 checkClosedWorlds(closedWorld1, closedWorld2, equivalence.entityEquivalence, 188 checkClosedWorlds(closedWorld1, closedWorld2, equivalence.entityEquivalence,
181 verbose: arguments.verbose); 189 verbose: arguments.verbose);
190
191 return ResultKind.success;
182 } 192 }
183 193
184 List createKernelResolutionEnqueuerListener( 194 List createKernelResolutionEnqueuerListener(
185 CompilerOptions options, 195 CompilerOptions options,
186 DiagnosticReporter reporter, 196 DiagnosticReporter reporter,
187 DeferredLoadTask deferredLoadTask, 197 DeferredLoadTask deferredLoadTask,
188 KernelToElementMap elementMap, 198 KernelToElementMap elementMap,
189 NativeBasicData nativeBasicData) { 199 NativeBasicData nativeBasicData) {
190 ElementEnvironment elementEnvironment = elementMap.elementEnvironment; 200 ElementEnvironment elementEnvironment = elementMap.elementEnvironment;
191 CommonElements commonElements = elementMap.commonElements; 201 CommonElements commonElements = elementMap.commonElements;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 370
361 MemoryDillLibraryLoaderTask(KernelToElementMap elementMap, 371 MemoryDillLibraryLoaderTask(KernelToElementMap elementMap,
362 DiagnosticReporter reporter, Measurer measurer, this.program) 372 DiagnosticReporter reporter, Measurer measurer, this.program)
363 : super(elementMap, null, null, reporter, measurer); 373 : super(elementMap, null, null, reporter, measurer);
364 374
365 Future<LoadedLibraries> loadLibrary(Uri resolvedUri, 375 Future<LoadedLibraries> loadLibrary(Uri resolvedUri,
366 {bool skipFileWithPartOfTag: false}) async { 376 {bool skipFileWithPartOfTag: false}) async {
367 return createLoadedLibraries(program); 377 return createLoadedLibraries(program);
368 } 378 }
369 } 379 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/element_map.dart ('k') | tests/compiler/dart2js/kernel/closed_world_tester.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698