Add language_2 tests demonstrating bug #30568

R=rnystrom@google.com

Review-Url: https://codereview.chromium.org/3008823002 .
diff --git a/tests/language_2/abstract_override_adds_optional_args_concrete_subclass_test.dart b/tests/language_2/abstract_override_adds_optional_args_concrete_subclass_test.dart
new file mode 100644
index 0000000..12a023f
--- /dev/null
+++ b/tests/language_2/abstract_override_adds_optional_args_concrete_subclass_test.dart
@@ -0,0 +1,28 @@
+// 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 {
+  void foo() {}
+}
+
+abstract class B extends A {
+  // If this class were concrete, there would be a problem, since `new
+  // B().foo(42)` would be statically allowed, but would lead to invalid
+  // arguments being passed to A.foo.  But since the class is abstract, there is
+  // no problem.
+  void foo([x]);
+}
+
+class /*@compile-error=unspecified*/ C extends B {
+  // However, there is a problem here because this class is concrete and doesn't
+  // override foo.
+}
+
+void f(B b) {
+  b.foo();
+}
+
+main() {
+  f(new C());
+}
diff --git a/tests/language_2/abstract_override_adds_optional_args_concrete_test.dart b/tests/language_2/abstract_override_adds_optional_args_concrete_test.dart
new file mode 100644
index 0000000..b8232e8
--- /dev/null
+++ b/tests/language_2/abstract_override_adds_optional_args_concrete_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 A {
+  void foo() {}
+}
+
+class B extends A {
+  // This class declaration violates soundness, since it allows `new
+  // B().foo(42)`, which would lead to invalid arguments being passed to A.foo.
+  void /*@compile-error=unspecified*/ foo([x]);
+}
+
+void f(B b) {
+  b.foo();
+}
+
+main() {
+  f(new B());
+}
diff --git a/tests/language_2/abstract_override_adds_optional_args_test.dart b/tests/language_2/abstract_override_adds_optional_args_test.dart
new file mode 100644
index 0000000..d139307
--- /dev/null
+++ b/tests/language_2/abstract_override_adds_optional_args_test.dart
@@ -0,0 +1,33 @@
+// 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.
+
+// This test exercises a corner case of override checking that is safe from a
+// soundness perspective, but which we haven't decided whether or not to allow
+// from a usability perspective.
+
+class A {
+  void foo() {}
+}
+
+abstract class B extends A {
+  // If this class were concrete, there would be a problem, since `new
+  // B().foo(42)` would be statically allowed, but would lead to invalid
+  // arguments being passed to A.foo.  But since the class is abstract, there is
+  // no problem.
+  void foo([x]);
+}
+
+class C extends B {
+  void foo([x]) {
+    super.foo();
+  }
+}
+
+void f(B b) {
+  b.foo(42);
+}
+
+main() {
+  f(new C());
+}
diff --git a/tests/language_2/additional_interface_adds_optional_args_concrete_subclass_test.dart b/tests/language_2/additional_interface_adds_optional_args_concrete_subclass_test.dart
new file mode 100644
index 0000000..523a972
--- /dev/null
+++ b/tests/language_2/additional_interface_adds_optional_args_concrete_subclass_test.dart
@@ -0,0 +1,31 @@
+// 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 {
+  void foo() {}
+}
+
+abstract class I {
+  void foo([x]);
+}
+
+abstract class B extends A implements I {
+  // If this class were concrete, there would be a problem, since `new
+  // B().foo(42)` would be statically allowed, but would lead to invalid
+  // arguments being passed to A.foo.  But since the class is abstract, there is
+  // no problem.
+}
+
+class /*@compile-error=unspecified*/ C extends B {
+  // However, there is a problem here because this class is concrete and doesn't
+  // override foo.
+}
+
+void f(B b) {
+  b.foo();
+}
+
+main() {
+  f(new C());
+}
diff --git a/tests/language_2/additional_interface_adds_optional_args_concrete_test.dart b/tests/language_2/additional_interface_adds_optional_args_concrete_test.dart
new file mode 100644
index 0000000..2fe4137
--- /dev/null
+++ b/tests/language_2/additional_interface_adds_optional_args_concrete_test.dart
@@ -0,0 +1,24 @@
+// 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 {
+  void foo() {}
+}
+
+abstract class I {
+  void foo([x]);
+}
+
+class /*@compile-error=unspecified*/ B extends A implements I {
+  // This class declaration violates soundness, since it allows `new
+  // B().foo(42)`, which would lead to invalid arguments being passed to A.foo.
+}
+
+void f(B b) {
+  b.foo();
+}
+
+main() {
+  f(new B());
+}
diff --git a/tests/language_2/additional_interface_adds_optional_args_test.dart b/tests/language_2/additional_interface_adds_optional_args_test.dart
new file mode 100644
index 0000000..5c9953e
--- /dev/null
+++ b/tests/language_2/additional_interface_adds_optional_args_test.dart
@@ -0,0 +1,36 @@
+// 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.
+
+// This test exercises a corner case of override checking that is safe from a
+// soundness perspective, but which we haven't decided whether or not to allow
+// from a usability perspective.
+
+class A {
+  void foo() {}
+}
+
+abstract class I {
+  void foo([x]);
+}
+
+abstract class B extends A implements I {
+  // If this class were concrete, there would be a problem, since `new
+  // B().foo(42)` would be statically allowed, but would lead to invalid
+  // arguments being passed to A.foo.  But since the class is abstract, there is
+  // no problem.
+}
+
+class C extends B {
+  void foo([x]) {
+    super.foo();
+  }
+}
+
+void f(B b) {
+  b.foo(42);
+}
+
+main() {
+  f(new C());
+}
diff --git a/tests/language_2/language_2_analyzer.status b/tests/language_2/language_2_analyzer.status
index 133134b..8d2194f 100644
--- a/tests/language_2/language_2_analyzer.status
+++ b/tests/language_2/language_2_analyzer.status
@@ -181,6 +181,8 @@
 getters_setters2_test/02: MissingCompileTimeError
 
 [ $compiler == dart2analyzer ]
