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

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2935933005: fix mixins with factory constructors (Closed)
Patch Set: d Created 3 years, 6 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
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index e9e17f69c49d497e846e5434f5d2318493cf1c7d..91f662d6351ba6fe427af932b7b435b931c5f4a7 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -1775,12 +1775,27 @@ class CodeGenerator extends Object
return;
}
+ bool foundConstructor = false;
for (var ctor in ctors) {
var element = ctor.element;
if (element.isFactory || _externalOrNative(ctor)) continue;
addConstructor(
element, _emitConstructor(ctor, fields, isCallable, className));
+ foundConstructor = true;
+ }
+
+ // If classElement has only factory constructors, and it can be mixed in,
+ // then we need to emit a special hidden default constructor for use by
+ // mixins.
+ if (!foundConstructor && classElem.supertype.isObject) {
+ body.add(
+ js.statement('(#[#] = function() { # }).prototype = #.prototype;', [
+ className,
+ _callHelper('mixinNew'),
+ [_initializeFields(fields)],
+ className
+ ]));
}
}
« no previous file with comments | « pkg/dev_compiler/lib/sdk/ddc_sdk.sum ('k') | pkg/dev_compiler/tool/input_sdk/private/ddc_runtime/classes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698