Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

Constructors (named or default) may be invoked as instance methods #162

Open
@vsmenon

Description

@vsmenon

In the following code, both A and A.from may be invoked as instance methods on an instance of A.

class A<T> {
  T x;

  A(this.x) { print("Constructing an A"); }

  A.from(A<T> a) {
    x = a.x;
  }
}

dynamic z;

main() {
  var y = new A<int>(1);
  var x = new A<int>(2);
  z = y;
  z.from(x);
  print(y.x); // Prints '2'
  z.A(); // Prints 'Constructing an A'
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions