Add frontend testcases for part with part(s) in it

Currently there's at least two issues:
* We can crash
* We can add metadata to things they weren't meant for

Change-Id: I4e277ea614ce9faa25b2bf1c5a16a5e877df225b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106640
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
diff --git a/pkg/front_end/testcases/having_part_with_part_and_annotation.dart b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart
new file mode 100644
index 0000000..9e3a783
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart
@@ -0,0 +1,8 @@
+@Foo
+part 'having_part_with_part_and_annotation_lib1.dart';
+
+const int Foo = 42;
+
+void fromMain() {}
+
+main() {}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.legacy.expect b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.legacy.expect
new file mode 100644
index 0000000..176c13c
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.legacy.expect
@@ -0,0 +1,21 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/having_part_with_part_and_annotation_lib1.dart:4:6: Error: A file that's a part of a library can't have parts itself.
+// Try moving the 'part' declaration to the containing library.
+// part 'having_part_with_part_and_annotation_lib2.dart';
+//      ^
+// pkg/front_end/testcases/having_part_with_part_and_annotation.dart: Context: This is the containing library.
+//
+import self as self;
+import "dart:core" as core;
+
+@self::Foo
+@self::Bar
+part having_part_with_part_and_annotation_lib1.dart;
+static const field core::int Foo = 42;
+static const field core::int Bar = 43 /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */;
+static method fromMain() → void {}
+static method main() → dynamic {}
+static method /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */ fromLib1() → void {}
diff --git a/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.legacy.transformed.expect b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.legacy.transformed.expect
new file mode 100644
index 0000000..176c13c
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.legacy.transformed.expect
@@ -0,0 +1,21 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/having_part_with_part_and_annotation_lib1.dart:4:6: Error: A file that's a part of a library can't have parts itself.
+// Try moving the 'part' declaration to the containing library.
+// part 'having_part_with_part_and_annotation_lib2.dart';
+//      ^
+// pkg/front_end/testcases/having_part_with_part_and_annotation.dart: Context: This is the containing library.
+//
+import self as self;
+import "dart:core" as core;
+
+@self::Foo
+@self::Bar
+part having_part_with_part_and_annotation_lib1.dart;
+static const field core::int Foo = 42;
+static const field core::int Bar = 43 /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */;
+static method fromMain() → void {}
+static method main() → dynamic {}
+static method /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */ fromLib1() → void {}
diff --git a/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.outline.expect b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.outline.expect
new file mode 100644
index 0000000..6043aa4
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.outline.expect
@@ -0,0 +1,22 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/having_part_with_part_and_annotation_lib1.dart:4:6: Error: A file that's a part of a library can't have parts itself.
+// Try moving the 'part' declaration to the containing library.
+// part 'having_part_with_part_and_annotation_lib2.dart';
+//      ^
+// pkg/front_end/testcases/having_part_with_part_and_annotation.dart: Context: This is the containing library.
+//
+import self as self;
+import "dart:core" as core;
+
+part having_part_with_part_and_annotation_lib1.dart;
+static const field core::int Foo = 42;
+static const field core::int Bar = 43 /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */;
+static method fromMain() → void
+  ;
+static method main() → dynamic
+  ;
+static method /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */ fromLib1() → void
+  ;
diff --git a/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.strong.expect b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.strong.expect
new file mode 100644
index 0000000..176c13c
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.strong.expect
@@ -0,0 +1,21 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/having_part_with_part_and_annotation_lib1.dart:4:6: Error: A file that's a part of a library can't have parts itself.
+// Try moving the 'part' declaration to the containing library.
+// part 'having_part_with_part_and_annotation_lib2.dart';
+//      ^
+// pkg/front_end/testcases/having_part_with_part_and_annotation.dart: Context: This is the containing library.
+//
+import self as self;
+import "dart:core" as core;
+
+@self::Foo
+@self::Bar
+part having_part_with_part_and_annotation_lib1.dart;
+static const field core::int Foo = 42;
+static const field core::int Bar = 43 /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */;
+static method fromMain() → void {}
+static method main() → dynamic {}
+static method /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */ fromLib1() → void {}
diff --git a/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.strong.transformed.expect b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.strong.transformed.expect
new file mode 100644
index 0000000..176c13c
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_part_and_annotation.dart.strong.transformed.expect
@@ -0,0 +1,21 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/having_part_with_part_and_annotation_lib1.dart:4:6: Error: A file that's a part of a library can't have parts itself.
+// Try moving the 'part' declaration to the containing library.
+// part 'having_part_with_part_and_annotation_lib2.dart';
+//      ^
+// pkg/front_end/testcases/having_part_with_part_and_annotation.dart: Context: This is the containing library.
+//
+import self as self;
+import "dart:core" as core;
+
+@self::Foo
+@self::Bar
+part having_part_with_part_and_annotation_lib1.dart;
+static const field core::int Foo = 42;
+static const field core::int Bar = 43 /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */;
+static method fromMain() → void {}
+static method main() → dynamic {}
+static method /* from org-dartlang-testcase:///having_part_with_part_and_annotation_lib1.dart */ fromLib1() → void {}
diff --git a/pkg/front_end/testcases/having_part_with_part_and_annotation_lib1.dart b/pkg/front_end/testcases/having_part_with_part_and_annotation_lib1.dart
new file mode 100644
index 0000000..b2bb2d8
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_part_and_annotation_lib1.dart
@@ -0,0 +1,8 @@
+part of 'having_part_with_part_and_annotation.dart';
+
+@Bar
+part 'having_part_with_part_and_annotation_lib2.dart';
+
+const int Bar = 43;
+
+void fromLib1() {}
diff --git a/pkg/front_end/testcases/having_part_with_part_and_annotation_lib2.dart b/pkg/front_end/testcases/having_part_with_part_and_annotation_lib2.dart
new file mode 100644
index 0000000..5614f61
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_part_and_annotation_lib2.dart
@@ -0,0 +1,3 @@
+part of 'having_part_with_part_and_annotation_lib1.dart';
+
+void fromLib2() {}
diff --git a/pkg/front_end/testcases/having_part_with_parts_and_annotation.dart b/pkg/front_end/testcases/having_part_with_parts_and_annotation.dart
new file mode 100644
index 0000000..46ba730
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_parts_and_annotation.dart
@@ -0,0 +1,8 @@
+@Foo
+part 'having_part_with_parts_and_annotation_lib1.dart';
+
+const int Foo = 42;
+
+void fromMain() {}
+
+main() {}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/having_part_with_parts_and_annotation.dart.outline.expect b/pkg/front_end/testcases/having_part_with_parts_and_annotation.dart.outline.expect
new file mode 100644
index 0000000..b6959ee
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_parts_and_annotation.dart.outline.expect
@@ -0,0 +1,29 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/having_part_with_parts_and_annotation_lib1.dart:4:6: Error: A file that's a part of a library can't have parts itself.
+// Try moving the 'part' declaration to the containing library.
+// part 'having_part_with_parts_and_annotation_lib2.dart';
+//      ^
+// pkg/front_end/testcases/having_part_with_parts_and_annotation.dart: Context: This is the containing library.
+//
+// pkg/front_end/testcases/having_part_with_parts_and_annotation_lib1.dart:6:6: Error: A file that's a part of a library can't have parts itself.
+// Try moving the 'part' declaration to the containing library.
+// part 'having_part_with_parts_and_annotation_lib2.dart';
+//      ^
+// pkg/front_end/testcases/having_part_with_parts_and_annotation.dart: Context: This is the containing library.
+//
+import self as self;
+import "dart:core" as core;
+
+part having_part_with_parts_and_annotation_lib1.dart;
+static const field core::int Foo = 42;
+static const field core::int Bar = 43 /* from org-dartlang-testcase:///having_part_with_parts_and_annotation_lib1.dart */;
+static const field core::int Baz = 44 /* from org-dartlang-testcase:///having_part_with_parts_and_annotation_lib1.dart */;
+static method fromMain() → void
+  ;
+static method main() → dynamic
+  ;
+static method /* from org-dartlang-testcase:///having_part_with_parts_and_annotation_lib1.dart */ fromLib1() → void
+  ;
diff --git a/pkg/front_end/testcases/having_part_with_parts_and_annotation_lib1.dart b/pkg/front_end/testcases/having_part_with_parts_and_annotation_lib1.dart
new file mode 100644
index 0000000..61dbfa8
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_parts_and_annotation_lib1.dart
@@ -0,0 +1,11 @@
+part of 'having_part_with_parts_and_annotation.dart';
+
+@Bar
+part 'having_part_with_parts_and_annotation_lib2.dart';
+@Baz
+part 'having_part_with_parts_and_annotation_lib2.dart';
+
+const int Bar = 43;
+const int Baz = 44;
+
+void fromLib1() {}
diff --git a/pkg/front_end/testcases/having_part_with_parts_and_annotation_lib2.dart b/pkg/front_end/testcases/having_part_with_parts_and_annotation_lib2.dart
new file mode 100644
index 0000000..f5c6150
--- /dev/null
+++ b/pkg/front_end/testcases/having_part_with_parts_and_annotation_lib2.dart
@@ -0,0 +1,3 @@
+part of 'having_part_with_parts_and_annotation_lib1.dart';
+
+void fromLib2() {}
diff --git a/pkg/front_end/testcases/legacy.status b/pkg/front_end/testcases/legacy.status
index b1b1917..2a0d665 100644
--- a/pkg/front_end/testcases/legacy.status
+++ b/pkg/front_end/testcases/legacy.status
@@ -16,6 +16,7 @@
 external_import: RuntimeError # Expected -- test uses import which doesn't exist.
 fallthrough: Fail # Missing FallThroughError.
 function_type_recovery: Fail
