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
Description
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'
}