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

Side by Side Diff: tests/compiler/dart2js/serialization/test_helper.dart

Issue 2847143002: Fix KernelEquivalence.entityEquivalence for equi-named instance/top-level members (Closed)
Patch Set: 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) 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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 } 714 }
715 return false; 715 return false;
716 case ElementKind.LIBRARY: 716 case ElementKind.LIBRARY:
717 if (b is KLibrary) { 717 if (b is KLibrary) {
718 LibraryElement libraryA = a; 718 LibraryElement libraryA = a;
719 return libraryA.canonicalUri == b.canonicalUri; 719 return libraryA.canonicalUri == b.canonicalUri;
720 } 720 }
721 return false; 721 return false;
722 case ElementKind.FUNCTION: 722 case ElementKind.FUNCTION:
723 if (b is KMethod) { 723 if (b is KMethod) {
724 if (!strategy.test(a, b, 'name', a.name, b.name)) return false; 724 return strategy.test(a, b, 'name', a.name, b.name) &&
725 if (b.enclosingClass != null) { 725 strategy.testElements(
726 return strategy.testElements( 726 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass) &&
727 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass); 727 strategy.testElements(a, b, 'library', a.library, b.library);
728 } else {
729 return strategy.testElements(
730 a, b, 'library', a.library, testing.getLibraryForFunction(b));
731 }
732 } else if (b is KLocalFunction) { 728 } else if (b is KLocalFunction) {
733 LocalFunctionElement aLocalFunction = a; 729 LocalFunctionElement aLocalFunction = a;
734 return strategy.test(a, b, 'name', a.name, b.name ?? '') && 730 return strategy.test(a, b, 'name', a.name, b.name ?? '') &&
735 strategy.testElements(a, b, 'executableContext', 731 strategy.testElements(a, b, 'executableContext',
736 aLocalFunction.executableContext, b.executableContext) && 732 aLocalFunction.executableContext, b.executableContext) &&
737 strategy.testElements(a, b, 'memberContext', 733 strategy.testElements(a, b, 'memberContext',
738 aLocalFunction.memberContext, b.memberContext); 734 aLocalFunction.memberContext, b.memberContext);
739 } 735 }
740 return false; 736 return false;
741 case ElementKind.GETTER: 737 case ElementKind.GETTER:
742 if (b is KGetter) { 738 if (b is KGetter) {
743 if (!strategy.test(a, b, 'name', a.name, b.name)) return false; 739 return strategy.test(a, b, 'name', a.name, b.name) &&
744 if (b.enclosingClass != null) { 740 strategy.testElements(
745 return strategy.testElements( 741 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass) &&
746 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass); 742 strategy.testElements(a, b, 'library', a.library, b.library);
747 } else {
748 return strategy.testElements(
749 a, b, 'library', a.library, testing.getLibraryForFunction(b));
750 }
751 } 743 }
752 return false; 744 return false;
753 case ElementKind.SETTER: 745 case ElementKind.SETTER:
754 if (b is KSetter) { 746 if (b is KSetter) {
755 if (!strategy.test(a, b, 'name', a.name, b.name)) return false; 747 return strategy.test(a, b, 'name', a.name, b.name) &&
756 if (b.enclosingClass != null) { 748 strategy.testElements(
757 return strategy.testElements( 749 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass) &&
758 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass); 750 strategy.testElements(a, b, 'library', a.library, b.library);
759 } else {
760 return strategy.testElements(
761 a, b, 'library', a.library, testing.getLibraryForFunction(b));
762 }
763 } 751 }
764 return false; 752 return false;
765 case ElementKind.FIELD: 753 case ElementKind.FIELD:
766 if (b is KField) { 754 if (b is KField) {
767 if (!strategy.test(a, b, 'name', a.name, b.name)) return false; 755 return strategy.test(a, b, 'name', a.name, b.name) &&
768 if (b.enclosingClass != null) { 756 strategy.testElements(
769 return strategy.testElements( 757 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass) &&
770 a, b, 'enclosingClass', a.enclosingClass, b.enclosingClass); 758 strategy.testElements(a, b, 'library', a.library, b.library);
771 } else {
772 return strategy.testElements(
773 a, b, 'library', a.library, testing.getLibraryForField(b));
774 }
775 } 759 }
776 return false; 760 return false;
777 case ElementKind.TYPE_VARIABLE: 761 case ElementKind.TYPE_VARIABLE:
778 if (b is KTypeVariable) { 762 if (b is KTypeVariable) {
779 TypeVariableElement aElement = a; 763 TypeVariableElement aElement = a;
780 return strategy.test(a, b, 'index', aElement.index, b.index) && 764 return strategy.test(a, b, 'index', aElement.index, b.index) &&
781 strategy.testElements(a, b, 'typeDeclaration', 765 strategy.testElements(a, b, 'typeDeclaration',
782 aElement.typeDeclaration, b.typeDeclaration); 766 aElement.typeDeclaration, b.typeDeclaration);
783 } 767 }
784 return false; 768 return false;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 strategy.testTypeLists(a, b, 'namedParameterTypes', 809 strategy.testTypeLists(a, b, 'namedParameterTypes',
826 aType.namedParameterTypes, b.namedParameterTypes); 810 aType.namedParameterTypes, b.namedParameterTypes);
827 } 811 }
828 return false; 812 return false;
829 default: 813 default:
830 throw new UnsupportedError('Unsupported equivalence: ' 814 throw new UnsupportedError('Unsupported equivalence: '
831 '$a (${a.runtimeType}) vs $b (${b.runtimeType})'); 815 '$a (${a.runtimeType}) vs $b (${b.runtimeType})');
832 } 816 }
833 } 817 }
834 } 818 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698