+having_part_with_parts_and_annotation: Crash
 incomplete_field_formal_parameter: Fail # Fasta doesn't recover well
 inference/bug31436: RuntimeError # Test exercises Dart 2.0 semantics
 inference/constructors_too_many_positional_arguments: Fail
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index 79ac736..44b9c0b 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -24,6 +24,7 @@
 expressions: RuntimeError
 external_import: RuntimeError # The native extension to import doesn't exist. This is ok.
 fallthrough: ExpectationFileMismatch
+having_part_with_parts_and_annotation: Crash
 incomplete_field_formal_parameter: RuntimeError
 inference/abstract_class_instantiation: InstrumentationMismatch # Issue #30040
 inference/conflicting_fields: TypeCheckError
diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status
index a32cc66..b43ed5f 100644
--- a/pkg/front_end/testcases/text_serialization.status
+++ b/pkg/front_end/testcases/text_serialization.status
@@ -104,6 +104,8 @@
 functions: TextSerializationFailure # Was: Pass
 future_or_test: TextSerializationFailure # Was: Pass
 hello: TextSerializationFailure # Was: Pass
+having_part_with_part_and_annotation: TextSerializationFailure
+having_part_with_parts_and_annotation: Crash
 illegal_named_function_expression: TextSerializationFailure # Was: Pass
 illegal_named_function_expression_scope: TextSerializationFailure # Was: Pass
 implicit_const_with_static_fields: TextSerializationFailure # Was: Pass