Index: runtime/vm/parser.cc |
diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc |
index 14446d997566b961a762f96e7cb7dd5bff590864..7a26916271ae58924cdd9352c2bc42e4824908b5 100644 |
--- a/runtime/vm/parser.cc |
+++ b/runtime/vm/parser.cc |
@@ -2900,6 +2900,31 @@ SequenceNode* Parser::MakeImplicitConstructor(const Function& func) { |
const TokenPosition ctor_pos = TokenPos(); |
OpenFunctionBlock(func); |
+ if ((current_class().is_mixin_app_alias() || |
+ current_class().IsMixinApplication()) && |
+ func.HasOptionalParameters()) { |
+ // At this point we don't support forwarding constructors |
+ // that have optional parameters because we don't know the default |
+ // values of the optional parameters. We would have to compile the super |
+ // constructor to get the default values. Also, the spec is not clear |
+ // whether optional parameters are even allowed in this situation. |
+ // TODO(hausner): Remove this limitation if the language spec indeed |
+ // allows optional parameters. |
+ const Class& super_class = Class::Handle(Z, current_class().SuperClass()); |
+ const String& msg = String::Handle(Symbols::NewFormatted(thread(), |
+ "cannot generate an implicit mixin application constructor " |
+ "forwarding to a super class constructor with optional " |
+ "parameters; add a constructor without optional parameters " |
+ "to class '%s' that redirects to the constructor with " |
+ "optional parameters and invoke it via super from a " |
+ "constructor of the class extending the mixin application", |
+ String::Handle(Z, super_class.Name()).ToCString())); |
+ ArgumentListNode* args = new ArgumentListNode(ST(ctor_pos)); |
+ args->Add(new LiteralNode(ctor_pos, msg)); |
+ current_block_->statements->Add(MakeStaticCall( |
+ Symbols::UnsupportedError(), Symbols::ThrowNew(), args)); |
+ return CloseBlock(); |
siva
2016/04/25 23:38:31
This code has been moved from somewhere?
Ivan Posva
2016/04/26 21:17:43
From line 2951. Will be removed there once I am co
Ivan Posva
2016/05/03 21:46:40
Removed for now again.
|
+ } |
LocalVariable* receiver = new LocalVariable( |
TokenPosition::kNoSource, |
Symbols::This(), |