OLD | NEW |
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.serialization_test_helper; | 5 library dart2js.serialization_test_helper; |
6 | 6 |
7 import 'dart:io'; | 7 import 'dart:io'; |
8 import 'memory_compiler.dart'; | 8 import 'memory_compiler.dart'; |
9 import 'package:async_helper/async_helper.dart'; | 9 import 'package:async_helper/async_helper.dart'; |
10 import 'package:compiler/src/common/resolution.dart'; | 10 import 'package:compiler/src/common/resolution.dart'; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 bool hasProperty(Element member1), | 287 bool hasProperty(Element member1), |
288 void checkMemberProperties(Compiler compiler1, Element member1, | 288 void checkMemberProperties(Compiler compiler1, Element member1, |
289 Compiler compiler2, Element member2, | 289 Compiler compiler2, Element member2, |
290 {bool verbose}), | 290 {bool verbose}), |
291 {bool verbose: false}) { | 291 {bool verbose: false}) { |
292 | 292 |
293 void checkMembers(Element member1, Element member2) { | 293 void checkMembers(Element member1, Element member2) { |
294 if (member1.isClass && member2.isClass) { | 294 if (member1.isClass && member2.isClass) { |
295 ClassElement class1 = member1; | 295 ClassElement class1 = member1; |
296 ClassElement class2 = member2; | 296 ClassElement class2 = member2; |
| 297 if (!class1.isResolved) return; |
| 298 |
297 class1.forEachLocalMember((m1) { | 299 class1.forEachLocalMember((m1) { |
298 checkMembers(m1, class2.lookupLocalMember(m1.name)); | 300 checkMembers(m1, class2.localLookup(m1.name)); |
299 }); | 301 }); |
| 302 ClassElement superclass1 = class1.superclass; |
| 303 ClassElement superclass2 = class2.superclass; |
| 304 while (superclass1 != null && superclass1.isUnnamedMixinApplication) { |
| 305 for (ConstructorElement c1 in superclass1.constructors) { |
| 306 checkMembers(c1, superclass2.lookupConstructor(c1.name)); |
| 307 } |
| 308 superclass1 = superclass1.superclass; |
| 309 superclass2 = superclass2.superclass; |
| 310 } |
300 return; | 311 return; |
301 } | 312 } |
302 | 313 |
303 if (!hasProperty(member1)) { | 314 if (!hasProperty(member1)) { |
304 return; | 315 return; |
305 } | 316 } |
306 | 317 |
307 if (member2 == null) { | 318 if (member2 == null) { |
308 return; | 319 throw 'Missing member for ${member1}'; |
309 } | 320 } |
310 | 321 |
311 if (areElementsEquivalent(member1, member2)) { | 322 if (areElementsEquivalent(member1, member2)) { |
312 checkMemberProperties( | 323 checkMemberProperties( |
313 compiler1, member1, | 324 compiler1, member1, |
314 compiler2, member2, | 325 compiler2, member2, |
315 verbose: verbose); | 326 verbose: verbose); |
316 } | 327 } |
317 } | 328 } |
318 | 329 |
(...skipping 22 matching lines...) Expand all Loading... |
341 }, | 352 }, |
342 checkImpacts, | 353 checkImpacts, |
343 verbose: verbose); | 354 verbose: verbose); |
344 } | 355 } |
345 | 356 |
346 /// Check equivalence of resolution impact for [member1] and [member2]. | 357 /// Check equivalence of resolution impact for [member1] and [member2]. |
347 void checkImpacts(Compiler compiler1, Element member1, | 358 void checkImpacts(Compiler compiler1, Element member1, |
348 Compiler compiler2, Element member2, | 359 Compiler compiler2, Element member2, |
349 {bool verbose: false}) { | 360 {bool verbose: false}) { |
350 ResolutionImpact impact1 = compiler1.resolution.getResolutionImpact(member1); | 361 ResolutionImpact impact1 = compiler1.resolution.getResolutionImpact(member1); |
351 ResolutionImpact impact2 = | 362 ResolutionImpact impact2 = compiler2.resolution.getResolutionImpact(member2); |
352 compiler2.serialization.deserializer.getResolutionImpact(member2); | |
353 | 363 |
354 if (impact1 == null || impact2 == null) return; | 364 if (impact1 == null && impact2 == null) return; |
355 | 365 |
356 if (verbose) { | 366 if (verbose) { |
357 print('Checking impacts for $member1 vs $member2'); | 367 print('Checking impacts for $member1 vs $member2'); |
358 } | 368 } |
359 | 369 |
| 370 if (impact1 == null) { |
| 371 throw 'Missing impact for $member1. $member2 has $impact2'; |
| 372 } |
| 373 if (impact2 == null) { |
| 374 throw 'Missing impact for $member2. $member1 has $impact1'; |
| 375 } |
| 376 |
360 testResolutionImpactEquivalence(impact1, impact2, const CheckStrategy()); | 377 testResolutionImpactEquivalence(impact1, impact2, const CheckStrategy()); |
361 } | 378 } |
OLD | NEW |