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 |
+ ])); |
} |
} |