Skip to content

Forwarding constructors must not have optional parameters #15101

@DartBot

Description

@DartBot

This issue was originally filed by @filiph


What steps will reproduce the problem?

  1. Extend a class that has an optional parameter in the constructor.
  2. Add a mixin

What is the expected output? What do you see instead?
I get a runtime error:
    forwarding constructors must not have optional parameters

I would expect this to work without problems, or at least to have better explanation (it is, for example, not clear if the culprit is the base class, the mixin, or the class being extended) and a compile time error.

But really, I find this quite limiting.

What version of the product are you using? On what operating system?
Dart Editor version 1.0.0_r30187 (DEV)
Dart SDK version 1.0.0.3_r30187
Mac OSX 10.8.5

Please provide any additional information below.

===== CODE =====

class Mixin extends Object {
  int mixinMember;
}

class BaseClass {
  int baseMember;
  BaseClass({this.baseMember: -1});
}

class Class extends BaseClass with Mixin {
  int member;
  Class(this.member);
}

void main() {
  var c = new Class(42);
}

===== /CODE =====


Attachment:
mixinoptparameters.dart (249 Bytes)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions