[model] Add makAsErroneous to ConstructorDeclaration and encodings

This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/425281/comment/6c94d9e6_cdb51e49/

Change-Id: I97dc157ef5370450b98687840805974a4e4662c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/431480
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/front_end/lib/src/fragment/constructor/declaration.dart b/pkg/front_end/lib/src/fragment/constructor/declaration.dart
index 7f87320..0459929 100644
--- a/pkg/front_end/lib/src/fragment/constructor/declaration.dart
+++ b/pkg/front_end/lib/src/fragment/constructor/declaration.dart
@@ -120,6 +120,13 @@
       SourceConstructorBuilderImpl constructorBuilder,
       ClassHierarchyBase hierarchy,
       List<DelayedDefaultValueCloner> delayedDefaultValueCloners);
+
+  /// Mark the constructor as erroneous.
+  ///
+  /// This is used during the compilation phase to set the appropriate flag on
+  /// the input AST node. The flag helps the verifier to skip apriori erroneous
+  /// members and to avoid reporting cascading errors.
+  void markAsErroneous();
 }
 
 mixin ConstructorDeclarationMixin
@@ -743,6 +750,11 @@
       }
     }
   }
+
+  @override
+  void markAsErroneous() {
+    _encoding.markAsErroneous();
+  }
 }
 
 class RegularConstructorDeclaration
@@ -1292,6 +1304,11 @@
       }
     }
   }
+
+  @override
+  void markAsErroneous() {
+    _encoding.markAsErroneous();
+  }
 }
 
 class ExtensionTypeConstructorDeclaration
diff --git a/pkg/front_end/lib/src/fragment/constructor/encoding.dart b/pkg/front_end/lib/src/fragment/constructor/encoding.dart
index 7e68fb5..6dacff2 100644
--- a/pkg/front_end/lib/src/fragment/constructor/encoding.dart
+++ b/pkg/front_end/lib/src/fragment/constructor/encoding.dart
@@ -298,6 +298,15 @@
     return new ConstructorBodyBuilderContext(
         constructorBuilder, constructorDeclaration, _constructor);
   }
+
+  /// Mark the constructor as erroneous.
+  ///
+  /// This is used during the compilation phase to set the appropriate flag on
+  /// the input AST node. The flag helps the verifier to skip apriori erroneous
+  /// members and to avoid reporting cascading errors.
+  void markAsErroneous() {
+    _constructor.isErroneous = true;
+  }
 }
 
 class ExtensionTypeConstructorEncoding {
@@ -597,4 +606,13 @@
     return new ConstructorBodyBuilderContext(
         constructorBuilder, constructorDeclaration, _constructor);
   }
+
+  /// Mark the constructor as erroneous.
+  ///
+  /// This is used during the compilation phase to set the appropriate flag on
+  /// the input AST node. The flag helps the verifier to skip apriori erroneous
+  /// members and to avoid reporting cascading errors.
+  void markAsErroneous() {
+    _constructor.isErroneous = true;
+  }
 }
diff --git a/pkg/front_end/lib/src/source/source_constructor_builder.dart b/pkg/front_end/lib/src/source/source_constructor_builder.dart
index d5e2407..05307e4 100644
--- a/pkg/front_end/lib/src/source/source_constructor_builder.dart
+++ b/pkg/front_end/lib/src/source/source_constructor_builder.dart
@@ -20,7 +20,6 @@
         templateCantInferTypeDueToCircularity;
 import '../base/modifiers.dart';
 import '../base/name_space.dart';
-import '../base/problems.dart';
 import '../builder/builder.dart';
 import '../builder/constructor_builder.dart';
 import '../builder/declaration_builders.dart';
@@ -703,14 +702,10 @@
 
   @override
   void markAsErroneous() {
-    switch (invokeTarget) {
-      case Constructor constructorTarget:
-        constructorTarget.isErroneous = true;
-      case Procedure procedureTarget:
-        procedureTarget.isErroneous = true;
-      // Coverage-ignore(suite): Not run.
-      case Field():
-        unexpected("Procedure|Constructor", "Field", fileOffset, fileUri);
+    _introductory.markAsErroneous();
+    for (ConstructorDeclaration augmentation in _augmentations) {
+      // Coverage-ignore-block(suite): Not run.
+      augmentation.markAsErroneous();
     }
   }
 }
diff --git a/pkg/front_end/test/coverage_suite_expected.dart b/pkg/front_end/test/coverage_suite_expected.dart
index 9b7bcab..6e71c6b 100644
--- a/pkg/front_end/test/coverage_suite_expected.dart
+++ b/pkg/front_end/test/coverage_suite_expected.dart
@@ -505,12 +505,12 @@
   ),
   // 100.0%.
   "package:front_end/src/fragment/constructor/declaration.dart": (
-    hitCount: 673,
+    hitCount: 679,
     missCount: 0,
   ),
   // 100.0%.
   "package:front_end/src/fragment/constructor/encoding.dart": (
-    hitCount: 375,
+    hitCount: 381,
     missCount: 0,
   ),
   // 100.0%.
@@ -955,7 +955,7 @@
   ),
   // 100.0%.
   "package:front_end/src/source/source_constructor_builder.dart": (
-    hitCount: 427,
+    hitCount: 425,
     missCount: 0,
   ),
   // 100.0%.