[language] Add language tests for preserved behavior when the inference-using-bounds flag isn't set

This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/386220/comments/75e33432_07105bb3

Change-Id: I26ab50062978e79a2bd113efcac572e68b86e759
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/386801
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
diff --git a/tests/language/inference_using_bounds/f_bounded_inheritance_hierarchy_root_test.dart b/tests/language/inference_using_bounds/f_bounded_inheritance_hierarchy_root_test.dart
index 573bf80..cf4b5e0 100644
--- a/tests/language/inference_using_bounds/f_bounded_inheritance_hierarchy_root_test.dart
+++ b/tests/language/inference_using_bounds/f_bounded_inheritance_hierarchy_root_test.dart
@@ -4,6 +4,8 @@
 
 // SharedOptions=--enable-experiment=inference-using-bounds
 
+import '../static_type_helper.dart';
+
 class A<X extends A<X>> {}
 
 class B extends A<B> {}
@@ -17,9 +19,3 @@
   f(C())..expectStaticType<Exactly<B>>();
   f<B>(C());
 }
-
-typedef Exactly<X> = X Function(X);
-
-extension E<X> on X {
-  void expectStaticType<Y extends Exactly<X>>() {}
-}
diff --git a/tests/language/inference_using_bounds/f_bounded_mutually_recursive_test.dart b/tests/language/inference_using_bounds/f_bounded_mutually_recursive_test.dart
index 4465ecb..642f415 100644
--- a/tests/language/inference_using_bounds/f_bounded_mutually_recursive_test.dart
+++ b/tests/language/inference_using_bounds/f_bounded_mutually_recursive_test.dart
@@ -4,6 +4,8 @@
 
 // SharedOptions=--enable-experiment=inference-using-bounds
 
+import '../static_type_helper.dart';
+
 class A1<X extends A1<X, Y>, Y extends A2<X, Y>> {}
 
 class A2<X extends A1<X, Y>, Y extends A2<X, Y>> {}
@@ -23,9 +25,3 @@
   f<B, B>(C1(), C2());
   f(C1(), C2())..expectStaticType<Exactly<Pair<B, B>>>();
 }
