| 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:collection'; | 7 import 'dart:collection'; |
| 8 import 'package:compiler/src/common/resolution.dart'; | 8 import 'package:compiler/src/common/resolution.dart'; |
| 9 import 'package:compiler/src/constants/expressions.dart'; | 9 import 'package:compiler/src/constants/expressions.dart'; |
| 10 import 'package:compiler/src/constants/values.dart'; | 10 import 'package:compiler/src/constants/values.dart'; |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 return strategy.test(a, b, 'name', a.name, b.name) && | 668 return strategy.test(a, b, 'name', a.name, b.name) && |
| 669 strategy.testElements( | 669 strategy.testElements( |
| 670 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass); | 670 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass); |
| 671 } | 671 } |
| 672 return false; | 672 return false; |
| 673 case ElementKind.CLASS: | 673 case ElementKind.CLASS: |
| 674 if (b is KClass) { | 674 if (b is KClass) { |
| 675 List<InterfaceType> aMixinTypes = []; | 675 List<InterfaceType> aMixinTypes = []; |
| 676 List<InterfaceType> bMixinTypes = []; | 676 List<InterfaceType> bMixinTypes = []; |
| 677 ClassElement aClass = a; | 677 ClassElement aClass = a; |
| 678 while (aClass.isMixinApplication) { | 678 if (aClass.isUnnamedMixinApplication) { |
| 679 MixinApplicationElement aMixinApplication = aClass; | 679 if (!testing.isUnnamedMixinApplication(b)) { |
| 680 aMixinTypes.add(aMixinApplication.mixinType); | |
| 681 aClass = aMixinApplication.superclass; | |
| 682 } | |
| 683 KClass bClass = b; | |
| 684 while (bClass != null) { | |
| 685 InterfaceType mixinType = testing.getMixinTypeForClass(bClass); | |
| 686 if (mixinType == null) break; | |
| 687 bMixinTypes.add(mixinType); | |
| 688 bClass = testing.getSuperclassForClass(bClass); | |
| 689 } | |
| 690 if (aMixinTypes.isNotEmpty || aMixinTypes.isNotEmpty) { | |
| 691 if (aClass.isNamedMixinApplication && | |
| 692 !strategy.test(a, b, 'name', a.name, b.name)) { | |
| 693 return false; | 680 return false; |
| 694 } | 681 } |
| 695 Pair<ClassEntity, ClassEntity> pair = | 682 while (aClass.isMixinApplication) { |
| 696 new Pair<ClassEntity, ClassEntity>(aClass, bClass); | 683 MixinApplicationElement aMixinApplication = aClass; |
| 697 if (assumedMixinApplications.contains(pair)) { | 684 aMixinTypes.add(aMixinApplication.mixinType); |
| 698 return true; | 685 aClass = aMixinApplication.superclass; |
| 699 } else { | 686 } |
| 700 assumedMixinApplications.add(pair); | 687 KClass bClass = b; |
| 701 bool result = strategy.testTypeLists( | 688 while (bClass != null) { |
| 702 a, b, 'mixinTypes', aMixinTypes, bMixinTypes); | 689 InterfaceType mixinType = testing.getMixinTypeForClass(bClass); |
| 703 assumedMixinApplications.remove(pair); | 690 if (mixinType == null) break; |
| 704 return result; | 691 bMixinTypes.add(mixinType); |
| 692 bClass = testing.getSuperclassForClass(bClass); |
| 693 } |
| 694 if (aMixinTypes.isNotEmpty || aMixinTypes.isNotEmpty) { |
| 695 Pair<ClassEntity, ClassEntity> pair = |
| 696 new Pair<ClassEntity, ClassEntity>(aClass, bClass); |
| 697 if (assumedMixinApplications.contains(pair)) { |
| 698 return true; |
| 699 } else { |
| 700 assumedMixinApplications.add(pair); |
| 701 bool result = strategy.testTypeLists( |
| 702 a, b, 'mixinTypes', aMixinTypes, bMixinTypes); |
| 703 assumedMixinApplications.remove(pair); |
| 704 return result; |
| 705 } |
| 706 } |
| 707 } else { |
| 708 if (testing.isUnnamedMixinApplication(b)) { |
| 709 return false; |
| 705 } | 710 } |
| 706 } | 711 } |
| 707 return strategy.test(a, b, 'name', a.name, b.name) && | 712 return strategy.test(a, b, 'name', a.name, b.name) && |
| 708 strategy.testElements( | 713 strategy.testElements(a, b, 'library', a.library, b.library); |
| 709 a, b, 'library', a.library, testing.getLibraryForClass(b)); | |
| 710 } | 714 } |
| 711 return false; | 715 return false; |
| 712 case ElementKind.LIBRARY: | 716 case ElementKind.LIBRARY: |
| 713 if (b is KLibrary) { | 717 if (b is KLibrary) { |
| 714 LibraryElement libraryA = a; | 718 LibraryElement libraryA = a; |
| 715 return libraryA.canonicalUri == testing.getLibraryUri(b); | 719 return libraryA.canonicalUri == b.canonicalUri; |
| 716 } | 720 } |
| 717 return false; | 721 return false; |
| 718 case ElementKind.FUNCTION: | 722 case ElementKind.FUNCTION: |
| 719 if (b is KMethod) { | 723 if (b is KMethod) { |
| 720 if (!strategy.test(a, b, 'name', a.name, b.name)) return false; | 724 if (!strategy.test(a, b, 'name', a.name, b.name)) return false; |
| 721 if (b.enclosingClass != null) { | 725 if (b.enclosingClass != null) { |
| 722 return strategy.testElements( | 726 return strategy.testElements( |
| 723 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass); | 727 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass); |
| 724 } else { | 728 } else { |
| 725 return strategy.testElements( | 729 return strategy.testElements( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 strategy.testTypeLists(a, b, 'namedParameterTypes', | 825 strategy.testTypeLists(a, b, 'namedParameterTypes', |
| 822 aType.namedParameterTypes, b.namedParameterTypes); | 826 aType.namedParameterTypes, b.namedParameterTypes); |
| 823 } | 827 } |
| 824 return false; | 828 return false; |
| 825 default: | 829 default: |
| 826 throw new UnsupportedError('Unsupported equivalence: ' | 830 throw new UnsupportedError('Unsupported equivalence: ' |
| 827 '$a (${a.runtimeType}) vs $b (${b.runtimeType})'); | 831 '$a (${a.runtimeType}) vs $b (${b.runtimeType})'); |
| 828 } | 832 } |
| 829 } | 833 } |
| 830 } | 834 } |
| OLD | NEW |