More minor fixes to the analyzer/FE comparison tool.
- The new mixin syntax is now handled. It's a little kludgy since the
front end lowers it to the old supermixin representation, so we have
to do a similar lowering to the analyzer representation. Once the
front end has full support for the new mixin syntax, I'll clean this
up.
- Synthetic '__loadLibrary_' functions (inserted by the front end to
cover the corner case where the "loadLibrary" function is torn off)
are ignored.
Drops the number of failing language_2 tests with `--compiler
compare_analyzer_cfe` from 22 to 11. I believe the remaining failures
are genuine bugs in either the front end or the analyzer.
Change-Id: I452ee92c418c04661d35cda1ed129ee5715879cd
Reviewed-on: https://dart-review.googlesource.com/75207
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/pkg/analyzer_fe_comparison/lib/src/analyzer.dart b/pkg/analyzer_fe_comparison/lib/src/analyzer.dart
index 7abd5b8..e8a8730 100644
--- a/pkg/analyzer_fe_comparison/lib/src/analyzer.dart
+++ b/pkg/analyzer_fe_comparison/lib/src/analyzer.dart
@@ -198,6 +198,18 @@
}
@override
+ void visitMixinDeclaration(MixinDeclaration node) {
+ // At present, kernel doesn't distinguish between mixin and class
+ // declarations. So treat the mixin as a class.
+ var children = <ComparisonNode>[];
+ var visitor = _AnalyzerVisitor(_typeProvider, children);
+ visitor._handleClassOrClassTypeAlias(node.declaredElement);
+ visitor._visitList(node.members);
+ _resultNodes
+ .add(ComparisonNode.sorted('Class ${node.name.name}', children));
+ }
+
+ @override
Null visitNode(AstNode node) {
throw new UnimplementedError('AnalyzerVisitor: ${node.runtimeType}');
}
@@ -221,11 +233,31 @@
void _handleClassOrClassTypeAlias(ClassElement element) {
_visitTypeParameters(element.typeParameters);
- if (element.supertype != null) {
- _resultNodes.add(_translateType('Extends: ', element.supertype));
+ InterfaceType supertype;
+ List<InterfaceType> mixins;
+ if (element.isMixin) {
+ // Kernel represents:
+ // - `mixin M` as `class M extends Object`
+ // - `mixin M on A` as `class M extends A`
+ // - `mixin M on A, B` as `class M extends A with B`
+ // - `mixin M on A, B, C` as `class M extends A with B, C`.
+ var superclassConstraints = element.superclassConstraints;
+ if (superclassConstraints.isEmpty) {
+ supertype = _typeProvider.objectType;
+ mixins = [];
+ } else {
+ supertype = superclassConstraints[0];
+ mixins = superclassConstraints.skip(1).toList();
+ }
+ } else {
+ supertype = element.supertype;
+ mixins = element.mixins;
}
- for (int i = 0; i < element.mixins.length; i++) {
- _resultNodes.add(_translateType('Mixin $i: ', element.mixins[i]));
+ if (supertype != null) {
+ _resultNodes.add(_translateType('Extends: ', supertype));
+ }
+ for (int i = 0; i < mixins.length; i++) {
+ _resultNodes.add(_translateType('Mixin $i: ', mixins[i]));
}
for (int i = 0; i < element.interfaces.length; i++) {
_resultNodes
diff --git a/pkg/analyzer_fe_comparison/lib/src/kernel.dart b/pkg/analyzer_fe_comparison/lib/src/kernel.dart
index 04e16a9..561f5e6 100644
--- a/pkg/analyzer_fe_comparison/lib/src/kernel.dart
+++ b/pkg/analyzer_fe_comparison/lib/src/kernel.dart
@@ -206,6 +206,11 @@
if (procedure.isSyntheticForwarder) {
return null;
}
+ if (procedure.name.name.startsWith('__loadLibrary_')) {
+ // Sometimes the front end generates procedures with this name that don't
+ // correspond to anything in the source file. Ignore them.
+ return null;
+ }
// TODO(paulberry): add an annotation to the ComparisonNode when the
// procedure is a factory.
var kind = procedure.isFactory