Migrate language_2/constructor to NNBD.
Change-Id: I2f638cbf6b0fc6e91b3666143a34eb12a66c6fea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141780
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
diff --git a/tests/language/constructor/bad_constructor_runtime_1_test.dart b/tests/language/constructor/bad_constructor_runtime_1_test.dart
new file mode 100644
index 0000000..cf8d562
--- /dev/null
+++ b/tests/language/constructor/bad_constructor_runtime_1_test.dart
@@ -0,0 +1,39 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// A constructor can't be static.
+class A {
+
+ A();
+}
+
+// A factory constructor can't be static.
+class B {
+
+ factory B() { return B._(); }
+
+ B._();
+}
+
+// A named constructor can have the same name as a setter.
+class E {
+ set setter(value) {}
+ E.setter();
+}
+
+// A constructor can't be static.
+class F {
+
+ F(){}
+}
+
+main() {
+ new A();
+ new B();
+ new E.setter();
+ new F();
+}
diff --git a/tests/language/constructor/bad_constructor_runtime_test.dart b/tests/language/constructor/bad_constructor_runtime_test.dart
new file mode 100644
index 0000000..71e14bd
--- /dev/null
+++ b/tests/language/constructor/bad_constructor_runtime_test.dart
@@ -0,0 +1,39 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// A constructor can't be static.
+class A {
+
+ A();
+}
+
+// A factory constructor can't be static.
+class B {
+
+ factory B() { return B._(); }
+
+ B._();
+}
+
+// A named constructor can have the same name as a setter.
+class E {
+
+ E.setter();
+}
+
+// A constructor can't be static.
+class F {
+
+ F(){}
+}
+
+main() {
+ new A();
+ new B();
+ new E.setter();
+ new F();
+}
diff --git a/tests/language/constructor/bad_constructor_test.dart b/tests/language/constructor/bad_constructor_test.dart
new file mode 100644
index 0000000..5cb42f6
--- /dev/null
+++ b/tests/language/constructor/bad_constructor_test.dart
@@ -0,0 +1,48 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// A constructor can't be static.
+class A {
+ static
+//^^^^^^
+// [analyzer] SYNTACTIC_ERROR.STATIC_CONSTRUCTOR
+// [cfe] Constructors can't be static.
+ A();
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.MISSING_FUNCTION_BODY
+ // [cfe] Expected a function body or '=>'.
+}
+
+// A factory constructor can't be static.
+class B {
+ static
+//^^^^^^
+// [analyzer] SYNTACTIC_ERROR.EXTRANEOUS_MODIFIER
+// [cfe] Can't have modifier 'static' here.
+ factory B() { return B._(); }
+
+ B._();
+}
+
+// A named constructor can have the same name as a setter.
+class E {
+ set setter(value) {}
+ E.setter();
+}
+
+// A constructor can't be static.
+class F {
+ static
+//^^^^^^
+// [analyzer] SYNTACTIC_ERROR.STATIC_CONSTRUCTOR
+// [cfe] Constructors can't be static.
+ F(){}
+}
+
+main() {
+ new A();
+ new B();
+ new E.setter();
+ new F();
+}
diff --git a/tests/language/constructor/bad_named_constructor_runtime_test.dart b/tests/language/constructor/bad_named_constructor_runtime_test.dart
new file mode 100644
index 0000000..c84de90
--- /dev/null
+++ b/tests/language/constructor/bad_named_constructor_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+ A() {}
+
+}
+
+main() {
+ new A();
+}
diff --git a/tests/language/constructor/bad_named_constructor_test.dart b/tests/language/constructor/bad_named_constructor_test.dart
new file mode 100644
index 0000000..d8a40d9
--- /dev/null
+++ b/tests/language/constructor/bad_named_constructor_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+ A() {}
+ WrongName.foo() {}
+//^^^^^^^^^
+// [analyzer] SYNTACTIC_ERROR.INVALID_CONSTRUCTOR_NAME
+// [cfe] The name of a constructor must match the name of the enclosing class.
+}
+
+main() {
+ new A();
+}
diff --git a/tests/language/constructor/body_test.dart b/tests/language/constructor/body_test.dart
new file mode 100644
index 0000000..d64d61f
--- /dev/null
+++ b/tests/language/constructor/body_test.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors without function bodies.
+
+import "package:expect/expect.dart";
+
+// Test a non-const constructor works without a body.
+class First {
+ First(int this.value);
+ First.named(int this.value);
+ int value;
+}
+
+// Test a const constructor works without a body.
+class Second {
+ const Second(int this.value);
+ const Second.named(int this.value);
+ final int value;
+}
+
+class ConstructorBodyTest {
+ static testMain() {
+ Expect.equals(4, new First(4).value);
+ Expect.equals(5, new First.named(5).value);
+ Expect.equals(6, new Second(6).value);
+ Expect.equals(7, new Second.named(7).value);
+ }
+}
+
+main() {
+ ConstructorBodyTest.testMain();
+}
diff --git a/tests/language/constructor/bodyless_wrong_arg_runtime_test.dart b/tests/language/constructor/bodyless_wrong_arg_runtime_test.dart
new file mode 100644
index 0000000..6a6c07e
--- /dev/null
+++ b/tests/language/constructor/bodyless_wrong_arg_runtime_test.dart
@@ -0,0 +1,25 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Base {
+ final String name;
+ const Base(this.name);
+}
+
+class C extends Base {
+ const C(String s)
+ : super(
+ // Call super constructor with wrong argument count.
+
+ s
+
+ );
+}
+
+main() {
+ const C("str");
+}
diff --git a/tests/language/constructor/bodyless_wrong_arg_test.dart b/tests/language/constructor/bodyless_wrong_arg_test.dart
new file mode 100644
index 0000000..4e669d0
--- /dev/null
+++ b/tests/language/constructor/bodyless_wrong_arg_test.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Base {
+ final String name;
+ const Base(this.name);
+}
+
+class C extends Base {
+ const C(String s)
+ // Call super constructor with wrong argument count.
+ : super();
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+}
+
+main() {
+ const C("str");
+}
diff --git a/tests/language/constructor/call_as_function_test.dart b/tests/language/constructor/call_as_function_test.dart
new file mode 100644
index 0000000..cb1dbda
--- /dev/null
+++ b/tests/language/constructor/call_as_function_test.dart
@@ -0,0 +1,13 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Point {
+ const Point(this.x, this.y);
+ final int x;
+ final int y;
+}
+
+main() {
+ Point p = Point(1, 2);
+}
diff --git a/tests/language/constructor/call_wrong_argument_count_runtime_test.dart b/tests/language/constructor/call_wrong_argument_count_runtime_test.dart
new file mode 100644
index 0000000..adb20bd
--- /dev/null
+++ b/tests/language/constructor/call_wrong_argument_count_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Stockhorn {
+ Stockhorn(int a);
+}
+
+main() {
+ new Stockhorn(1);
+
+}
diff --git a/tests/language/constructor/call_wrong_argument_count_test.dart b/tests/language/constructor/call_wrong_argument_count_test.dart
new file mode 100644
index 0000000..4830bcd
--- /dev/null
+++ b/tests/language/constructor/call_wrong_argument_count_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Stockhorn {
+ Stockhorn(int a);
+}
+
+main() {
+ new Stockhorn(1);
+ new Stockhorn();
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+}
diff --git a/tests/language/constructor/constructor10_runtime_test.dart b/tests/language/constructor/constructor10_runtime_test.dart
new file mode 100644
index 0000000..554c0e1
--- /dev/null
+++ b/tests/language/constructor/constructor10_runtime_test.dart
@@ -0,0 +1,47 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check that the implicit super call for synthetic constructors are checked.
+
+class A {
+ final x;
+ A(this.x);
+}
+
+class B extends A {
+
+ B() : super(null);
+
+}
+
+// ==========
+
+class Y extends A {
+
+ Y() : super(null);
+
+}
+
+class Z extends Y {
+ Z() : super();
+}
+
+// ==============
+
+class G extends A {
+
+ G() : super(null);
+
+}
+
+class H extends G {}
+
+main() {
+ new B().x;
+ new Z().x;
+ new H().x;
+}
diff --git a/tests/language/constructor/constructor10_test.dart b/tests/language/constructor/constructor10_test.dart
new file mode 100644
index 0000000..06426fb
--- /dev/null
+++ b/tests/language/constructor/constructor10_test.dart
@@ -0,0 +1,53 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check that the implicit super call for synthetic constructors are checked.
+
+class A {
+ final x;
+ A(this.x);
+}
+
+class B extends A {
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
+ /*
+ B() : super(null);
+ */
+}
+
+// ==========
+
+class Y extends A {
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
+ /*
+ Y() : super(null);
+ */
+}
+
+class Z extends Y {
+ Z() : super();
+}
+
+// ==============
+
+class G extends A {
+// ^
+// [analyzer] COMPILE_TIME_ERROR.NO_DEFAULT_SUPER_CONSTRUCTOR
+// [cfe] The superclass, 'A', has no unnamed constructor that takes no arguments.
+ /*
+ G() : super(null);
+ */
+}
+
+class H extends G {}
+
+main() {
+ new B().x;
+ new Z().x;
+ new H().x;
+}
diff --git a/tests/language/constructor/constructor11_test.dart b/tests/language/constructor/constructor11_test.dart
new file mode 100644
index 0000000..73d08a3
--- /dev/null
+++ b/tests/language/constructor/constructor11_test.dart
@@ -0,0 +1,44 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check that the implicit super call for synthetic constructors are checked.
+
+import "package:expect/expect.dart";
+
+class A {
+ final x;
+ A([this.x = 499]);
+}
+
+class B extends A {}
+
+// ==========
+
+class X {
+ final x;
+ X([this.x = 42]);
+}
+
+class Y extends X {}
+
+class Z extends Y {
+ Z() : super();
+}
+
+// ==============
+
+class F {
+ final x;
+ F([this.x = 99]);
+}
+
+class G extends F {}
+
+class H extends G {}
+
+main() {
+ Expect.equals(499, new B().x);
+ Expect.equals(42, new Z().x);
+ Expect.equals(99, new H().x);
+}
diff --git a/tests/language/constructor/constructor12_test.dart b/tests/language/constructor/constructor12_test.dart
new file mode 100644
index 0000000..477955c
--- /dev/null
+++ b/tests/language/constructor/constructor12_test.dart
@@ -0,0 +1,69 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+class B {
+ final z;
+ B(this.z);
+
+ foo() => this.z;
+}
+
+class A<T> extends B {
+ var captured, captured2;
+ var typedList;
+
+ // p must be inside a box (in dart2js).
+ A(p)
+ : captured = (() => p),
+ super(p++) {
+ // Make constructor body non-inlinable.
+ try {} catch (e) {}
+
+ captured2 = () => p++;
+
+ // In the current implementation of dart2js makes the generic type an
+ // argument to the body.
+ typedList = <T>[];
+ }
+
+ foo() => captured();
+ bar() => captured2();
+}
+
+@pragma('dart2js:noInline')
+@pragma('dart2js:assumeDynamic')
+confuse(x) => x;
+
+main() {
+ var a = confuse(new A<int>(1));
+ var a2 = confuse(new A(2));
+ var b = confuse(new B(3));
+ Expect.equals(2, a.foo());
+ Expect.equals(3, a2.foo());
+ Expect.equals(3, b.foo());
+ Expect.equals(1, a.z);
+ Expect.equals(2, a2.z);
+ Expect.equals(3, b.z);
+ Expect.isTrue(a is A<int>);
+ Expect.isFalse(a is A<String>);
+ Expect.isFalse(a2 is A<int>);
+ Expect.isFalse(a2 is A<String>);
+ Expect.isFalse(a2 is A<Object>);
+ Expect.isTrue(a2 is A<Object?>);
+ Expect.equals(2, a.bar());
+ Expect.equals(3, a2.bar());
+ Expect.equals(3, a.foo());
+ Expect.equals(4, a2.foo());
+ Expect.equals(0, a.typedList.length);
+ Expect.equals(0, a2.typedList.length);
+ a.typedList.add(499);
+ Expect.equals(1, a.typedList.length);
+ Expect.equals(0, a2.typedList.length);
+ Expect.isTrue(a.typedList is List<int>);
+ Expect.isFalse(a2.typedList is List<int>);
+ Expect.isFalse(a.typedList is List<String>);
+ Expect.isFalse(a2.typedList is List<String>);
+}
diff --git a/tests/language/constructor/constructor13_runtime_test.dart b/tests/language/constructor/constructor13_runtime_test.dart
new file mode 100644
index 0000000..e2ff3b6
--- /dev/null
+++ b/tests/language/constructor/constructor13_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check that there's no crash when constructor called with wrong
+// number of args.
+
+class Klass {
+ Klass(v) {}
+}
+
+main() {
+
+ new Klass(1);
+
+}
diff --git a/tests/language/constructor/constructor13_test.dart b/tests/language/constructor/constructor13_test.dart
new file mode 100644
index 0000000..f6790ec
--- /dev/null
+++ b/tests/language/constructor/constructor13_test.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check that there's no crash when constructor called with wrong
+// number of args.
+
+class Klass {
+ Klass(v) {}
+}
+
+main() {
+ new Klass();
+ // ^^
+ // [analyzer] COMPILE_TIME_ERROR.NOT_ENOUGH_POSITIONAL_ARGUMENTS
+ // [cfe] Too few positional arguments: 1 required, 0 given.
+ new Klass(1);
+ new Klass(1, 2);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 1 allowed, but 2 found.
+}
diff --git a/tests/language/constructor/constructor2_test.dart b/tests/language/constructor/constructor2_test.dart
new file mode 100644
index 0000000..97dd7de
--- /dev/null
+++ b/tests/language/constructor/constructor2_test.dart
@@ -0,0 +1,45 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors and initializers.
+
+import "package:expect/expect.dart";
+
+// Expect the initializer expressions E(i) to be evaluated
+// in the order 1, 2, 3, ...
+// Each expression must be evaluated exactly once.
+
+String trace = "";
+
+int E(int i) {
+ trace += "$i-";
+ return i;
+}
+
+class A {
+ var a1;
+ A(x, y) : a1 = E(4) {
+ Expect.equals(2, x);
+ Expect.equals(3, y);
+ Expect.equals(4, a1);
+ E(6);
+ }
+}
+
+class B extends A {
+ var b1, b2;
+
+ B(x)
+ : b1 = E(1),
+ b2 = E(5),
+ super(E(2), E(3)) {
+ Expect.equals(1, b1);
+ Expect.equals(5, b2);
+ E(7);
+ }
+}
+
+main() {
+ var b = new B(0);
+ Expect.equals("1-5-2-3-4-6-7-", trace);
+}
diff --git a/tests/language/constructor/constructor3_test.dart b/tests/language/constructor/constructor3_test.dart
new file mode 100644
index 0000000..4bb7173
--- /dev/null
+++ b/tests/language/constructor/constructor3_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors and initializers.
+
+import "package:expect/expect.dart";
+
+// Expect the initializer expressions E(i) to be evaluated
+// in the order 1, 2, 3, ...
+// Each expression must be evaluated exactly once.
+
+String trace = "";
+
+int E(int i) {
+ trace += "$i-";
+ return i;
+}
+
+class A {
+ var a1;
+ A(x, y) : a1 = E(3) {
+ Expect.equals(1, x);
+ Expect.equals(2, y);
+ E(5);
+ }
+}
+
+class B extends A {
+ var b1;
+ B(x)
+ : b1 = E(4),
+ super(E(1), E(2)) {
+ // Implicit super call to A's body happens here.
+ Expect.equals(4, b1);
+ E(6);
+ }
+}
+
+main() {
+ var b = new B(0);
+ Expect.equals("4-1-2-3-5-6-", trace);
+}
diff --git a/tests/language/constructor/constructor4_test.dart b/tests/language/constructor/constructor4_test.dart
new file mode 100644
index 0000000..b4df9b0
--- /dev/null
+++ b/tests/language/constructor/constructor4_test.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors and initializers.
+
+import "package:expect/expect.dart";
+
+// Expect the initializer expressions E(i) to be evaluated
+// in the order 1, 2, 3, ...
+// Each expression must be evaluated exactly once.
+
+String trace = "";
+
+int E(int i) {
+ trace += "$i-";
+ return i;
+}
+
+class A {
+ var a1;
+ A() : a1 = E(2) {
+ E(3);
+ }
+}
+
+class B extends A {
+ var b1;
+ B(x) : b1 = E(1) /* Implicit super call to A's initializers happens here. */ {
+ // Implicit super call to A's body happens here.
+ E(4);
+ }
+}
+
+main() {
+ var b = new B(0);
+ Expect.equals("1-2-3-4-", trace);
+}
diff --git a/tests/language/constructor/constructor5_test.dart b/tests/language/constructor/constructor5_test.dart
new file mode 100644
index 0000000..52020cf
--- /dev/null
+++ b/tests/language/constructor/constructor5_test.dart
@@ -0,0 +1,57 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors and initializers.
+
+import "package:expect/expect.dart";
+
+// Super initializer and super constructor body are executed in with the same
+// bindings.
+
+String trace = "";
+
+int E(int i) {
+ trace = "$trace$i-";
+ return i;
+}
+
+class A {
+ A({arg1: 100, arg2: 200})
+ : a1 = E(arg1++),
+ a2 = E(arg2++) {
+ // b2 should be initialized between the above initializers and the following
+ // statements.
+ E(arg1); // 101
+ E(arg2); // 51
+ }
+ var a1;
+ var a2;
+}
+
+class B extends A {
+ // Initializers in order: b1, super, b2.
+ B(x, y)
+ : b1 = E(x++),
+ b2 = E(y++),
+ super(arg2: 50) {
+ // Implicit super call to A's body happens here.
+ E(x); // 11
+ E(y); // 21
+ }
+ var b1;
+ var b2;
+}
+
+class C extends B {
+ C() : super(10, 20);
+}
+
+main() {
+ var c = new C();
+ Expect.equals(100, c.a1);
+ Expect.equals(50, c.a2);
+ Expect.equals(10, c.b1);
+ Expect.equals(20, c.b2);
+
+ Expect.equals("10-20-100-50-101-51-11-21-", trace);
+}
diff --git a/tests/language/constructor/constructor6_test.dart b/tests/language/constructor/constructor6_test.dart
new file mode 100644
index 0000000..71f6c38
--- /dev/null
+++ b/tests/language/constructor/constructor6_test.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors and initializers.
+
+import "package:expect/expect.dart";
+
+// Super initializer and super constructor body are executed in with the same
+// bindings.
+
+String trace = "";
+
+int E(int i) {
+ trace = "$trace$i-";
+ return i;
+}
+
+class A {
+ // f closes-over arg. arg needs to be preserved while b2 is initialized.
+ A(arg)
+ : a = E(arg += 1),
+ f = (() => E(arg += 10)) {
+ // b2 should be initialized between the above initializers and the following
+ // statements.
+ var r1 = f();
+ E(arg += 100); // If this is the same arg as closed by f, ...
+ var r2 = f(); // .. the effect of +=100 will be seen here.
+ }
+ final a;
+ final f;
+}
+
+class B extends A {
+ // Initializers in order: b1, super, b2.
+ B(x, y)
+ : b1 = E(x++),
+ b2 = E(y++),
+ super(1000) {
+ // Implicit super call to A's body happens here.
+ E(x);
+ E(y);
+ f();
+ }
+ var b1;
+ var b2;
+}
+
+class C extends B {
+ C() : super(10, 20);
+}
+
+main() {
+ var c = new C();
+ Expect.equals("10-20-1001-1011-1111-1121-11-21-1131-", trace);
+}
diff --git a/tests/language/constructor/constructor7_test.dart b/tests/language/constructor/constructor7_test.dart
new file mode 100644
index 0000000..5ed7be4
--- /dev/null
+++ b/tests/language/constructor/constructor7_test.dart
@@ -0,0 +1,61 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors and initializers.
+
+import "package:expect/expect.dart";
+
+// Expect the initializer expressions E(i) to be evaluated
+// in the order 1, 2, 3, ...
+// This test has no inheritance but many fields to flush out issues with
+// ordering of fields.
+
+String trace = "";
+
+int E(int i) {
+ trace += "$i-";
+ return i;
+}
+
+class A {
+ var j; // Names are in reverse order to detect sorting by name...
+ var i = 0; // Initialized odd/even to detect these inits affecting order.
+ var h;
+ var g = 0;
+ var f;
+ var e = 0;
+ var d;
+ var c = 0;
+ var b;
+ var a = 0;
+
+ A()
+ : a = E(1), // Initializations in different order to decls. Ascending...
+ b = E(2),
+ c = E(3),
+ f = E(4), // Descending to be perverse...
+ e = E(5),
+ d = E(6),
+ g = E(7), // Ascending again.
+ h = E(8),
+ i = E(9),
+ j = E(10) {
+ Expect.equals(1, a);
+ Expect.equals(2, b);
+ Expect.equals(3, c);
+
+ Expect.equals(4, f);
+ Expect.equals(5, e);
+ Expect.equals(6, d);
+
+ Expect.equals(7, g);
+ Expect.equals(8, h);
+ Expect.equals(9, i);
+ Expect.equals(10, j);
+ }
+}
+
+main() {
+ var x = new A();
+ Expect.equals('1-2-3-4-5-6-7-8-9-10-', trace);
+}
diff --git a/tests/language/constructor/constructor8_test.dart b/tests/language/constructor/constructor8_test.dart
new file mode 100644
index 0000000..2de31c4
--- /dev/null
+++ b/tests/language/constructor/constructor8_test.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Regression test for dart2js that used to crash on this program.
+
+class A {
+ var b;
+
+ // The closure in the constructor body used to confuse the SSA builder
+ // when it created the call to the constructor body.
+ A.withClosure(Map? a) {
+ var c;
+ var f = () {
+ return c = 42;
+ };
+ b = f();
+ Expect.equals(42, b);
+ Expect.equals(42, c);
+ }
+}
+
+main() {
+ new A.withClosure(null);
+ new A.withClosure({});
+}
diff --git a/tests/language/constructor/constructor9_runtime_test.dart b/tests/language/constructor/constructor9_runtime_test.dart
new file mode 100644
index 0000000..fcdbf5a
--- /dev/null
+++ b/tests/language/constructor/constructor9_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check that all final instance fields of a class are initialized by
+// constructors.
+
+class Klass {
+ Klass(var v) : field_ = v {}
+
+ var field_;
+}
+
+main() {
+ new Klass(5);
+}
diff --git a/tests/language/constructor/constructor9_test.dart b/tests/language/constructor/constructor9_test.dart
new file mode 100644
index 0000000..4c7b35d
--- /dev/null
+++ b/tests/language/constructor/constructor9_test.dart
@@ -0,0 +1,24 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check that all final instance fields of a class are initialized by
+// constructors.
+
+class Klass {
+ Klass(var v) : field_ = v {}
+//^^^^^
+// [analyzer] STATIC_WARNING.FINAL_NOT_INITIALIZED_CONSTRUCTOR
+ final uninitializedFinalField_;
+ // ^
+ // [cfe] Final field 'uninitializedFinalField_' is not initialized.
+ final uninitializedFinalField_;
+ // ^^^^^^^^^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.DUPLICATE_DEFINITION
+ // [cfe] 'uninitializedFinalField_' is already declared in this scope.
+ var field_;
+}
+
+main() {
+ new Klass(5);
+}
diff --git a/tests/language/constructor/constructor_test.dart b/tests/language/constructor/constructor_test.dart
new file mode 100644
index 0000000..17c3842
--- /dev/null
+++ b/tests/language/constructor/constructor_test.dart
@@ -0,0 +1,65 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for constructors and initializers.
+
+import "package:expect/expect.dart";
+
+class A extends B {
+ A(x, y)
+ : a = x,
+ super(y) {}
+
+ var a;
+}
+
+class B {
+ var b;
+
+ B(x) : b = x {}
+
+ B.namedB(var x) : b = x {}
+}
+
+// Test the order of initialization: first the instance variable then
+// the super constructor.
+abstract class Alpha {
+ Alpha(v) {
+ this.foo(v);
+ }
+ foo(v) => throw 'Alpha.foo should never be called.';
+}
+
+class Beta extends Alpha {
+ Beta(v)
+ : b = 1,
+ super(v) {}
+
+ foo(v) {
+ // Check that 'b' was initialized.
+ Expect.equals(1, b);
+ b = v;
+ }
+
+ var b;
+}
+
+class ConstructorTest {
+ static testMain() {
+ var o = new A(10, 2);
+ Expect.equals(10, o.a);
+ Expect.equals(2, o.b);
+
+ var o1 = new B.namedB(10);
+ Expect.equals(10, o1.b);
+
+ Expect.equals(22, o.a + o.b + o1.b);
+
+ var beta = new Beta(3);
+ Expect.equals(3, beta.b);
+ }
+}
+
+main() {
+ ConstructorTest.testMain();
+}
diff --git a/tests/language/constructor/cyclic_constructor_test.dart b/tests/language/constructor/cyclic_constructor_test.dart
new file mode 100644
index 0000000..1b2533f
--- /dev/null
+++ b/tests/language/constructor/cyclic_constructor_test.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+ A.a() : this.b();
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
+ A.b()
+ : this.a()
+ //^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
+ // ^
+ // [cfe] Redirecting constructors can't be cyclic.
+ ;
+ A.c() : this.b();
+}
+
+main() {
+ new A.a();
+ new A.b();
+ new A.c();
+}
diff --git a/tests/language/constructor/cyclic_runtime_test.dart b/tests/language/constructor/cyclic_runtime_test.dart
new file mode 100644
index 0000000..b0cf8aff
--- /dev/null
+++ b/tests/language/constructor/cyclic_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+ A.a() : this.b();
+ A.b()
+
+ ;
+ A.c() : this.b();
+}
+
+main() {
+ new A.a();
+ new A.b();
+ new A.c();
+}
diff --git a/tests/language/constructor/default_class_implicit_constructor_test.dart b/tests/language/constructor/default_class_implicit_constructor_test.dart
new file mode 100644
index 0000000..30d48a5
--- /dev/null
+++ b/tests/language/constructor/default_class_implicit_constructor_test.dart
@@ -0,0 +1,20 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// An abstract class with a redirecting factory to a class with no declared
+// constructor should use the implicit default constructor.
+
+abstract class A {
+ factory A() = B;
+}
+
+class B implements A {}
+
+main() {
+ var val = new A();
+ Expect.equals(true, val is A);
+ Expect.equals(true, val is B);
+}
diff --git a/tests/language/constructor/default_factory2_runtime_test.dart b/tests/language/constructor/default_factory2_runtime_test.dart
new file mode 100644
index 0000000..2113b80
--- /dev/null
+++ b/tests/language/constructor/default_factory2_runtime_test.dart
@@ -0,0 +1,24 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check type bounds when invoking a redirecting factory method
+
+abstract class Foo {}
+
+abstract class IA<T> {
+
+}
+
+class A<T extends Foo> implements IA<T> {
+ factory A() { return A._(); }
+
+ A._();
+}
+
+main() {
+
+}
diff --git a/tests/language/constructor/default_factory2_test.dart b/tests/language/constructor/default_factory2_test.dart
new file mode 100644
index 0000000..a8b56b8
--- /dev/null
+++ b/tests/language/constructor/default_factory2_test.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check type bounds when invoking a redirecting factory method
+
+abstract class Foo {}
+
+abstract class IA<T> {
+ factory IA() = A<T>;
+ // ^
+ // [cfe] The type 'T' doesn't extend 'Foo'.
+ // ^
+ // [analyzer] COMPILE_TIME_ERROR.TYPE_ARGUMENT_NOT_MATCHING_BOUNDS
+}
+
+class A<T extends Foo> implements IA<T> {
+ factory A() { return A._(); }
+
+ A._();
+}
+
+main() {
+ var result = new IA<String>();
+ // ^
+ // [cfe] Type argument 'String' doesn't conform to the bound 'Foo' of the type variable 'T' on 'A'.
+}
diff --git a/tests/language/constructor/default_factory3_test.dart b/tests/language/constructor/default_factory3_test.dart
new file mode 100644
index 0000000..58d89b9
--- /dev/null
+++ b/tests/language/constructor/default_factory3_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check possibly still unresolved upper bounds of default factory class.
+
+abstract class A<T extends Foo> {
+ factory A() = _AImpl<T>;
+}
+
+class Moo extends Foo {}
+
+class Foo extends Bar {}
+
+class Bar {}
+
+class _AImpl<T extends Foo> implements A<T> {
+ factory _AImpl() { return _AImpl._(); }
+
+ _AImpl._();
+}
+
+main() {
+ var result = new A<Moo>();
+}
diff --git a/tests/language/constructor/default_factory_library.dart b/tests/language/constructor/default_factory_library.dart
new file mode 100644
index 0000000..a7cd293
--- /dev/null
+++ b/tests/language/constructor/default_factory_library.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Dart test program for testing default factories defined across libraries
+
+library lib;
+
+import "default_factory_library_test.dart" as test;
+
+// References a factory class in another library
+abstract class A {
+ factory A() = test.C.A;
+ int methodA();
+}
diff --git a/tests/language/constructor/default_factory_library_test.dart b/tests/language/constructor/default_factory_library_test.dart
new file mode 100644
index 0000000..d141456
--- /dev/null
+++ b/tests/language/constructor/default_factory_library_test.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Dart test program for testing factories defined across libraries
+
+library test;
+
+import "package:expect/expect.dart";
+import "default_factory_library.dart" as lib;
+
+class B implements lib.A, C {
+ int methodA() {
+ return 1;
+ }
+
+ int methodB() {
+ return 2;
+ }
+}
+
+abstract class C implements lib.A {
+ // Referenced from an abstract class in another library
+ factory C.A() {
+ return new B();
+ }
+}
+
+main() {
+ dynamic val = new lib.A();
+ Expect.equals(true, (val is B));
+ Expect.equals(1, val.methodA());
+ Expect.equals(2, val.methodB());
+}
diff --git a/tests/language/constructor/default_factory_runtime_test.dart b/tests/language/constructor/default_factory_runtime_test.dart
new file mode 100644
index 0000000..a12c7e5
--- /dev/null
+++ b/tests/language/constructor/default_factory_runtime_test.dart
@@ -0,0 +1,38 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Dart test program for testing default factories.
+
+abstract class Vehicle {
+
+}
+
+class Bike implements Vehicle, GoogleOne {
+ Bike.redOne() {}
+}
+
+abstract class SpaceShip {
+ factory SpaceShip() = GoogleOne;
+}
+
+class GoogleOne implements SpaceShip {
+ GoogleOne.internal_() {}
+ factory GoogleOne() {
+ return new GoogleOne.internal_();
+ }
+ factory GoogleOne.Vehicle() {
+ return new Bike.redOne();
+ }
+}
+
+main() {
+ Expect.equals(true, (new Bike.redOne()) is Bike);
+ Expect.equals(true, (new SpaceShip()) is GoogleOne);
+
+}
diff --git a/tests/language/constructor/default_factory_test.dart b/tests/language/constructor/default_factory_test.dart
new file mode 100644
index 0000000..43a93e8
--- /dev/null
+++ b/tests/language/constructor/default_factory_test.dart
@@ -0,0 +1,38 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Dart test program for testing default factories.
+
+abstract class Vehicle {
+ factory Vehicle() = GoogleOne.Vehicle;
+ // ^^^^^^^^^^^^^^^^^
+ // [analyzer] STATIC_WARNING.REDIRECT_TO_INVALID_RETURN_TYPE
+ // [cfe] The constructor function type 'GoogleOne Function()' isn't a subtype of 'Vehicle Function()'.
+}
+
+class Bike implements Vehicle, GoogleOne {
+ Bike.redOne() {}
+}
+
+abstract class SpaceShip {
+ factory SpaceShip() = GoogleOne;
+}
+
+class GoogleOne implements SpaceShip {
+ GoogleOne.internal_() {}
+ factory GoogleOne() {
+ return new GoogleOne.internal_();
+ }
+ factory GoogleOne.Vehicle() {
+ return new Bike.redOne();
+ }
+}
+
+main() {
+ Expect.equals(true, (new Bike.redOne()) is Bike);
+ Expect.equals(true, (new SpaceShip()) is GoogleOne);
+ var ensureItsCalled = new Vehicle();
+}
diff --git a/tests/language/constructor/default_test.dart b/tests/language/constructor/default_test.dart
new file mode 100644
index 0000000..aae9c52
--- /dev/null
+++ b/tests/language/constructor/default_test.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for default constructors.
+
+import "package:expect/expect.dart";
+
+class A {
+ A() : a = 499;
+
+ var a;
+}
+
+class B extends A {
+ B() {
+ Expect.equals(499, a);
+ }
+}
+
+main() {
+ new B();
+}
diff --git a/tests/language/constructor/duplicate_final_test.dart b/tests/language/constructor/duplicate_final_test.dart
new file mode 100644
index 0000000..96c1d22
--- /dev/null
+++ b/tests/language/constructor/duplicate_final_test.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Check that duplicate initialization of a final field is a runtime error.
+
+class Class {
+ final f = 10;
+
+ Class(v) : f = v; //# 01: compile-time error
+
+ Class(this.f); //# 02: compile-time error
+
+ // If a field is initialized multiple times in the initializer
+ // list, it's a compile time error.
+ Class(this.f) : f = 0; //# 03: compile-time error
+}
+
+main() {
+ new Class(5); //# 01: continued
+ new Class(5); //# 02: continued
+ new Class(5); //# 03: continued
+}
diff --git a/tests/language/constructor/duplicate_initializers_runtime_test.dart b/tests/language/constructor/duplicate_initializers_runtime_test.dart
new file mode 100644
index 0000000..94a3466
--- /dev/null
+++ b/tests/language/constructor/duplicate_initializers_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Check that initializers are not duplicated
+
+ class Class {
+ Class(var v) : field_ = v
+ // Test against duplicate final field initialization in initializing list.
+
+ ;
+ Class.field(this.field_)
+ // Test against duplicate final field initialization between initializing
+ // formals and initializer list.
+
+ ;
+ // Test against duplicate final field initialization in initializing formals.
+ Class.two_fields(this.field_
+
+ );
+ final field_;
+ }
+
+ main() {
+ new Class(42);
+ new Class.field(42);
+ new Class.two_fields(42
+
+ );
+ }
diff --git a/tests/language/constructor/duplicate_initializers_test.dart b/tests/language/constructor/duplicate_initializers_test.dart
new file mode 100644
index 0000000..1b4125a
--- /dev/null
+++ b/tests/language/constructor/duplicate_initializers_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Check that initializers are not duplicated
+
+ class Class {
+ Class(var v) : field_ = v
+ // Test against duplicate final field initialization in initializing list.
+ , field_ = 2
+ //^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZED_BY_MULTIPLE_INITIALIZERS
+ // ^
+ // [cfe] 'field_' is a final instance variable that has already been initialized.
+ ;
+ Class.field(this.field_)
+ // Test against duplicate final field initialization between initializing
+ // formals and initializer list.
+ : field_ = 2
+ //^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZED_IN_PARAMETER_AND_INITIALIZER
+ // ^
+ // [cfe] 'field_' is a final instance variable that has already been initialized.
+ ;
+ // Test against duplicate final field initialization in initializing formals.
+ Class.two_fields(this.field_
+ , this.field_
+ // ^^^^^^
+ // [cfe] 'field_' is a final instance variable that has already been initialized.
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FINAL_INITIALIZED_MULTIPLE_TIMES
+ // [cfe] Duplicated parameter name 'field_'.
+ );
+ final field_;
+ }
+
+ main() {
+ new Class(42);
+ new Class.field(42);
+ new Class.two_fields(42
+ , 42
+ );
+ }
diff --git a/tests/language/constructor/duplicate_runtime_test.dart b/tests/language/constructor/duplicate_runtime_test.dart
new file mode 100644
index 0000000..c65bc41
--- /dev/null
+++ b/tests/language/constructor/duplicate_runtime_test.dart
@@ -0,0 +1,15 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo {
+ Foo();
+
+}
+
+main() {
+ new Foo();
+}
diff --git a/tests/language/constructor/duplicate_test.dart b/tests/language/constructor/duplicate_test.dart
new file mode 100644
index 0000000..80f717e
--- /dev/null
+++ b/tests/language/constructor/duplicate_test.dart
@@ -0,0 +1,17 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo {
+ Foo();
+ Foo();
+//^^^
+// [analyzer] COMPILE_TIME_ERROR.DUPLICATE_CONSTRUCTOR
+// [cfe] 'Foo' is already declared in this scope.
+}
+
+main() {
+ new Foo();
+ // ^
+ // [cfe] Can't use 'Foo' because it is declared more than once.
+}
diff --git a/tests/language/constructor/evaluation_redirecting_constructor_test.dart b/tests/language/constructor/evaluation_redirecting_constructor_test.dart
new file mode 100644
index 0000000..6236c0a
--- /dev/null
+++ b/tests/language/constructor/evaluation_redirecting_constructor_test.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+int counter = 0;
+
+class Bar {
+ Bar() {
+ counter++;
+ }
+}
+
+class A {
+ var _bar = new Bar();
+ A() : this._();
+ A._() {
+ () => 42;
+ }
+}
+
+main() {
+ new A();
+ Expect.equals(1, counter);
+}
diff --git a/tests/language/constructor/example_constructor_test.dart b/tests/language/constructor/example_constructor_test.dart
new file mode 100644
index 0000000..f015b07
--- /dev/null
+++ b/tests/language/constructor/example_constructor_test.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test for testing order of constructor invocation.
+
+import "package:expect/expect.dart";
+
+var trace = "";
+
+int rec(int i) {
+ trace += "$i ";
+ return i;
+}
+
+class A {
+ A(int x) : x = rec(4) {
+ Expect.equals(3, x); // Parameter x
+ Expect.equals(4, this.x);
+ rec(5);
+ }
+ final int x;
+}
+
+class B extends A {
+ B(this.a, int y, int z)
+ : z = rec(1),
+ y = rec(2),
+ super(rec(3)) {
+ rec(6);
+ }
+ int a;
+ int y;
+ int z;
+}
+
+main() {
+ var test = new B(rec(0), 0, 0);
+ Expect.equals(0, test.a);
+ Expect.equals(4, test.x);
+ Expect.equals(2, test.y);
+ Expect.equals(1, test.z);
+ Expect.equals("0 1 2 3 4 5 6 ", trace);
+}
diff --git a/tests/language/constructor/forwarding_factory_constructor_default_values_test.dart b/tests/language/constructor/forwarding_factory_constructor_default_values_test.dart
new file mode 100644
index 0000000..70738fe
--- /dev/null
+++ b/tests/language/constructor/forwarding_factory_constructor_default_values_test.dart
@@ -0,0 +1,29 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for dart2js bug 18257: Properly infer types for forwarding
+// factory constructors with optional parameters with default values.
+
+main() {
+ A a = new A.a1();
+ a.test();
+}
+
+class A {
+ final bool condition;
+
+ A({this.condition: true});
+
+ factory A.a1({condition}) = _A1.boo;
+
+ test() {
+ if (condition != true) {
+ throw "FAILED";
+ }
+ }
+}
+
+class _A1 extends A {
+ _A1.boo({condition: true}) : super(condition: condition);
+}
diff --git a/tests/language/constructor/implicit_super_constructor_call_test.dart b/tests/language/constructor/implicit_super_constructor_call_test.dart
new file mode 100644
index 0000000..fca1a62
--- /dev/null
+++ b/tests/language/constructor/implicit_super_constructor_call_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// This is a regression test for http://dartbug.com/22723.
+
+import "package:expect/expect.dart";
+
+class A {
+ final x;
+
+ @pragma('dart2js:noInline')
+ A({this.x: "foo"}) {
+ Expect.equals("foo", x.toString());
+ }
+}
+
+class C extends A {
+ C(foobar) {}
+}
+
+main() {
+ var c = new C(499);
+ Expect.equals("foo", c.x.toString());
+}
diff --git a/tests/language/constructor/implicit_super_constructor_test.dart b/tests/language/constructor/implicit_super_constructor_test.dart
new file mode 100644
index 0000000..2c31206
--- /dev/null
+++ b/tests/language/constructor/implicit_super_constructor_test.dart
@@ -0,0 +1,20 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+abstract class A {
+ int _x = 42;
+}
+
+abstract class B extends A {}
+
+class C extends B {
+ C() {}
+}
+
+main() {
+ // Regression test for https://github.com/dart-lang/sdk/issues/27421
+ Expect.equals(new C()._x, 42);
+}
diff --git a/tests/language/constructor/inference_super_constructor_call_test.dart b/tests/language/constructor/inference_super_constructor_call_test.dart
new file mode 100644
index 0000000..a95c185
--- /dev/null
+++ b/tests/language/constructor/inference_super_constructor_call_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Regression test for dart2js's inferrer that used to not propagate
+// types given to generative constructors in super constructor calls.
+
+import "package:expect/expect.dart";
+
+class A {
+ final field;
+ A.full(this.field);
+}
+
+class B extends A {
+ // The following super call used to not be analyzed properly.
+ B.full(field) : super.full(field);
+}
+
+main() {
+ // Call [A.full] with an int to have the inferrer think [field] is
+ // always an int.
+ Expect.equals(84, new A.full(42).field + 42);
+ Expect.throwsNoSuchMethodError(() => new B.full(null).field + 42,);
+}
diff --git a/tests/language/constructor/initializer_test.dart b/tests/language/constructor/initializer_test.dart
new file mode 100644
index 0000000..4204885
--- /dev/null
+++ b/tests/language/constructor/initializer_test.dart
@@ -0,0 +1,43 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+class A {
+ var _x, _y;
+ A(x, [y = 10])
+ : _x = x++,
+ _y = y++ {
+ // Check that value of modified constructor parameters
+ // is remembered in the constructor body.
+ Expect.equals(x, _x + 1);
+ Expect.equals(y, _y + 1);
+ }
+}
+
+class B extends A {
+ var _a, _b;
+ // The super call in the middle of the initializer list conceptually
+ // forces two super call chains, one for initializer list and a second
+ // one for the constructor bodies.
+ B(a, b)
+ : _a = a++,
+ _b = b++,
+ super(a + b++) {
+ Expect.equals(a, _a + 1);
+ Expect.equals(b, _b + 2);
+ Expect.equals(a + (b - 2), _x - 1);
+ }
+}
+
+main() {
+ dynamic o = new B(3, 5);
+ Expect.equals(3, o._a);
+ Expect.equals(5, o._b);
+ Expect.equals(10, o._x);
+ Expect.equals(10, o._y);
+ o = new A(3);
+ Expect.equals(3, o._x);
+ Expect.equals(10, o._y);
+}
diff --git a/tests/language/constructor/missing_const_constructor_test.dart b/tests/language/constructor/missing_const_constructor_test.dart
new file mode 100644
index 0000000..123eccf
--- /dev/null
+++ b/tests/language/constructor/missing_const_constructor_test.dart
@@ -0,0 +1,27 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test handling of unknown constructor in const expression.
+
+class GoodClass {
+ const GoodClass();
+}
+
+GoodClass? GOOD_CLASS
+ = const GoodClass() //# 01: ok
+ = const GoodClass.BAD_NAME() //# 02: compile-time error
+ = const GoodClass("bad arg") //# 03: compile-time error
+ ;
+
+const BadClass BAD_CLASS = const BadClass(); //# 04: compile-time error
+BadClass BAD_CLASS = const BadClass(); //# 05: compile-time error
+
+void main() {
+ try {
+ print(GOOD_CLASS);
+ print(BAD_CLASS); //# 04: continued
+ print(BAD_CLASS); //# 05: continued
+ print(const BadClass()); //# 06: compile-time error
+ } catch (e) {}
+}
diff --git a/tests/language/constructor/multiple_field_assignment_constructor_test.dart b/tests/language/constructor/multiple_field_assignment_constructor_test.dart
new file mode 100644
index 0000000..7292e80
--- /dev/null
+++ b/tests/language/constructor/multiple_field_assignment_constructor_test.dart
@@ -0,0 +1,52 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+import "../compiler_annotations.dart";
+
+var a = [null];
+
+class A {
+ var foo;
+ var bar;
+
+ @DontInline()
+ A() {
+ // Currently defeat inlining by using a closure.
+ bar = () => 42;
+ foo = 42;
+ foo = a[0];
+ }
+}
+
+class B {
+ var foo;
+ var bar;
+
+ @DontInline()
+ B() {
+ // Currently defeat inlining by using a closure.
+ bar = () => 42;
+ foo = 42;
+ foo = a[0];
+ if (false) foo = 42;
+ }
+}
+
+main() {
+ // Surround the call to [bar] by allocations of [A] and [B] to
+ // ensure their constructors get analyzed first.
+ new A();
+ new B();
+ bar();
+ new A();
+ new B();
+}
+
+@DontInline()
+bar() {
+ // Currently defeat inlining by using a closure.
+ Expect.throwsNoSuchMethodError(() => new A().foo + 42);
+ Expect.throwsNoSuchMethodError(() => new B().foo + 42);
+}
diff --git a/tests/language/constructor/name_clash_lib.dart b/tests/language/constructor/name_clash_lib.dart
new file mode 100644
index 0000000..ff52f3b
--- /dev/null
+++ b/tests/language/constructor/name_clash_lib.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library lib;
+
+var global = 0;
+
+class A {
+ A() {
+ global += 10;
+ try {} catch (e) {} // no inline
+ }
+}
diff --git a/tests/language/constructor/name_clash_test.dart b/tests/language/constructor/name_clash_test.dart
new file mode 100644
index 0000000..e7681ef
--- /dev/null
+++ b/tests/language/constructor/name_clash_test.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:expect/expect.dart';
+import 'name_clash_lib.dart' as lib;
+
+class A extends lib.A {
+ A() {
+ lib.global += 100;
+ try {} catch (e) {} // no inline
+ }
+}
+
+main() {
+ new A();
+ Expect.equals(110, lib.global);
+}
diff --git a/tests/language/constructor/name_test.dart b/tests/language/constructor/name_test.dart
new file mode 100644
index 0000000..43e764f
--- /dev/null
+++ b/tests/language/constructor/name_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo {
+ Bar.Foo(); //# 01: compile-time error
+ factory Bar(); //# 02: syntax error
+ factory Bar.Baz(); //# 03: syntax error
+}
+
+void main() {
+ new Foo();
+ new Foo.Foo(); //# 01: continued
+ new Foo.Baz(); //# 03: continued
+}
diff --git a/tests/language/constructor/named_arguments_test.dart b/tests/language/constructor/named_arguments_test.dart
new file mode 100644
index 0000000..854ae04
--- /dev/null
+++ b/tests/language/constructor/named_arguments_test.dart
@@ -0,0 +1,57 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for default constructors.
+
+import "package:expect/expect.dart";
+
+late String message;
+
+foo() {
+ message += 'foo';
+ return 1;
+}
+
+bar() {
+ message += 'bar';
+ return 2;
+}
+
+class X {
+ var i;
+ var j;
+ X({a: 'defa', b: 'defb'})
+ : this.i = a,
+ this.j = b;
+ X.foo() : this(b: 1, a: 2);
+ X.bar()
+ : this(
+ 1, // //# 01: compile-time error, runtime error
+ a: 2);
+ X.baz() : this(a: 1, b: 2);
+ X.qux() : this(b: 2);
+ X.hest() : this();
+ X.fisk() : this(b: bar(), a: foo());
+ X.naebdyr() : this(a: foo(), b: bar());
+}
+
+test(x, a, b) {
+ Expect.equals(x.i, a);
+ Expect.equals(x.j, b);
+}
+
+main() {
+ test(new X.foo(), 2, 1);
+ test(new X.bar(), 2, 'defb');
+ test(new X.baz(), 1, 2);
+ test(new X.qux(), 'defa', 2);
+ test(new X.hest(), 'defa', 'defb');
+
+ message = '';
+ new X.fisk();
+ Expect.equals('barfoo', message);
+
+ message = '';
+ new X.naebdyr();
+ Expect.equals('foobar', message);
+}
diff --git a/tests/language/constructor/named_constructor_test.dart b/tests/language/constructor/named_constructor_test.dart
new file mode 100644
index 0000000..915f147
--- /dev/null
+++ b/tests/language/constructor/named_constructor_test.dart
@@ -0,0 +1,104 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library named_constructor_test;
+
+import 'package:expect/expect.dart';
+import 'named_lib.dart' as prefix;
+
+class Class<T> {
+ final int value;
+ Class() : value = 0;
+ Class.named() : value = 1;
+}
+
+void main() {
+ Expect.equals(0, new Class().value);
+ Expect.equals(0, new Class<int>().value);
+
+ Expect.equals(1, new Class.named().value);
+ Expect.equals(1, new Class<int>.named().value);
+ // 'Class.named' is not a type:
+ new Class.named<int>().value;
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+
+ // 'Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+ new Class<int>.named<int>().value;
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+
+ new prefix.Class().value;
+ // 'prefix' is not a type:
+ new prefix<int>.Class().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ new prefix.Class<int>().value;
+ // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id:
+ new prefix<int>.Class<int>().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+
+ new prefix.Class.named().value;
+ // 'prefix<int>.Class.named' doesn't fit the grammar syntax T.id:
+ new prefix<int>.Class.named().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+
+
+ // 'prefix.Class<int>.named' doesn't fit the grammar syntax T.id:
+ new prefix.Class<int>.named().value;
+ // 'prefix.Class.named<int>' doesn't fit the grammar syntax T.id:
+ new prefix.Class.named<int>().value;
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+
+ // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id:
+ new prefix<int>.Class<int>.named().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+
+
+ // 'prefix<int>.Class.named<int>' doesn't fit the grammar syntax T.id:
+ new prefix<int>.Class.named<int>().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+
+
+ // 'prefix.Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+ new prefix.Class<int>.named<int>().value;
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+
+ // 'prefix<int>.Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+ new prefix<int>.Class<int>.named<int>().value;
+ // ^^^^^^
+ // [analyzer] STATIC_WARNING.NEW_WITH_NON_TYPE
+ // [cfe] Method not found: 'prefix.Class'.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+}
diff --git a/tests/language/constructor/named_lib.dart b/tests/language/constructor/named_lib.dart
new file mode 100644
index 0000000..210d54c
--- /dev/null
+++ b/tests/language/constructor/named_lib.dart
@@ -0,0 +1,11 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library named_constructor_lib;
+
+class Class<T> {
+ final int value;
+ Class() : value = 2;
+ Class.named() : value = 3;
+}
diff --git a/tests/language/constructor/named_runtime_test.dart b/tests/language/constructor/named_runtime_test.dart
new file mode 100644
index 0000000..815b05b
--- /dev/null
+++ b/tests/language/constructor/named_runtime_test.dart
@@ -0,0 +1,52 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library named_constructor_test;
+
+import 'package:expect/expect.dart';
+import 'named_lib.dart' as prefix;
+
+class Class<T> {
+ final int value;
+ Class() : value = 0;
+ Class.named() : value = 1;
+}
+
+void main() {
+ Expect.equals(0, new Class().value);
+ Expect.equals(0, new Class<int>().value);
+
+ Expect.equals(1, new Class.named().value);
+ Expect.equals(1, new Class<int>.named().value);
+ // 'Class.named' is not a type:
+
+ // 'Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+
+
+ new prefix.Class().value;
+ // 'prefix' is not a type:
+
+ new prefix.Class<int>().value;
+ // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id:
+
+
+ new prefix.Class.named().value;
+ // 'prefix<int>.Class.named' doesn't fit the grammar syntax T.id:
+
+ // 'prefix.Class<int>.named' doesn't fit the grammar syntax T.id:
+ new prefix.Class<int>.named().value;
+ // 'prefix.Class.named<int>' doesn't fit the grammar syntax T.id:
+
+ // 'prefix<int>.Class<int>' doesn't fit the grammar syntax T.id:
+
+ // 'prefix<int>.Class.named<int>' doesn't fit the grammar syntax T.id:
+
+ // 'prefix.Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+
+ // 'prefix<int>.Class<int>.named<int>' doesn't fit the grammar syntax T.id:
+
+}
diff --git a/tests/language/constructor/no_such_constructor_runtime_test.dart b/tests/language/constructor/no_such_constructor_runtime_test.dart
new file mode 100644
index 0000000..17ee996
--- /dev/null
+++ b/tests/language/constructor/no_such_constructor_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+ A();
+}
+
+main() {
+
+}
diff --git a/tests/language/constructor/no_such_constructor_test.dart b/tests/language/constructor/no_such_constructor_test.dart
new file mode 100644
index 0000000..b106273
--- /dev/null
+++ b/tests/language/constructor/no_such_constructor_test.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+ A();
+}
+
+main() {
+ new A(42);
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 0 allowed, but 1 found.
+}
diff --git a/tests/language/constructor/non_const_constructor_without_body_test.dart b/tests/language/constructor/non_const_constructor_without_body_test.dart
new file mode 100644
index 0000000..cd2005a
--- /dev/null
+++ b/tests/language/constructor/non_const_constructor_without_body_test.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+class NonConstConstructorWithoutBodyTest {
+ int x = -1;
+
+ NonConstConstructorWithoutBodyTest();
+ NonConstConstructorWithoutBodyTest.named();
+ NonConstConstructorWithoutBodyTest.initializers() : x = 1;
+ NonConstConstructorWithoutBodyTest.parameters(int x) : x = x + 1;
+ NonConstConstructorWithoutBodyTest.fieldParameter(int this.x);
+ NonConstConstructorWithoutBodyTest.redirection() : this.initializers();
+
+ static testMain() {
+ Expect.equals(-1, new NonConstConstructorWithoutBodyTest().x);
+ Expect.equals(-1, new NonConstConstructorWithoutBodyTest.named().x);
+ Expect.equals(1, new NonConstConstructorWithoutBodyTest.initializers().x);
+ Expect.equals(2, new NonConstConstructorWithoutBodyTest.parameters(1).x);
+ Expect.equals(
+ 2, new NonConstConstructorWithoutBodyTest.fieldParameter(2).x);
+ Expect.equals(1, new NonConstConstructorWithoutBodyTest.redirection().x);
+ }
+}
+
+main() {
+ NonConstConstructorWithoutBodyTest.testMain();
+}
diff --git a/tests/language/constructor/non_parameterized_factory2_test.dart b/tests/language/constructor/non_parameterized_factory2_test.dart
new file mode 100644
index 0000000..2833d06
--- /dev/null
+++ b/tests/language/constructor/non_parameterized_factory2_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+abstract class Interface<T> {
+ factory Interface() = Factory<T>;
+ factory Interface.withArg(T value) = Factory<T>.withArg;
+}
+
+class Factory<T> implements Interface<T> {
+ factory Factory() {
+ return Factory._();
+ }
+
+ factory Factory.withArg(T value) {
+ return Factory._();
+ }
+
+ Factory._();
+}
+
+main() {
+ new Interface<int>();
+ new Interface<int>.withArg(4);
+}
diff --git a/tests/language/constructor/non_parameterized_factory_test.dart b/tests/language/constructor/non_parameterized_factory_test.dart
new file mode 100644
index 0000000..36cd6aa
--- /dev/null
+++ b/tests/language/constructor/non_parameterized_factory_test.dart
@@ -0,0 +1,25 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+abstract class Interface<T> {
+ factory Interface() = Factory<T>;
+ factory Interface.withArg(T value) = Factory<T>.withArg;
+}
+
+class Factory<T> implements Interface<T> {
+ factory Factory() {
+ return Factory._();
+ }
+
+ factory Factory.withArg(T value) {
+ return Factory._();
+ }
+
+ Factory._();
+}
+
+main() {
+ new Interface();
+ new Interface.withArg(4);
+}
diff --git a/tests/language/constructor/redirect2_runtime_test.dart b/tests/language/constructor/redirect2_runtime_test.dart
new file mode 100644
index 0000000..f5216f6
--- /dev/null
+++ b/tests/language/constructor/redirect2_runtime_test.dart
@@ -0,0 +1,32 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Redirection constructors must not have a function body.
+
+class A {
+ var x;
+ A(this.x) {}
+
+ // Redirecting constructor must not have a function body.
+
+
+ // Redirecting constructor must not initialize any fields.
+
+
+ // Redirecting constructor must not have initializing formal parameters.
+
+
+ // Redirection constructors must not call super constructor.
+
+}
+
+main() {
+ new A(3);
+
+
+
+
+}
diff --git a/tests/language/constructor/redirect2_test.dart b/tests/language/constructor/redirect2_test.dart
new file mode 100644
index 0000000..0999747
--- /dev/null
+++ b/tests/language/constructor/redirect2_test.dart
@@ -0,0 +1,46 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Redirection constructors must not have a function body.
+
+class A {
+ var x;
+ A(this.x) {}
+
+ // Redirecting constructor must not have a function body.
+ A.illegalBody(x) : this(3) {}
+ // ^
+ // [analyzer] SYNTACTIC_ERROR.REDIRECTING_CONSTRUCTOR_WITH_BODY
+ // [cfe] Redirecting constructors can't have a body.
+
+ // Redirecting constructor must not initialize any fields.
+ A.illegalInit() : this(3), x = 5;
+ // ^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
+ // ^
+ // [cfe] Can't have other initializers together with 'this'.
+
+ // Redirecting constructor must not have initializing formal parameters.
+ A.illegalFormal(this.x) : this(3);
+ // ^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.FIELD_INITIALIZER_REDIRECTING_CONSTRUCTOR
+ // ^
+ // [cfe] Can't have other initializers together with 'this'.
+
+ // Redirection constructors must not call super constructor.
+ A.illegalSuper() : this(3), super(3);
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.SUPER_IN_REDIRECTING_CONSTRUCTOR
+ // [cfe] Can't have other initializers together with 'this'.
+ // ^^^
+ // [analyzer] COMPILE_TIME_ERROR.EXTRA_POSITIONAL_ARGUMENTS
+ // [cfe] Too many positional arguments: 0 allowed, but 1 found.
+}
+
+main() {
+ new A(3);
+ new A.illegalBody(10);
+ new A.illegalInit();
+ new A.illegalFormal(10);
+ new A.illegalSuper();
+}
diff --git a/tests/language/constructor/redirect_cycle_runtime_test.dart b/tests/language/constructor/redirect_cycle_runtime_test.dart
new file mode 100644
index 0000000..4a05857
--- /dev/null
+++ b/tests/language/constructor/redirect_cycle_runtime_test.dart
@@ -0,0 +1,18 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Redirection constructors must not be cyclic.
+
+class A {
+ var x;
+ A(x)
+
+ ;
+}
+
+main() {
+ new A(10);
+}
diff --git a/tests/language/constructor/redirect_cycle_test.dart b/tests/language/constructor/redirect_cycle_test.dart
new file mode 100644
index 0000000..6730e06
--- /dev/null
+++ b/tests/language/constructor/redirect_cycle_test.dart
@@ -0,0 +1,18 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Redirection constructors must not be cyclic.
+
+class A {
+ var x;
+ A(x)
+ : this(0)
+ //^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
+ // [cfe] Redirecting constructors can't be cyclic.
+ ;
+}
+
+main() {
+ new A(10);
+}
diff --git a/tests/language/constructor/redirect_indirect_cycle_runtime_test.dart b/tests/language/constructor/redirect_indirect_cycle_runtime_test.dart
new file mode 100644
index 0000000..94159a5
--- /dev/null
+++ b/tests/language/constructor/redirect_indirect_cycle_runtime_test.dart
@@ -0,0 +1,19 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+ var x;
+ A(x) : this.named(x, 0);
+ A.named(x, int y)
+ // Redirecting constructors must not be cyclic.
+
+ ;
+}
+
+main() {
+ new A(10);
+}
diff --git a/tests/language/constructor/redirect_indirect_cycle_test.dart b/tests/language/constructor/redirect_indirect_cycle_test.dart
new file mode 100644
index 0000000..aa2bb69
--- /dev/null
+++ b/tests/language/constructor/redirect_indirect_cycle_test.dart
@@ -0,0 +1,21 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class A {
+ var x;
+ A(x) : this.named(x, 0);
+ // ^^^^^^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
+ A.named(x, int y)
+ // Redirecting constructors must not be cyclic.
+ : this(x + y)
+ //^^^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RECURSIVE_CONSTRUCTOR_REDIRECT
+ // [cfe] Redirecting constructors can't be cyclic.
+ ;
+}
+
+main() {
+ new A(10);
+}
diff --git a/tests/language/constructor/redirect_runtime_test.dart b/tests/language/constructor/redirect_runtime_test.dart
new file mode 100644
index 0000000..f6084b8
--- /dev/null
+++ b/tests/language/constructor/redirect_runtime_test.dart
@@ -0,0 +1,75 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for redirection constructors.
+
+import "package:expect/expect.dart";
+
+class A {
+ var x;
+ A(this.x) {}
+ A.named(x, int y) : this(x + y);
+ A.named2(int x, int y, z) : this.named(staticFun(x, y), z);
+
+ // The following is a bit tricky. It is a compile-time error to
+ // refer to this (implicitly or explicitly) from an initializer.
+ // When we remove the line with moreStaticFun, staticFun is really a
+ // static function and it is legal to call it. This is what will
+ // happen in the /none version of this test. However, in /01,
+ // staticFun isn't really a static function and should cause a
+ // compile-time error.
+ static
+
+ int staticFun(int v1, int v2) {
+ return v1 * v2;
+ }
+}
+
+class B extends A {
+ B(y) : super(y + 1) {}
+ B.named(y) : super.named(y, y + 1) {}
+}
+
+class C {
+ final x;
+ const C(this.x);
+ const C.named(x, int y) : this(x + y);
+}
+
+class D extends C {
+ const D(y) : super(y + 1);
+ const D.named(y) : super.named(y, y + 1);
+}
+
+class ConstructorRedirectTest {
+ static testMain() {
+ var a = new A(499);
+ Expect.equals(499, a.x);
+ a = new A.named(349, 499);
+ Expect.equals(349 + 499, a.x);
+ a = new A.named2(11, 42, 99);
+ Expect.equals(11 * 42 + 99, a.x);
+
+ var b = new B(498);
+ Expect.equals(499, b.x);
+ b = new B.named(249);
+ Expect.equals(499, b.x);
+
+ C c = const C(499);
+ Expect.equals(499, c.x);
+ c = const C.named(249, 250);
+ Expect.equals(499, c.x);
+
+ D d = const D(498);
+ Expect.equals(499, d.x);
+ d = const D.named(249);
+ Expect.equals(499, d.x);
+ }
+}
+
+main() {
+ ConstructorRedirectTest.testMain();
+}
diff --git a/tests/language/constructor/redirect_test.dart b/tests/language/constructor/redirect_test.dart
new file mode 100644
index 0000000..0f1ee3a
--- /dev/null
+++ b/tests/language/constructor/redirect_test.dart
@@ -0,0 +1,75 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Dart test program for redirection constructors.
+
+import "package:expect/expect.dart";
+
+class A {
+ var x;
+ A(this.x) {}
+ A.named(x, int y) : this(x + y);
+ A.named2(int x, int y, z) : this.named(staticFun(x, y), z);
+ // ^^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.IMPLICIT_THIS_REFERENCE_IN_INITIALIZER
+ // [cfe] Can't access 'this' in a field initializer to read 'staticFun'.
+
+ // The following is a bit tricky. It is a compile-time error to
+ // refer to this (implicitly or explicitly) from an initializer.
+ // When we remove the line with moreStaticFun, staticFun is really a
+ // static function and it is legal to call it. This is what will
+ // happen in the /none version of this test. However, in /01,
+ // staticFun isn't really a static function and should cause a
+ // compile-time error.
+ static
+ moreStaticFun() {}
+ int staticFun(int v1, int v2) {
+ return v1 * v2;
+ }
+}
+
+class B extends A {
+ B(y) : super(y + 1) {}
+ B.named(y) : super.named(y, y + 1) {}
+}
+
+class C {
+ final x;
+ const C(this.x);
+ const C.named(x, int y) : this(x + y);
+}
+
+class D extends C {
+ const D(y) : super(y + 1);
+ const D.named(y) : super.named(y, y + 1);
+}
+
+class ConstructorRedirectTest {
+ static testMain() {
+ var a = new A(499);
+ Expect.equals(499, a.x);
+ a = new A.named(349, 499);
+ Expect.equals(349 + 499, a.x);
+ a = new A.named2(11, 42, 99);
+ Expect.equals(11 * 42 + 99, a.x);
+
+ var b = new B(498);
+ Expect.equals(499, b.x);
+ b = new B.named(249);
+ Expect.equals(499, b.x);
+
+ C c = const C(499);
+ Expect.equals(499, c.x);
+ c = const C.named(249, 250);
+ Expect.equals(499, c.x);
+
+ D d = const D(498);
+ Expect.equals(499, d.x);
+ d = const D.named(249);
+ Expect.equals(499, d.x);
+ }
+}
+
+main() {
+ ConstructorRedirectTest.testMain();
+}
diff --git a/tests/language/constructor/reference_runtime_10_test.dart b/tests/language/constructor/reference_runtime_10_test.dart
new file mode 100644
index 0000000..b96d8f9
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_10_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Foo.bar();
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_11_test.dart b/tests/language/constructor/reference_runtime_11_test.dart
new file mode 100644
index 0000000..cea554d
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_11_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Foo<int>();
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_12_test.dart b/tests/language/constructor/reference_runtime_12_test.dart
new file mode 100644
index 0000000..5b58eae
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_12_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Foo<int>.bar();
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_1_test.dart b/tests/language/constructor/reference_runtime_1_test.dart
new file mode 100644
index 0000000..450bc7f
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_1_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+ new Foo();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_2_test.dart b/tests/language/constructor/reference_runtime_2_test.dart
new file mode 100644
index 0000000..cab730f
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_2_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+ new Foo.bar();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_3_test.dart b/tests/language/constructor/reference_runtime_3_test.dart
new file mode 100644
index 0000000..20ac3d2
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_3_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+ new Foo<int>();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_4_test.dart b/tests/language/constructor/reference_runtime_4_test.dart
new file mode 100644
index 0000000..e69fe77
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_4_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+ new Foo<int>.bar();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_5_test.dart b/tests/language/constructor/reference_runtime_5_test.dart
new file mode 100644
index 0000000..4dda061
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_5_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+ const Foo();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_6_test.dart b/tests/language/constructor/reference_runtime_6_test.dart
new file mode 100644
index 0000000..75859e0
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_6_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+ const Foo.bar();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_7_test.dart b/tests/language/constructor/reference_runtime_7_test.dart
new file mode 100644
index 0000000..b18721e
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_7_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const Foo<int>();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_8_test.dart b/tests/language/constructor/reference_runtime_8_test.dart
new file mode 100644
index 0000000..1493e34
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_8_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ const Foo<int>.bar();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_9_test.dart b/tests/language/constructor/reference_runtime_9_test.dart
new file mode 100644
index 0000000..cad70b0
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_9_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Foo();
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_runtime_test.dart b/tests/language/constructor/reference_runtime_test.dart
new file mode 100644
index 0000000..12b5314
--- /dev/null
+++ b/tests/language/constructor/reference_runtime_test.dart
@@ -0,0 +1,44 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
diff --git a/tests/language/constructor/reference_test.dart b/tests/language/constructor/reference_test.dart
new file mode 100644
index 0000000..52e1235
--- /dev/null
+++ b/tests/language/constructor/reference_test.dart
@@ -0,0 +1,117 @@
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo<X> {
+ const Foo();
+ const Foo.bar();
+ const Foo.baz();
+}
+
+main() {
+ new Foo();
+ new Foo.bar();
+ new Foo.bar.baz();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ new Foo<int>();
+ new Foo<int>.bar();
+ new Foo<int>.bar.baz();
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
+ new Foo.bar<int>();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ new Foo.bar<int>.baz();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ new Foo.bar.baz<int>();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+
+ const Foo();
+ const Foo.bar();
+ const Foo.bar.baz();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ const Foo<int>();
+ const Foo<int>.bar();
+ const Foo<int>.bar.baz();
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
+ const Foo.bar<int>();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ const Foo.bar<int>.baz();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ const Foo.bar.baz<int>();
+ // ^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.UNDEFINED_CLASS
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+
+ Foo();
+ Foo.bar();
+ Foo.bar.baz();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Getter not found: 'bar'.
+ Foo<int>();
+ Foo<int>.bar();
+ Foo<int>.bar.baz();
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.EXPECTED_TOKEN
+ // [cfe] Expected '(' after this.
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_METHOD
+ // [cfe] The method 'baz' isn't defined for the class 'Foo<int>'.
+ Foo.bar<int>();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ Foo.bar<int>.baz();
+ // ^
+ // [cfe] A constructor invocation can't have type arguments on the constructor name.
+ // ^^^^^
+ // [analyzer] STATIC_TYPE_WARNING.WRONG_NUMBER_OF_TYPE_ARGUMENTS_CONSTRUCTOR
+ // ^
+ // [cfe] Method not found: 'Foo.bar.baz'.
+ Foo.bar.baz<int>();
+ // ^^^
+ // [analyzer] STATIC_TYPE_WARNING.UNDEFINED_GETTER
+ // [cfe] Getter not found: 'bar'.
+}
diff --git a/tests/language/constructor/return_runtime_test.dart b/tests/language/constructor/return_runtime_test.dart
new file mode 100644
index 0000000..9c23cd9
--- /dev/null
+++ b/tests/language/constructor/return_runtime_test.dart
@@ -0,0 +1,47 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Dart spec 0.03, section 11.10 - generative constructors can only have return
+// statements in the form 'return;'.
+class A {
+ int x;
+ A(this.x) {
+ return;
+ }
+ A.test1(this.x) {
+
+ }
+ A.test2(this.x) {
+
+ }
+ int foo(int y) => x + y;
+}
+
+class B {
+
+}
+
+class C {
+ int value = -1;
+
+}
+
+class D {
+ int value = -1;
+
+}
+
+main() {
+ Expect.equals((new A(1)).foo(10), 11);
+ Expect.equals((new A.test1(1)).foo(10), 11);
+ Expect.equals((new A.test2(1)).foo(10), 11);
+ new B();
+ new C();
+ new D();
+}
diff --git a/tests/language/constructor/return_test.dart b/tests/language/constructor/return_test.dart
new file mode 100644
index 0000000..b20170e
--- /dev/null
+++ b/tests/language/constructor/return_test.dart
@@ -0,0 +1,68 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import "package:expect/expect.dart";
+
+// Dart spec 0.03, section 11.10 - generative constructors can only have return
+// statements in the form 'return;'.
+class A {
+ int x;
+ A(this.x) {
+ return;
+ }
+ A.test1(this.x) {
+ return this;
+// ^
+// [cfe] Constructors can't have a return type.
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
+ }
+ A.test2(this.x) {
+ return null;
+// ^
+// [cfe] Constructors can't have a return type.
+// ^^^^
+// [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
+ }
+ int foo(int y) => x + y;
+}
+
+class B {
+ B() => B._();
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
+ // ^
+ // [cfe] Constructors can't have a return type.
+
+ B._();
+}
+
+class C {
+ int value;
+ C() : value = 1 { return null; }
+ // ^
+ // [cfe] Constructors can't have a return type.
+ // ^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
+}
+
+class D {
+ int value = -1;
+ D(): value = 1 => D._();
+ // ^^^^^^^^
+ // [analyzer] COMPILE_TIME_ERROR.RETURN_IN_GENERATIVE_CONSTRUCTOR
+ // ^
+ // [cfe] Constructors can't have a return type.
+
+ D._();
+}
+
+main() {
+ Expect.equals((new A(1)).foo(10), 11);
+ Expect.equals((new A.test1(1)).foo(10), 11);
+ Expect.equals((new A.test2(1)).foo(10), 11);
+ new B();
+ new C();
+ new D();
+}
diff --git a/tests/language/constructor/setter_test.dart b/tests/language/constructor/setter_test.dart
new file mode 100644
index 0000000..bad56d3
--- /dev/null
+++ b/tests/language/constructor/setter_test.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+// Test that setters are not invokable in the initializer list.
+
+class A {
+ A() : a = 499; /*@compile-error=unspecified*/
+
+ set a(val) {}
+}
+
+main() {
+ new A();
+}
diff --git a/tests/language/constructor/type_parameter_runtime_test.dart b/tests/language/constructor/type_parameter_runtime_test.dart
new file mode 100644
index 0000000..6cb2a75
--- /dev/null
+++ b/tests/language/constructor/type_parameter_runtime_test.dart
@@ -0,0 +1,14 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo {
+
+}
+
+main() {
+ new Foo();
+}
diff --git a/tests/language/constructor/type_parameter_test.dart b/tests/language/constructor/type_parameter_test.dart
new file mode 100644
index 0000000..3712c26
--- /dev/null
+++ b/tests/language/constructor/type_parameter_test.dart
@@ -0,0 +1,14 @@
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Foo {
+ Foo<A>() {}
+ // ^^^
+ // [analyzer] SYNTACTIC_ERROR.TYPE_PARAMETER_ON_CONSTRUCTOR
+ // [cfe] Constructors can't have type parameters.
+}
+
+main() {
+ new Foo();
+}
diff --git a/tests/language/constructor/unresolved_default_constructor_test.dart b/tests/language/constructor/unresolved_default_constructor_test.dart
new file mode 100644
index 0000000..07fdc72
--- /dev/null
+++ b/tests/language/constructor/unresolved_default_constructor_test.dart
@@ -0,0 +1,20 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test unresolved default constructor calls cause compilation errors.
+
+import 'package:expect/expect.dart';
+
+class A {
+ A.named();
+ static method() {}
+}
+
+main() {
+ A.method();
+ Expect.throws(() => new A());
+ // ^
+ // [analyzer] STATIC_WARNING.NEW_WITH_UNDEFINED_CONSTRUCTOR_DEFAULT
+ // [cfe] Method not found: 'A'.
+}
diff --git a/tests/language/constructor/unresolved_default_runtime_test.dart b/tests/language/constructor/unresolved_default_runtime_test.dart
new file mode 100644
index 0000000..dd83067
--- /dev/null
+++ b/tests/language/constructor/unresolved_default_runtime_test.dart
@@ -0,0 +1,20 @@
+// TODO(multitest): This was automatically migrated from a multitest and may
+// contain strange or dead code.
+
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test unresolved default constructor calls cause compilation errors.
+
+import 'package:expect/expect.dart';
+
+class A {
+ A.named();
+ static method() {}
+}
+
+main() {
+ A.method();
+
+}
diff --git a/tests/language/constructor/unresolved_in_factory_test.dart b/tests/language/constructor/unresolved_in_factory_test.dart
new file mode 100644
index 0000000..a9aa72a
--- /dev/null
+++ b/tests/language/constructor/unresolved_in_factory_test.dart
@@ -0,0 +1,15 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test that an unresolved method call in a factory is a compile error.
+
+class A {
+ factory A() {
+ foo(); /*@compile-error=unspecified*/
+ }
+}
+
+main() {
+ new A();
+}
diff --git a/tests/language/constructor/with_mixin_test.dart b/tests/language/constructor/with_mixin_test.dart
new file mode 100644
index 0000000..5e4badc
--- /dev/null
+++ b/tests/language/constructor/with_mixin_test.dart
@@ -0,0 +1,36 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Test super constructor invocation with mixins.
+// Regression test for issue dartbug.com/22604
+
+import "package:expect/expect.dart";
+
+var a_count = 0;
+var b_count = 0;
+
+class A {
+ final int x;
+ A(int this.x) {
+ a_count++;
+ }
+}
+
+class I {}
+
+class B extends A with I {
+ int y;
+
+ B(int xx)
+ : y = 13,
+ super(xx) {
+ b_count++;
+ }
+}
+
+void main() {
+ var b = new B(17);
+ Expect.equals(1, a_count);
+ Expect.equals(1, b_count);
+}
diff --git a/tests/language/constructor/with_type_parameters_test.dart b/tests/language/constructor/with_type_parameters_test.dart
new file mode 100644
index 0000000..8df1733
--- /dev/null
+++ b/tests/language/constructor/with_type_parameters_test.dart
@@ -0,0 +1,28 @@
+// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+class Bar<T> {
+ Bar() {} //# 01: ok
+ Bar.boo() {} //# 02: ok
+ Bar<E>() {} //# 03: compile-time error
+ Bar<E>.boo() {} //# 04: syntax error
+ Bar.boo<E>() {} //# 05: syntax error
+ Bar.boo<E>.baz() {} //# 06: syntax error
+
+ Bar(); //# 07: ok
+ Bar.boo(); //# 08: ok
+ Bar<E>(); //# 09: compile-time error
+ Bar<E>.boo(); //# 10: syntax error
+ Bar.boo<E>(); //# 11: syntax error
+ Bar.boo<E>.baz(); //# 12: syntax error
+
+ const Bar(); //# 13: ok
+ const Bar.boo(); //# 14: ok
+ const Bar<E>(); //# 15: syntax error
+ const Bar<E>.boo(); //# 16: syntax error
+ const Bar.boo<E>(); //# 17: syntax error
+ const Bar.boo<E>.baz(); //# 18: syntax error
+}
+
+main() {}