Chromium Code Reviews| Index: pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart |
| diff --git a/pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart b/pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart |
| index 6cce8985ee24d1d55bed4ca1bcf33163ea45898c..5ef4007f86c84b97881a4769911be11d26326d79 100644 |
| --- a/pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart |
| +++ b/pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart |
| @@ -233,15 +233,43 @@ class KernelSorter implements Sorter { |
| @override |
| Iterable<ClassEntity> sortClasses(Iterable<ClassEntity> classes) { |
| - return classes.toList() |
| - ..sort((ClassEntity cls1, ClassEntity cls2) { |
| - int r = _compareLibraries(cls1.library, cls2.library); |
| - if (r != 0) return r; |
| - ClassDefinition definition1 = elementMap.getClassDefinition(cls1); |
| - ClassDefinition definition2 = elementMap.getClassDefinition(cls2); |
| - return _compareSourceSpans( |
| - cls1, definition1.location, cls2, definition2.location); |
| + int compareClasses(ClassEntity cls1, ClassEntity cls2) { |
| + int r = _compareLibraries(cls1.library, cls2.library); |
| + if (r != 0) return r; |
| + ClassDefinition definition1 = elementMap.getClassDefinition(cls1); |
| + ClassDefinition definition2 = elementMap.getClassDefinition(cls2); |
| + return _compareSourceSpans( |
| + cls1, definition1.location, cls2, definition2.location); |
| + } |
| + |
| + ClassEntity getMixin(ClassEntity cls) { |
| + ClassEntity mixin; |
| + elementMap.elementEnvironment.forEachMixin(cls, (ClassEntity c) { |
|
Siggi Cherem (dart-lang)
2017/08/30 19:33:52
maybe it is worth having a method to just fetch th
|
| + if (c != null) return; |
|
Siggi Cherem (dart-lang)
2017/08/30 19:33:52
seems like c/mixin are swapped here and below:
|
| + c = mixin; |
| }); |
| + return mixin; |
| + } |
| + |
| + List<ClassEntity> regularClasses = <ClassEntity>[]; |
| + List<ClassEntity> unnamedMixins = <ClassEntity>[]; |
| + for (ClassEntity cls in classes) { |
| + if (elementMap.elementEnvironment.isUnnamedMixinApplication(cls)) { |
| + unnamedMixins.add(cls); |
| + } else { |
| + regularClasses.add(cls); |
| + } |
| + } |
| + List<ClassEntity> sorted = <ClassEntity>[]; |
| + regularClasses.sort(compareClasses); |
| + sorted.addAll(regularClasses); |
| + unnamedMixins.sort((a, b) { |
| + int result = a.name.compareTo(b.name); |
| + if (result != 0) return result; |
| + return compareClasses(getMixin(a), getMixin(b)); |
|
Siggi Cherem (dart-lang)
2017/08/30 19:33:52
should this be recursive instead?
e.g: compare A&
Johnni Winther
2017/09/01 15:17:45
Remove the need for this. If we sort first by libr
|
| + }); |
| + sorted.addAll(unnamedMixins); |
| + return sorted; |
| } |
| @override |