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

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

Issue 2983483002: Check function type equivalence (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « tests/compiler/dart2js/equivalence/check_functions.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 dart2js.kernel.equivalence; 5 library dart2js.kernel.equivalence;
6 6
7 import 'package:compiler/src/common/backend_api.dart'; 7 import 'package:compiler/src/common/backend_api.dart';
8 import 'package:compiler/src/common/resolution.dart'; 8 import 'package:compiler/src/common/resolution.dart';
9 import 'package:compiler/src/common/work.dart'; 9 import 'package:compiler/src/common/work.dart';
10 import 'package:compiler/src/constants/expressions.dart'; 10 import 'package:compiler/src/constants/expressions.dart';
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 default: 168 default:
169 throw new UnsupportedError('Unsupported equivalence: ' 169 throw new UnsupportedError('Unsupported equivalence: '
170 '$a (${a.runtimeType}) vs $b (${b.runtimeType})'); 170 '$a (${a.runtimeType}) vs $b (${b.runtimeType})');
171 } 171 }
172 } 172 }
173 173
174 bool typeEquivalence(ResolutionDartType a, DartType b, 174 bool typeEquivalence(ResolutionDartType a, DartType b,
175 {TestStrategy strategy}) { 175 {TestStrategy strategy}) {
176 if (identical(a, b)) return true; 176 if (identical(a, b)) return true;
177 if (a == null || b == null) return false; 177 if (a == null || b == null) return false;
178 a = unalias(a);
178 strategy ??= defaultStrategy; 179 strategy ??= defaultStrategy;
179 switch (a.kind) { 180 switch (a.kind) {
180 case ResolutionTypeKind.DYNAMIC: 181 case ResolutionTypeKind.DYNAMIC:
181 return b is DynamicType; 182 return b is DynamicType;
182 case ResolutionTypeKind.VOID: 183 case ResolutionTypeKind.VOID:
183 return b is VoidType; 184 return b is VoidType;
184 case ResolutionTypeKind.INTERFACE: 185 case ResolutionTypeKind.INTERFACE:
185 if (b is InterfaceType) { 186 if (b is InterfaceType) {
186 ResolutionInterfaceType aType = a; 187 ResolutionInterfaceType aType = a;
187 return strategy.testElements(a, b, 'element', a.element, b.element) && 188 return strategy.testElements(a, b, 'element', a.element, b.element) &&
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 for (ConstructorElement constructor in element.constructors) { 307 for (ConstructorElement constructor in element.constructors) {
307 if (!constructor.isRedirectingFactory) { 308 if (!constructor.isRedirectingFactory) {
308 return true; 309 return true;
309 } 310 }
310 } 311 }
311 // The class cannot itself be instantiated. 312 // The class cannot itself be instantiated.
312 return false; 313 return false;
313 } 314 }
314 return true; 315 return true;
315 } 316 }
OLDNEW
« no previous file with comments | « tests/compiler/dart2js/equivalence/check_functions.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698