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..ff5df10a44f0ce5b8e167d66305bb132aa071a33 100644 |
--- a/pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart |
+++ b/pkg/compiler/lib/src/kernel/kernel_backend_strategy.dart |
@@ -233,15 +233,37 @@ 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); |
+ } |
+ |
+ 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 = _compareLibraries(a.library, b.library); |
+ if (result != 0) return result; |
+ result = a.name.compareTo(b.name); |
+ assert(result != 0, |
+ failedAt(a, "Multiple mixins named ${a.name}: $a vs $b.")); |
Siggi Cherem (dart-lang)
2017/09/01 15:41:49
do we ensure today that if you do A extends Object
Johnni Winther
2017/09/01 16:13:48
We do in the optimized mixin algorithm (ported fro
|
+ return result; |
+ }); |
+ sorted.addAll(unnamedMixins); |
+ return sorted; |
} |
@override |