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

Unified Diff: pkg/front_end/lib/src/fasta/kernel/kernel_target.dart

Issue 2732293004: Install default constructors on broken mixin applications. (Closed)
Patch Set: Update status files. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/rasta/class_hierarchy.dart.outline.expect » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
index 218585d6cc4a74426cf969414b4e0af7ca74f8c3..d04bc35fb942f071386d3df0dbcd118947d3e234 100644
--- a/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/kernel_target.dart
@@ -394,7 +394,14 @@ class KernelTarget extends TargetImplementation {
/// If [builder] doesn't have a constructors, install the defaults.
void installDefaultConstructor(SourceClassBuilder builder) {
- if (builder.isMixinApplication || builder.constructors.isNotEmpty) return;
+ if (builder.cls.isMixinApplication) {
+ // We have to test if builder.cls is a mixin application. [builder] may
+ // think it's a mixin application, but if its mixed-in type couldn't be
+ // resolved, the target class won't be a mixin application and we need
+ // to add a default constructor to complete error recovery.
+ return;
+ }
+ if (builder.constructors.isNotEmpty) return;
/// Quotes below are from [Dart Programming Language Specification, 4th
/// Edition](
@@ -429,9 +436,13 @@ class KernelTarget extends TargetImplementation {
builder.getSubstitutionMap(supertype, builder.fileUri,
builder.charOffset, dynamicType),
builder.parent);
- for (Constructor constructor in supertype.cls.constructors) {
- builder.addSyntheticConstructor(makeMixinApplicationConstructor(
- builder.cls.mixin, constructor, substitutionMap));
+ if (supertype.cls.constructors.isEmpty) {
+ builder.addSyntheticConstructor(makeDefaultConstructor());
+ } else {
+ for (Constructor constructor in supertype.cls.constructors) {
+ builder.addSyntheticConstructor(makeMixinApplicationConstructor(
+ builder.cls.mixin, constructor, substitutionMap));
+ }
}
} else {
internalError("Unhandled: ${supertype.runtimeType}");
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/rasta/class_hierarchy.dart.outline.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698