-
-typedef Exactly<X> = X Function(X);
-
-extension E<X> on X {
-  void expectStaticType<Y extends Exactly<X>>() {}
-}
diff --git a/tests/language/inference_using_bounds/pre_experiment/f_bounded_inheritance_hierarchy_root_error_test.dart b/tests/language/inference_using_bounds/pre_experiment/f_bounded_inheritance_hierarchy_root_error_test.dart
new file mode 100644
index 0000000..6dc917f
--- /dev/null
+++ b/tests/language/inference_using_bounds/pre_experiment/f_bounded_inheritance_hierarchy_root_error_test.dart
@@ -0,0 +1,22 @@
+// Copyright (c) 2024, 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=3.5
+
+class A<X extends A<X>> {}
+
+class B extends A<B> {}
+
+class C extends B {}
+
+X f<X extends A<X>>(X x) => x;
+
+void main() {
+  f(B()); // Ok.
+  f(C()); // Error.
+//^
+// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
+// [cfe] Inferred type argument 'C' doesn't conform to the bound 'A<X>' of the type variable 'X' on 'f'.
+  f<B>(C()); // Ok.
+}
diff --git a/tests/language/inference_using_bounds/pre_experiment/f_bounded_mutually_recursive_error_test.dart b/tests/language/inference_using_bounds/pre_experiment/f_bounded_mutually_recursive_error_test.dart
new file mode 100644
index 0000000..4766f17
--- /dev/null
+++ b/tests/language/inference_using_bounds/pre_experiment/f_bounded_mutually_recursive_error_test.dart
@@ -0,0 +1,30 @@
+// Copyright (c) 2024, 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=3.5
+
+class A1<X extends A1<X, Y>, Y extends A2<X, Y>> {}
+
+class A2<X extends A1<X, Y>, Y extends A2<X, Y>> {}
+
+class B extends A1<B, B> implements A2<B, B> {}
+
+class C1 extends B {}
+
+class C2 extends B {}
+
+class Pair<X, Y> {}
+
+Pair<X, Y> f<X extends A1<X, Y>, Y extends A2<X, Y>>(X x, Y y) =>
+    new Pair<X, Y>();
+
+void main() {
+  f<B, B>(C1(), C2()); // Ok.
+  f(C1(), C2()); // Error.
+//^
+// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
+// [analyzer] COMPILE_TIME_ERROR.COULD_NOT_INFER
+// [cfe] Inferred type argument 'C1' doesn't conform to the bound 'A1<X, Y>' of the type variable 'X' on 'f'.
+// [cfe] Inferred type argument 'C2' doesn't conform to the bound 'A2<X, Y>' of the type variable 'Y' on 'f'.
+}
diff --git a/tests/language/inference_using_bounds/pre_experiment/type_variable_dependency_left_to_right_test.dart b/tests/language/inference_using_bounds/pre_experiment/type_variable_dependency_left_to_right_test.dart
new file mode 100644
index 0000000..75413fc
--- /dev/null
+++ b/tests/language/inference_using_bounds/pre_experiment/type_variable_dependency_left_to_right_test.dart
@@ -0,0 +1,19 @@
+// Copyright (c) 2024, 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=3.5
+
+import '../../static_type_helper.dart';
+
+class A<X extends Iterable<Y>, Y> {
+  A(X x);
+  Y? y;
+}
+
+main() {
+  // Inferred as A<List<num>, dynamic>.
+  A(<num>[])
+    ..y = "ok"
+    ..expectStaticType<Exactly<A<List<num>, dynamic>>>();
+}
diff --git a/tests/language/inference_using_bounds/pre_experiment/type_variable_dependency_right_to_left_test.dart b/tests/language/inference_using_bounds/pre_experiment/type_variable_dependency_right_to_left_test.dart
new file mode 100644
index 0000000..81a5080
--- /dev/null
+++ b/tests/language/inference_using_bounds/pre_experiment/type_variable_dependency_right_to_left_test.dart
@@ -0,0 +1,19 @@
+// Copyright (c) 2024, 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=3.5
+
+import '../../static_type_helper.dart';
+
+class A<Y, X extends Iterable<Y>> {
+  A(X x);
+  Y? y;
+}
+
+main() {
+  // Inferred as A<dynamic, List<num>>.
+  A(<num>[])
+    ..y = "ok"
+    ..expectStaticType<Exactly<A<dynamic, List<num>>>>();
+}
diff --git a/tests/language/inference_using_bounds/type_variable_dependency_left_to_right_test.dart b/tests/language/inference_using_bounds/type_variable_dependency_left_to_right_error_test.dart
similarity index 100%
rename from tests/language/inference_using_bounds/type_variable_dependency_left_to_right_test.dart
rename to tests/language/inference_using_bounds/type_variable_dependency_left_to_right_error_test.dart
diff --git a/tests/language/inference_using_bounds/type_variable_dependency_right_to_left_test.dart b/tests/language/inference_using_bounds/type_variable_dependency_right_to_left_test.dart
index f54e7fa..ad62ebf 100644
--- a/tests/language/inference_using_bounds/type_variable_dependency_right_to_left_test.dart
+++ b/tests/language/inference_using_bounds/type_variable_dependency_right_to_left_test.dart
@@ -4,6 +4,8 @@
 
 // SharedOptions=--enable-experiment=inference-using-bounds
 
+import '../static_type_helper.dart';
+
 class A<Y, X extends Iterable<Y>> {
   A(X x);
   Y? y;
@@ -15,9 +17,3 @@
     ..y = "ok"
     ..expectStaticType<Exactly<A<dynamic, List<num>>>>();
 }
-
-typedef Exactly<X> = X Function(X);
-
-extension E<X> on X {
-  void expectStaticType<Y extends Exactly<X>>() {}
-}