+abstract_override_adds_optional_args_concrete_subclass_test: MissingCompileTimeError # Issue #30568
+abstract_override_adds_optional_args_concrete_test: MissingCompileTimeError # Issue #30568
 async_return_types_test/nestedFuture: MissingCompileTimeError
 bad_initializer1_negative_test: CompileTimeError # Issue 14529
 bad_initializer2_negative_test: fail # Issue 14880
@@ -211,6 +213,7 @@
 accessor_conflict_import_prefixed2_test: CompileTimeError # Issue 25626
 accessor_conflict_import_prefixed_test: CompileTimeError # Issue 25626
 accessor_conflict_import_test: CompileTimeError # Issue 25626
+additional_interface_adds_optional_args_test: CompileTimeError # Issue #30568
 async_return_types_test/nestedFuture: MissingCompileTimeError
 bit_operations_test/01: MissingStaticWarning # Issue 28823
 bit_operations_test/02: MissingStaticWarning # Issue 28823
@@ -283,6 +286,9 @@
 accessor_conflict_import_prefixed2_test: StaticWarning # Issue 25626
 accessor_conflict_import_prefixed_test: StaticWarning # Issue 25626
 accessor_conflict_import_test: StaticWarning # Issue 25626
+additional_interface_adds_optional_args_concrete_subclass_test: MissingCompileTimeError
+additional_interface_adds_optional_args_concrete_test: MissingCompileTimeError
+additional_interface_adds_optional_args_test: StaticWarning
 cast_test/04: MissingCompileTimeError
 cast_test/05: MissingCompileTimeError
 checked_null_test/01: MissingCompileTimeError
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index a4e994d..369ec8e 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -10,7 +10,11 @@
 abstract_exact_selector_test/01: MissingCompileTimeError
 abstract_factory_constructor_test/00: MissingCompileTimeError
 abstract_getter_test/01: MissingCompileTimeError
+abstract_override_adds_optional_args_concrete_subclass_test: MissingCompileTimeError
+abstract_override_adds_optional_args_concrete_test: MissingCompileTimeError
 abstract_syntax_test/00: MissingCompileTimeError
+additional_interface_adds_optional_args_concrete_subclass_test: MissingCompileTimeError
+additional_interface_adds_optional_args_concrete_test: MissingCompileTimeError
 assign_static_type_test/01: MissingCompileTimeError
 assign_static_type_test/02: MissingCompileTimeError
 assign_static_type_test/03: MissingCompileTimeError
diff --git a/tests/language_2/language_2_dartdevc.status b/tests/language_2/language_2_dartdevc.status
index ee41e74..b4d2234 100644
--- a/tests/language_2/language_2_dartdevc.status
+++ b/tests/language_2/language_2_dartdevc.status
@@ -5,6 +5,9 @@
 # Sections in this file should contain "$compiler == dartdevc".
 
 [ $compiler == dartdevc ]
+abstract_override_adds_optional_args_concrete_subclass_test: MissingCompileTimeError # Issue #30568
+abstract_override_adds_optional_args_concrete_test: MissingCompileTimeError # Issue #30568
+additional_interface_adds_optional_args_test: CompileTimeError # Issue #30568
 assertion_initializer_const_error2_test/none: CompileTimeError
 assertion_initializer_const_function_test/01: CompileTimeError
 assertion_initializer_test: CompileTimeError
diff --git a/tests/language_2/language_2_precompiled.status b/tests/language_2/language_2_precompiled.status
index 3d612b5..c5cecc2 100644
--- a/tests/language_2/language_2_precompiled.status
+++ b/tests/language_2/language_2_precompiled.status
@@ -10,7 +10,11 @@
 abstract_exact_selector_test/01: MissingCompileTimeError
 abstract_factory_constructor_test/00: MissingCompileTimeError
 abstract_getter_test/01: MissingCompileTimeError
+abstract_override_adds_optional_args_concrete_subclass_test: MissingCompileTimeError
+abstract_override_adds_optional_args_concrete_test: MissingCompileTimeError
 abstract_syntax_test/00: MissingCompileTimeError
+additional_interface_adds_optional_args_concrete_subclass_test: MissingCompileTimeError
+additional_interface_adds_optional_args_concrete_test: MissingCompileTimeError
 assign_static_type_test/01: MissingCompileTimeError
 assign_static_type_test/02: MissingCompileTimeError
 assign_static_type_test/03: MissingCompileTimeError
diff --git a/tests/language_2/language_2_vm.status b/tests/language_2/language_2_vm.status
index 6d3f5d2..399afc4 100644
--- a/tests/language_2/language_2_vm.status
+++ b/tests/language_2/language_2_vm.status
@@ -10,7 +10,11 @@
 abstract_exact_selector_test/01: MissingCompileTimeError
 abstract_factory_constructor_test/00: MissingCompileTimeError
 abstract_getter_test/01: MissingCompileTimeError
+abstract_override_adds_optional_args_concrete_subclass_test: MissingCompileTimeError
+abstract_override_adds_optional_args_concrete_test: MissingCompileTimeError
 abstract_syntax_test/00: MissingCompileTimeError
+additional_interface_adds_optional_args_concrete_subclass_test: MissingCompileTimeError
+additional_interface_adds_optional_args_concrete_test: MissingCompileTimeError
 assign_static_type_test/01: MissingCompileTimeError
 assign_static_type_test/02: MissingCompileTimeError
 assign_static_type_test/03: MissingCompileTimeError