Test that shows leaking synthetic nodes

Change-Id: I8f68795380c1d6963203f9356244d2599be6c9cb
Reviewed-on: https://dart-review.googlesource.com/c/90002
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
diff --git a/pkg/front_end/testcases/many_errors.dart b/pkg/front_end/testcases/many_errors.dart
new file mode 100644
index 0000000..b689662
--- /dev/null
+++ b/pkg/front_end/testcases/many_errors.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2019, 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 {
+  final x = null;
+
+  const A.named1() sync* {}
+
+  const A.named2() : x = new Object();
+}
+
+external foo(String x) {
+  return x.length;
+}
+
+class B {}
+
+class C {
+  B b;
+}
+
+abstract class AbstractClass {
+  const AbstractClass.id();
+}
+
+m() {
+  const AbstractClass.id();
+  (new C()?.b ??= new B()).b;
+}
+
+main() {}
diff --git a/pkg/front_end/testcases/many_errors.dart.hierarchy.expect b/pkg/front_end/testcases/many_errors.dart.hierarchy.expect
new file mode 100644
index 0000000..ef14d0e
--- /dev/null
+++ b/pkg/front_end/testcases/many_errors.dart.hierarchy.expect
@@ -0,0 +1,90 @@
+Object:
+  superclasses:
+  interfaces:
+  classMembers:
+    Object._haveSameRuntimeType
+    Object.toString
+    Object.runtimeType
+    Object._toString
+    Object._simpleInstanceOf
+    Object._hashCodeRnd
+    Object._instanceOf
+    Object.noSuchMethod
+    Object._objectHashCode
+    Object._identityHashCode
+    Object.hashCode
+    Object._simpleInstanceOfFalse
+    Object._simpleInstanceOfTrue
+    Object.==
+  classSetters:
+
+A:
+  superclasses:
+    Object
+  interfaces:
+  classMembers:
+    Object.toString
+    A.x
+    Object.runtimeType
+    Object._simpleInstanceOf
+    Object._instanceOf
+    Object.noSuchMethod
+    Object._identityHashCode
+    Object.hashCode
+    Object._simpleInstanceOfFalse
+    Object._simpleInstanceOfTrue
+    Object.==
+  classSetters:
+
+B:
+  superclasses:
+    Object
+  interfaces:
+  classMembers:
+    Object.toString
+    Object.runtimeType
+    Object._simpleInstanceOf
+    Object._instanceOf
+    Object.noSuchMethod
+    Object._identityHashCode
+    Object.hashCode
+    Object._simpleInstanceOfFalse
+    Object._simpleInstanceOfTrue
+    Object.==
+  classSetters:
+
+C:
+  superclasses:
+    Object
+  interfaces:
+  classMembers:
+    C.b
+    Object.toString
+    Object.runtimeType
+    Object._simpleInstanceOf
+    Object._instanceOf
+    Object.noSuchMethod
+    Object._identityHashCode
+    Object.hashCode
+    Object._simpleInstanceOfFalse
+    Object._simpleInstanceOfTrue
+    Object.==
+  classSetters:
+    C.b
+
+AbstractClass:
+  superclasses:
+    Object
+  interfaces:
+  classMembers:
+    Object.toString
+    Object.runtimeType
+    Object._simpleInstanceOf
+    Object._instanceOf
+    Object.noSuchMethod
+    Object._identityHashCode
+    Object.hashCode
+    Object._simpleInstanceOfFalse
+    Object._simpleInstanceOfTrue
+    Object.==
+  classSetters:
diff --git a/pkg/front_end/testcases/many_errors.dart.legacy.expect b/pkg/front_end/testcases/many_errors.dart.legacy.expect
new file mode 100644
index 0000000..119e782
--- /dev/null
+++ b/pkg/front_end/testcases/many_errors.dart.legacy.expect
@@ -0,0 +1,90 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/many_errors.dart:8:3: Error: A const constructor can't have a body.
+// Try removing either the 'const' keyword or the body.
+//   const A.named1() sync* {}
+//   ^^^^^
+//
+// pkg/front_end/testcases/many_errors.dart:13:1: Error: An external or native method can't have a body.
+// external foo(String x) {
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/many_errors.dart:8:26: Error: Constructor bodies can't use 'async', 'async*', or 'sync*'.
+//   const A.named1() sync* {}
+//                          ^
+//
+// pkg/front_end/testcases/many_errors.dart:10:26: Error: New expression is not a constant expression.
+//   const A.named2() : x = new Object();
+//                          ^^^
+//
+// pkg/front_end/testcases/many_errors.dart:10:24: Warning: 'x' is a final instance variable that has already been initialized.
+//   const A.named2() : x = new Object();
+//                        ^
+// pkg/front_end/testcases/many_errors.dart:6:9: Context: 'x' was initialized here.
+//   final x = null;
+//         ^
+//
+// pkg/front_end/testcases/many_errors.dart:10:24: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   const A.named2() : x = new Object();
+//                        ^
+//
+// pkg/front_end/testcases/many_errors.dart:13:24: Error: An external or native method can't have a body.
+// external foo(String x) {
+//                        ^
+//
+// pkg/front_end/testcases/many_errors.dart:28:9: Error: The class 'AbstractClass' is abstract and can't be instantiated.
+//   const AbstractClass.id();
+//         ^^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/many_errors.dart:28:9: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   const AbstractClass.id();
+//         ^
+//
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object {
+  final field dynamic x = null;
+  constructor named1() → self::A
+    : final dynamic #t1 = invalid-expression "pkg/front_end/testcases/many_errors.dart:8:26: Error: Constructor bodies can't use 'async', 'async*', or 'sync*'.
+  const A.named1() sync* {}
+                         ^" {}
+  const constructor named2() → self::A
+    : final dynamic #t2 = throw invalid-expression "pkg/front_end/testcases/many_errors.dart:10:24: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  const A.named2() : x = new Object();
+                       ^", super core::Object::•()
+    ;
+}
+class B extends core::Object {
+  synthetic constructor •() → self::B
+    : super core::Object::•()
+    ;
+}
+class C extends core::Object {
+  field self::B b = null;
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+}
+abstract class AbstractClass extends core::Object {
+  const constructor id() → self::AbstractClass
+    : super core::Object::•()
+    ;
+}
+external static method foo(core::String x) → dynamic
+  invalid-expression "pkg/front_end/testcases/many_errors.dart:13:24: Error: An external or native method can't have a body.
+external foo(String x) {
+                       ^";
+static method m() → dynamic {
+  throw invalid-expression "pkg/front_end/testcases/many_errors.dart:28:9: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  const AbstractClass.id();
+        ^";
+  (let final dynamic #t3 = new self::C::•() in #t3.==(null) ? null : let final dynamic #t4 = #t3.b in #t4.==(null) ? #t3.b = new self::B::•() : #t4).b;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/many_errors.dart.legacy.transformed.expect b/pkg/front_end/testcases/many_errors.dart.legacy.transformed.expect
new file mode 100644
index 0000000..119e782
--- /dev/null
+++ b/pkg/front_end/testcases/many_errors.dart.legacy.transformed.expect
@@ -0,0 +1,90 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/many_errors.dart:8:3: Error: A const constructor can't have a body.
+// Try removing either the 'const' keyword or the body.
+//   const A.named1() sync* {}
+//   ^^^^^
+//
+// pkg/front_end/testcases/many_errors.dart:13:1: Error: An external or native method can't have a body.
+// external foo(String x) {
+// ^^^^^^^^
+//
+// pkg/front_end/testcases/many_errors.dart:8:26: Error: Constructor bodies can't use 'async', 'async*', or 'sync*'.
+//   const A.named1() sync* {}
+//                          ^
+//
+// pkg/front_end/testcases/many_errors.dart:10:26: Error: New expression is not a constant expression.
+//   const A.named2() : x = new Object();
+//                          ^^^
+//
+// pkg/front_end/testcases/many_errors.dart:10:24: Warning: 'x' is a final instance variable that has already been initialized.
+//   const A.named2() : x = new Object();
+//                        ^
+// pkg/front_end/testcases/many_errors.dart:6:9: Context: 'x' was initialized here.
+//   final x = null;
+//         ^
+//
+// pkg/front_end/testcases/many_errors.dart:10:24: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   const A.named2() : x = new Object();
+//                        ^
+//
+// pkg/front_end/testcases/many_errors.dart:13:24: Error: An external or native method can't have a body.
+// external foo(String x) {
+//                        ^
+//
+// pkg/front_end/testcases/many_errors.dart:28:9: Error: The class 'AbstractClass' is abstract and can't be instantiated.
+//   const AbstractClass.id();
+//         ^^^^^^^^^^^^^
+//
+// pkg/front_end/testcases/many_errors.dart:28:9: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+// Try using a constructor or factory that is 'const'.
+//   const AbstractClass.id();
+//         ^
+//
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object {
+  final field dynamic x = null;
+  constructor named1() → self::A
+    : final dynamic #t1 = invalid-expression "pkg/front_end/testcases/many_errors.dart:8:26: Error: Constructor bodies can't use 'async', 'async*', or 'sync*'.
+  const A.named1() sync* {}
+                         ^" {}
+  const constructor named2() → self::A
+    : final dynamic #t2 = throw invalid-expression "pkg/front_end/testcases/many_errors.dart:10:24: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  const A.named2() : x = new Object();
+                       ^", super core::Object::•()
+    ;
+}
+class B extends core::Object {
+  synthetic constructor •() → self::B
+    : super core::Object::•()
+    ;
+}
+class C extends core::Object {
+  field self::B b = null;
+  synthetic constructor •() → self::C
+    : super core::Object::•()
+    ;
+}
+abstract class AbstractClass extends core::Object {
+  const constructor id() → self::AbstractClass
+    : super core::Object::•()
+    ;
+}
+external static method foo(core::String x) → dynamic
+  invalid-expression "pkg/front_end/testcases/many_errors.dart:13:24: Error: An external or native method can't have a body.
+external foo(String x) {
+                       ^";
+static method m() → dynamic {
+  throw invalid-expression "pkg/front_end/testcases/many_errors.dart:28:9: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
+Try using a constructor or factory that is 'const'.
+  const AbstractClass.id();
+        ^";
+  (let final dynamic #t3 = new self::C::•() in #t3.==(null) ? null : let final dynamic #t4 = #t3.b in #t4.==(null) ? #t3.b = new self::B::•() : #t4).b;
+}
+static method main() → dynamic {}
diff --git a/pkg/front_end/testcases/many_errors.dart.outline.expect b/pkg/front_end/testcases/many_errors.dart.outline.expect
new file mode 100644
index 0000000..4efbcd6
--- /dev/null
+++ b/pkg/front_end/testcases/many_errors.dart.outline.expect
@@ -0,0 +1,41 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/many_errors.dart:8:3: Error: A const constructor can't have a body.
+// Try removing either the 'const' keyword or the body.
+//   const A.named1() sync* {}
+//   ^^^^^
+//
+// pkg/front_end/testcases/many_errors.dart:13:1: Error: An external or native method can't have a body.
+// external foo(String x) {
+// ^^^^^^^^
+//
+import self as self;
+import "dart:core" as core;
+
+class A extends core::Object {
+  final field dynamic x;
+  constructor named1() → self::A
+    ;
+  const constructor named2() → self::A
+    ;
+}
+class B extends core::Object {
+  synthetic constructor •() → self::B
+    ;
+}
+class C extends core::Object {
+  field self::B b;
+  synthetic constructor •() → self::C
+    ;
+}
+abstract class AbstractClass extends core::Object {
+  const constructor id() → self::AbstractClass
+    ;
+}
+external static method foo(core::String x) → dynamic;
+static method m() → dynamic
+  ;
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index 4f3da29..94d8017 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -73,6 +73,7 @@
 invalid_type: TypeCheckError
 invocations: RuntimeError
 issue34899: TypeCheckError
+many_errors: VerificationError
 micro: RuntimeError
 mixin_application_override: TypeCheckError
 optional: TypeCheckError
diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status
index b577dfc..bb6e23a 100644
--- a/pkg/front_end/testcases/text_serialization.status
+++ b/pkg/front_end/testcases/text_serialization.status
@@ -669,6 +669,7 @@
 literals: TextSerializationFailure # Was: Pass
 local_generic_function: TextSerializationFailure # Was: Pass
 magic_const: TextSerializationFailure # Was: Pass
+many_errors: VerificationError
 map: TextSerializationFailure # Was: Pass
 metadata_enum: TextSerializationFailure # Was: Pass
 metadata_named_mixin_application: TextSerializationFailure # Was: Pass