1ca17b6d03
Kernel mixin transformation desugars mixin applications into normal classes. Mixed-in type is pulled into interfaces list. However, dart:mirrors needs to know the original mixed-in type of a mixin application. This change solves this problem by propagating a 'isTransformedMixinApplication' attribute of a class through kernel AST, kernel binary and VM objects into dart:mirrors implementation. Fixes: https://github.com/dart-lang/sdk/issues/33240 Change-Id: I98ca69294e1ad445402a5ca91d90c30447aabcb2 Reviewed-on: https://dart-review.googlesource.com/56721 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Reviewed-by: Kevin Millikin <kmillikin@google.com>
47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
import 'package:front_end/src/fasta/kernel/utils.dart' show serializeComponent;
|
|
|
|
import 'package:kernel/kernel.dart'
|
|
show Class, Component, EmptyStatement, Library, Procedure, Reference;
|
|
|
|
List<int> postProcess(Component c) {
|
|
c.libraries.sort((l1, l2) {
|
|
return "${l1.fileUri}".compareTo("${l2.fileUri}");
|
|
});
|
|
|
|
c.computeCanonicalNames();
|
|
for (Library library in c.libraries) {
|
|
library.additionalExports.sort((Reference r1, Reference r2) {
|
|
return "${r1.canonicalName}".compareTo("${r2.canonicalName}");
|
|
});
|
|
}
|
|
|
|
return serializeComponent(c);
|
|
}
|
|
|
|
void throwOnEmptyMixinBodies(Component component) {
|
|
int empty = countEmptyMixinBodies(component);
|
|
if (empty != 0) {
|
|
throw "Expected 0 empty bodies in mixins, but found $empty";
|
|
}
|
|
}
|
|
|
|
int countEmptyMixinBodies(Component component) {
|
|
int empty = 0;
|
|
for (Library lib in component.libraries) {
|
|
for (Class c in lib.classes) {
|
|
if (c.isAnonymousMixin) {
|
|
for (Procedure p in c.procedures) {
|
|
if (p.function.body is EmptyStatement) {
|
|
empty++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return empty;
|
|
}
|