[cfe] Remove Builder.isAugment

Change-Id: Idb8d5bb93d4cf8ae46d1d8d975a6c4987cd9b331
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/424041
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/front_end/lib/src/builder/builder.dart b/pkg/front_end/lib/src/builder/builder.dart
index 26e57b5..92cb4a6 100644
--- a/pkg/front_end/lib/src/builder/builder.dart
+++ b/pkg/front_end/lib/src/builder/builder.dart
@@ -2,8 +2,6 @@
 // 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.
 
-import '../base/problems.dart' show unsupported;
-
 abstract class Builder {
   /// Used when multiple things with the same name are declared within the same
   /// parent. Only used for top-level and class-member declarations, not for
@@ -191,9 +189,6 @@
   ///
   bool get isExtensionTypeInstanceMember;
 
-  /// Returns `true` if the related declaration is marked `augment`
-  bool get isAugment;
-
   bool get isStatic;
 
   bool get isSynthetic;
@@ -202,13 +197,6 @@
 
   bool get isTypeParameter;
 
-  /// Adds [augmentation] to this declaration.
-  // TODO(johnniwinther): Remove this augmentations are based on fragments.
-  void addAugmentation(Builder augmentation);
-
-  /// Applies [augmentation] to this declaration.
-  void applyAugmentation(Builder augmentation);
-
   /// Return `true` if this builder is a duplicate of another with the same
   /// name. This is `false` for the builder first declared amongst duplicates.
   bool get isDuplicate;
@@ -252,9 +240,6 @@
   bool get isExtensionTypeInstanceMember => false;
 
   @override
-  bool get isAugment => false;
-
-  @override
   // Coverage-ignore(suite): Not run.
   bool get isStatic => false;
 
@@ -269,18 +254,6 @@
   bool get isTypeParameter => false;
 
   @override
-  // Coverage-ignore(suite): Not run.
-  void addAugmentation(Builder augmentation) {
-    unsupported("${runtimeType}.addAugmentation", fileOffset, fileUri);
-  }
-
-  @override
-  // Coverage-ignore(suite): Not run.
-  void applyAugmentation(Builder augmentation) {
-    unsupported("${runtimeType}.applyAugmentation", fileOffset, fileUri);
-  }
-
-  @override
   bool get isDuplicate => next != null;
 }
 
diff --git a/pkg/front_end/lib/src/source/source_class_builder.dart b/pkg/front_end/lib/src/source/source_class_builder.dart
index c85bc55..178b1fe 100644
--- a/pkg/front_end/lib/src/source/source_class_builder.dart
+++ b/pkg/front_end/lib/src/source/source_class_builder.dart
@@ -234,9 +234,6 @@
   bool get isStatic => _modifiers.isStatic;
 
   @override
-  bool get isAugment => _modifiers.isAugment;
-
-  @override
   bool get isMixinDeclaration => _introductory.isMixinDeclaration;
 
   @override
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 53fedfb..1f3d90f2 100644
--- a/pkg/front_end/lib/src/source/source_constructor_builder.dart
+++ b/pkg/front_end/lib/src/source/source_constructor_builder.dart
@@ -195,9 +195,6 @@
   bool get isStatic => modifiers.isStatic;
 
   @override
-  bool get isAugment => modifiers.isAugment;
-
-  @override
   // Coverage-ignore(suite): Not run.
   Name get memberName => _memberName.name;
 
diff --git a/pkg/front_end/lib/src/source/source_extension_builder.dart b/pkg/front_end/lib/src/source/source_extension_builder.dart
index 91482d9..1b47c6d 100644
--- a/pkg/front_end/lib/src/source/source_extension_builder.dart
+++ b/pkg/front_end/lib/src/source/source_extension_builder.dart
@@ -111,9 +111,6 @@
   bool get isStatic => _modifiers.isStatic;
 
   @override
-  bool get isAugment => _modifiers.isAugment;
-
-  @override
   void buildScopes(LibraryBuilder coreLibrary) {
     _nameSpace = _nameSpaceBuilder.buildNameSpace(
         loader: libraryBuilder.loader,
diff --git a/pkg/front_end/lib/src/source/source_extension_type_declaration_builder.dart b/pkg/front_end/lib/src/source/source_extension_type_declaration_builder.dart
index 7121c74..1324f41 100644
--- a/pkg/front_end/lib/src/source/source_extension_type_declaration_builder.dart
+++ b/pkg/front_end/lib/src/source/source_extension_type_declaration_builder.dart
@@ -149,9 +149,6 @@
   // Coverage-ignore(suite): Not run.
   bool get isStatic => _modifiers.isStatic;
 
-  @override
-  bool get isAugment => _modifiers.isAugment;
-
   SourcePropertyBuilder? get representationFieldBuilder =>
       _representationFieldFragment?.builder;
 
diff --git a/pkg/front_end/lib/src/source/source_factory_builder.dart b/pkg/front_end/lib/src/source/source_factory_builder.dart
index ac75b76..6a73b82 100644
--- a/pkg/front_end/lib/src/source/source_factory_builder.dart
+++ b/pkg/front_end/lib/src/source/source_factory_builder.dart
@@ -118,9 +118,6 @@
   bool get isStatic => modifiers.isStatic;
 
   @override
-  bool get isAugment => modifiers.isAugment;
-
-  @override
   // Coverage-ignore(suite): Not run.
   Builder get getable => this;
 
diff --git a/pkg/front_end/lib/src/source/source_method_builder.dart b/pkg/front_end/lib/src/source/source_method_builder.dart
index 0fe3e52c..ce55162 100644
--- a/pkg/front_end/lib/src/source/source_method_builder.dart
+++ b/pkg/front_end/lib/src/source/source_method_builder.dart
@@ -96,9 +96,6 @@
   bool get isAbstract => _modifiers.isAbstract;
 
   @override
-  bool get isAugment => _modifiers.isAugment;
-
-  @override
   // Coverage-ignore(suite): Not run.
   bool get isFinal => false;
 
diff --git a/pkg/front_end/lib/src/source/source_property_builder.dart b/pkg/front_end/lib/src/source/source_property_builder.dart
index 69ac274..2fa4146 100644
--- a/pkg/front_end/lib/src/source/source_property_builder.dart
+++ b/pkg/front_end/lib/src/source/source_property_builder.dart
@@ -152,9 +152,6 @@
   bool get hasConstField => _modifiers.isConst;
 
   @override
-  bool get isAugment => _modifiers.isAugment;
-
-  @override
   bool get isSynthesized => false;
 
   @override
diff --git a/pkg/front_end/lib/src/source/type_parameter_scope_builder.dart b/pkg/front_end/lib/src/source/type_parameter_scope_builder.dart
index 1082c8b..08390a0 100644
--- a/pkg/front_end/lib/src/source/type_parameter_scope_builder.dart
+++ b/pkg/front_end/lib/src/source/type_parameter_scope_builder.dart
@@ -41,7 +41,6 @@
 import 'source_factory_builder.dart';
 import 'source_library_builder.dart';
 import 'source_loader.dart';
-import 'source_member_builder.dart';
 import 'source_method_builder.dart';
 import 'source_property_builder.dart';
 import 'source_type_alias_builder.dart';
@@ -76,6 +75,8 @@
   final int nameOffset;
   final int nameLength;
   final bool isAugment;
+  final bool inPatch;
+  final bool inLibrary;
   final bool isStatic;
   final _PropertyKind? propertyKind;
 
@@ -85,6 +86,8 @@
       required this.nameOffset,
       required this.nameLength,
       required this.isAugment,
+      required this.inPatch,
+      required this.inLibrary,
       this.propertyKind,
       this.isStatic = true});
 }
@@ -1019,6 +1022,69 @@
   }
 }
 
+/// Reports an error if [fragmentName] is augmenting.
+///
+/// This is called when the first [_PreBuilder] is created, meaning that the
+/// augmentation didn't correspond to an introductory declaration.
+void _checkAugmentation(
+    ProblemReporting problemReporting, _FragmentName fragmentName) {
+  if (fragmentName.isAugment) {
+    Message message;
+    switch (fragmentName.fragment) {
+      case ClassFragment():
+        message = fragmentName.inPatch
+            ? templateUnmatchedPatchClass.withArguments(fragmentName.name)
+            :
+            // Coverage-ignore(suite): Not run.
+            templateUnmatchedAugmentationClass.withArguments(fragmentName.name);
+      case ConstructorFragment():
+      case FactoryFragment():
+      case FieldFragment():
+      case GetterFragment():
+      case MethodFragment():
+      case PrimaryConstructorFragment():
+      case SetterFragment():
+        if (fragmentName.inLibrary) {
+          message = fragmentName.inPatch
+              ? templateUnmatchedPatchLibraryMember
+                  .withArguments(fragmentName.name)
+              :
+              // Coverage-ignore(suite): Not run.
+              templateUnmatchedAugmentationLibraryMember
+                  .withArguments(fragmentName.name);
+        } else {
+          message = fragmentName.inPatch
+              ? templateUnmatchedPatchClassMember
+                  .withArguments(fragmentName.name)
+              :
+              // Coverage-ignore(suite): Not run.
+              templateUnmatchedAugmentationClassMember
+                  .withArguments(fragmentName.name);
+        }
+      case EnumFragment():
+      case EnumElementFragment():
+      case ExtensionFragment():
+      // Coverage-ignore(suite): Not run.
+      case ExtensionTypeFragment():
+      // Coverage-ignore(suite): Not run.
+      case MixinFragment():
+      // Coverage-ignore(suite): Not run.
+      case NamedMixinApplicationFragment():
+      // Coverage-ignore(suite): Not run.
+      case TypedefFragment():
+        // TODO(johnniwinther): Specialize more messages.
+        message = fragmentName.inPatch
+            ? templateUnmatchedPatchDeclaration.withArguments(fragmentName.name)
+            :
+            // Coverage-ignore(suite): Not run.
+            templateUnmatchedAugmentationDeclaration
+                .withArguments(fragmentName.name);
+    }
+    problemReporting.addProblem(message, fragmentName.nameOffset,
+        fragmentName.nameLength, fragmentName.fileUri);
+  }
+}
+
 _PreBuilder _createPreBuilder(_FragmentName fragmentName) {
   switch (fragmentName.fragment) {
     case ClassFragment():
@@ -1068,6 +1134,7 @@
         return;
       }
     }
+    _checkAugmentation(problemReporting, fragmentName);
     thesePreBuilders.add(_createPreBuilder(fragmentName));
     if (otherPreBuilders.isNotEmpty) {
       otherPreBuilders.first.checkFragment(problemReporting, fragmentName);
@@ -1105,139 +1172,207 @@
   for (Fragment fragment in fragments) {
     switch (fragment) {
       case ClassFragment():
-        addFragment(new _FragmentName(_FragmentKind.Class, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: fragment.modifiers.isAugment));
+        addFragment(new _FragmentName(
+          _FragmentKind.Class,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: fragment.modifiers.isAugment,
+          inPatch: fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: true,
+        ));
       case EnumFragment():
-        addFragment(new _FragmentName(_FragmentKind.Enum, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            // TODO(johnniwinther): Support enum augmentations.
-            isAugment: false));
+        addFragment(new _FragmentName(
+          _FragmentKind.Enum, fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          // TODO(johnniwinther): Support enum augmentations.
+          isAugment: false,
+          inPatch: fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: true,
+        ));
       case ExtensionTypeFragment():
-        addFragment(new _FragmentName(_FragmentKind.ExtensionType, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: fragment.modifiers.isAugment));
+        addFragment(new _FragmentName(
+          _FragmentKind.ExtensionType,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: fragment.modifiers.isAugment,
+          inPatch: fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: true,
+        ));
       case MethodFragment():
-        addFragment(new _FragmentName(_FragmentKind.Method, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: fragment.modifiers.isAugment,
-            isStatic:
-                declarationBuilder == null || fragment.modifiers.isStatic));
+        addFragment(new _FragmentName(
+          _FragmentKind.Method,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: fragment.modifiers.isAugment,
+          isStatic: declarationBuilder == null || fragment.modifiers.isStatic,
+          inPatch: fragment.enclosingDeclaration?.isPatch ??
+              fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: declarationBuilder == null,
+        ));
       case MixinFragment():
-        addFragment(new _FragmentName(_FragmentKind.Mixin, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: fragment.modifiers.isAugment));
+        addFragment(new _FragmentName(
+          _FragmentKind.Mixin,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: fragment.modifiers.isAugment,
+          inPatch: fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: true,
+        ));
       case NamedMixinApplicationFragment():
         addFragment(new _FragmentName(
-            _FragmentKind.NamedMixinApplication, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: fragment.modifiers.isAugment));
+          _FragmentKind.NamedMixinApplication,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: fragment.modifiers.isAugment,
+          inPatch: fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: true,
+        ));
       case TypedefFragment():
-        addFragment(new _FragmentName(_FragmentKind.Typedef, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            // TODO(johnniwinther): Support typedef augmentations.
-            isAugment: false));
+        addFragment(new _FragmentName(
+          _FragmentKind.Typedef, fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          // TODO(johnniwinther): Support typedef augmentations.
+          isAugment: false,
+          inPatch: fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: true,
+        ));
       case ExtensionFragment():
         if (!fragment.isUnnamed) {
-          addFragment(new _FragmentName(_FragmentKind.Extension, fragment,
-              fileUri: fragment.fileUri,
-              name: fragment.name,
-              nameOffset: fragment.fileOffset,
-              nameLength: fragment.name.length,
-              isAugment: fragment.modifiers.isAugment));
+          addFragment(new _FragmentName(
+            _FragmentKind.Extension,
+            fragment,
+            fileUri: fragment.fileUri,
+            name: fragment.name,
+            nameOffset: fragment.fileOffset,
+            nameLength: fragment.name.length,
+            isAugment: fragment.modifiers.isAugment,
+            inPatch: fragment.enclosingCompilationUnit.isPatch,
+            inLibrary: true,
+          ));
         } else {
           unnamedFragments.add(fragment);
         }
       case FactoryFragment():
-        addFragment(new _FragmentName(_FragmentKind.Factory, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.constructorName.fullName,
-            nameOffset: fragment.constructorName.fullNameOffset,
-            nameLength: fragment.constructorName.fullNameLength,
-            isAugment: fragment.modifiers.isAugment));
+        addFragment(new _FragmentName(
+          _FragmentKind.Factory,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.constructorName.fullName,
+          nameOffset: fragment.constructorName.fullNameOffset,
+          nameLength: fragment.constructorName.fullNameLength,
+          isAugment: fragment.modifiers.isAugment,
+          inPatch: fragment.enclosingDeclaration.isPatch,
+          inLibrary: declarationBuilder == null,
+        ));
       case ConstructorFragment():
-        addFragment(new _FragmentName(_FragmentKind.Constructor, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.constructorName.fullName,
-            nameOffset: fragment.constructorName.fullNameOffset,
-            nameLength: fragment.constructorName.fullNameLength,
-            isAugment: fragment.modifiers.isAugment));
+        addFragment(new _FragmentName(
+          _FragmentKind.Constructor,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.constructorName.fullName,
+          nameOffset: fragment.constructorName.fullNameOffset,
+          nameLength: fragment.constructorName.fullNameLength,
+          isAugment: fragment.modifiers.isAugment,
+          inPatch: fragment.enclosingDeclaration.isPatch,
+          inLibrary: declarationBuilder == null,
+        ));
       case PrimaryConstructorFragment():
-        addFragment(new _FragmentName(_FragmentKind.Constructor, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.constructorName.fullName,
-            nameOffset: fragment.constructorName.fullNameOffset,
-            nameLength: fragment.constructorName.fullNameLength,
-            isAugment: fragment.modifiers.isAugment));
+        addFragment(new _FragmentName(
+          _FragmentKind.Constructor,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.constructorName.fullName,
+          nameOffset: fragment.constructorName.fullNameOffset,
+          nameLength: fragment.constructorName.fullNameLength,
+          isAugment: fragment.modifiers.isAugment,
+          inPatch: fragment.enclosingDeclaration.isPatch,
+          inLibrary: declarationBuilder == null,
+        ));
       case FieldFragment():
         _FragmentName fragmentName = new _FragmentName(
-            _FragmentKind.Property, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: fragment.modifiers.isAugment,
-            propertyKind: fragment.hasSetter
-                ? _PropertyKind.Field
-                : _PropertyKind.FinalField,
-            isStatic:
-                declarationBuilder == null || fragment.modifiers.isStatic);
+          _FragmentKind.Property,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: fragment.modifiers.isAugment,
+          propertyKind: fragment.hasSetter
+              ? _PropertyKind.Field
+              : _PropertyKind.FinalField,
+          isStatic: declarationBuilder == null || fragment.modifiers.isStatic,
+          inPatch: fragment.enclosingDeclaration?.isPatch ??
+              fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: declarationBuilder == null,
+        );
         addFragment(fragmentName);
       case GetterFragment():
         _FragmentName fragmentName = new _FragmentName(
-            _FragmentKind.Property, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: fragment.modifiers.isAugment,
-            propertyKind: _PropertyKind.Getter,
-            isStatic:
-                declarationBuilder == null || fragment.modifiers.isStatic);
+          _FragmentKind.Property,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: fragment.modifiers.isAugment,
+          propertyKind: _PropertyKind.Getter,
+          isStatic: declarationBuilder == null || fragment.modifiers.isStatic,
+          inPatch: fragment.enclosingDeclaration?.isPatch ??
+              fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: declarationBuilder == null,
+        );
         addFragment(fragmentName);
       case SetterFragment():
         _FragmentName fragmentName = new _FragmentName(
-            _FragmentKind.Property, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: fragment.modifiers.isAugment,
-            propertyKind: _PropertyKind.Setter,
-            isStatic:
-                declarationBuilder == null || fragment.modifiers.isStatic);
+          _FragmentKind.Property,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: fragment.modifiers.isAugment,
+          propertyKind: _PropertyKind.Setter,
+          isStatic: declarationBuilder == null || fragment.modifiers.isStatic,
+          inPatch: fragment.enclosingDeclaration?.isPatch ??
+              fragment.enclosingCompilationUnit.isPatch,
+          inLibrary: declarationBuilder == null,
+        );
         addFragment(fragmentName);
       case EnumElementFragment():
         _FragmentName fragmentName = new _FragmentName(
-            _FragmentKind.Property, fragment,
-            fileUri: fragment.fileUri,
-            name: fragment.name,
-            nameOffset: fragment.nameOffset,
-            nameLength: fragment.name.length,
-            isAugment: false,
-            propertyKind: _PropertyKind.FinalField,
-            isStatic: true);
+          _FragmentKind.Property,
+          fragment,
+          fileUri: fragment.fileUri,
+          name: fragment.name,
+          nameOffset: fragment.nameOffset,
+          nameLength: fragment.name.length,
+          isAugment: false,
+          propertyKind: _PropertyKind.FinalField,
+          isStatic: true,
+          inPatch: fragment.enclosingDeclaration.isPatch,
+          inLibrary: declarationBuilder == null,
+        );
         addFragment(fragmentName);
     }
   }
@@ -1475,39 +1610,6 @@
 
       if (existing == declaration) return;
 
-      if (declaration.isAugment) {
-        if (existing != null) {
-          // Coverage-ignore-block(suite): Not run.
-          existing.addAugmentation(declaration);
-          return;
-        } else {
-          if (addBuilder.inPatch) {
-            Message message;
-            if (declaration is SourceMemberBuilder) {
-              message = addBuilder.inPatch
-                  ? templateUnmatchedPatchLibraryMember.withArguments(name)
-                  :
-                  // Coverage-ignore(suite): Not run.
-                  templateUnmatchedAugmentationLibraryMember
-                      .withArguments(name);
-            } else if (declaration is SourceClassBuilder) {
-              message = addBuilder.inPatch
-                  ? templateUnmatchedPatchClass.withArguments(name)
-                  :
-                  // Coverage-ignore(suite): Not run.
-                  templateUnmatchedAugmentationClass.withArguments(name);
-            } else {
-              message = addBuilder.inPatch
-                  ? templateUnmatchedPatchDeclaration.withArguments(name)
-                  :
-                  // Coverage-ignore(suite): Not run.
-                  templateUnmatchedAugmentationDeclaration.withArguments(name);
-            }
-            problemReporting.addProblem(message, charOffset, noLength, fileUri);
-          }
-        }
-      }
-
       if (addBuilder.inPatch &&
           !name.startsWith('_') &&
           !_allowInjectedPublicMember(enclosingLibraryBuilder, declaration)) {
@@ -1787,29 +1889,6 @@
 
       if (existing == declaration) return;
 
-      if (declaration.isAugment) {
-        if (existing != null) {
-          // Coverage-ignore-block(suite): Not run.
-          existing.addAugmentation(declaration);
-          return;
-        } else {
-          Message message;
-          if (declaration is SourceMemberBuilder) {
-            message = addBuilder.inPatch
-                ? templateUnmatchedPatchClassMember.withArguments(name)
-                :
-                // Coverage-ignore(suite): Not run.
-                templateUnmatchedAugmentationClassMember.withArguments(name);
-          } else {
-            // Coverage-ignore-block(suite): Not run.
-            message = addBuilder.inPatch
-                ? templateUnmatchedPatchDeclaration.withArguments(name)
-                : templateUnmatchedAugmentationDeclaration.withArguments(name);
-          }
-          problemReporting.addProblem(message, charOffset, noLength, fileUri);
-        }
-      }
-
       if (addBuilder.inPatch &&
           !name.startsWith('_') &&
           !_allowInjectedPublicMember(enclosingLibraryBuilder, declaration)) {
diff --git a/pkg/front_end/test/coverage_suite_expected.dart b/pkg/front_end/test/coverage_suite_expected.dart
index f50757b..431c55e 100644
--- a/pkg/front_end/test/coverage_suite_expected.dart
+++ b/pkg/front_end/test/coverage_suite_expected.dart
@@ -245,7 +245,7 @@
   ),
   // 100.0%.
   "package:front_end/src/builder/builder.dart": (
-    hitCount: 12,
+    hitCount: 11,
     missCount: 0,
   ),
   // 100.0%.
@@ -935,7 +935,7 @@
   ),
   // 100.0%.
   "package:front_end/src/source/source_class_builder.dart": (
-    hitCount: 1427,
+    hitCount: 1424,
     missCount: 0,
   ),
   // 100.0%.
@@ -945,7 +945,7 @@
   ),
   // 100.0%.
   "package:front_end/src/source/source_constructor_builder.dart": (
-    hitCount: 424,
+    hitCount: 421,
     missCount: 0,
   ),
   // 100.0%.
@@ -955,18 +955,18 @@
   ),
   // 100.0%.
   "package:front_end/src/source/source_extension_builder.dart": (
-    hitCount: 132,
+    hitCount: 129,
     missCount: 0,
   ),
   // 100.0%.
   "package:front_end/src/source/source_extension_type_declaration_builder.dart":
       (
-    hitCount: 539,
+    hitCount: 536,
     missCount: 0,
   ),
   // 100.0%.
   "package:front_end/src/source/source_factory_builder.dart": (
-    hitCount: 140,
+    hitCount: 137,
     missCount: 0,
   ),
   // 100.0%.
@@ -991,12 +991,12 @@
   ),
   // 100.0%.
   "package:front_end/src/source/source_method_builder.dart": (
-    hitCount: 199,
+    hitCount: 196,
     missCount: 0,
   ),
   // 100.0%.
   "package:front_end/src/source/source_property_builder.dart": (
-    hitCount: 670,
+    hitCount: 667,
     missCount: 0,
   ),
   // 100.0%.
@@ -1016,7 +1016,7 @@
   ),
   // 100.0%.
   "package:front_end/src/source/type_parameter_scope_builder.dart": (
-    hitCount: 1748,
+    hitCount: 1802,
     missCount: 0,
   ),
   // 100.0%.
diff --git a/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.expect b/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.expect
index 16ac87a..a878ff4 100644
--- a/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.expect
+++ b/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.expect
@@ -48,7 +48,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:22:6: Error: Patch member 'missingOriginMethod' doesn't match a member in the origin library.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 // void missingOriginMethod() {} /* Error: missing origin method */
-//      ^
+//      ^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:22:6: Error: Can't inject public 'missingOriginMethod' into 'dart:test'.
 // Make 'missingOriginMethod' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -58,7 +58,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:25:7: Error: Patch class 'MissingOriginClass' doesn't match a class in the origin library.
 // Try changing the name to an existing class or removing the '@patch' annotation.
 // class MissingOriginClass {} /* Error: missing origin class */
-//       ^
+//       ^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:25:7: Error: Can't inject public 'MissingOriginClass' into 'dart:test'.
 // Make 'MissingOriginClass' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -68,7 +68,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:28:11: Error: Patch 'MissingOriginExtension' doesn't match a declaration in the origin library.
 // Try changing the name to an existing declaration or removing the '@patch' annotation.
 // extension MissingOriginExtension on int {} /* Error: missing origin extension */
-//           ^
+//           ^^^^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:28:11: Error: Can't inject public 'MissingOriginExtension' into 'dart:test'.
 // Make 'MissingOriginExtension' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -89,15 +89,15 @@
 //   void existingOriginMethod() {}
 //        ^^^^^^^^^^^^^^^^^^^^
 //
-// pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:11:3: Error: Patch member 'missingOriginConstructor' doesn't match a member in the origin class.
+// pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:11:3: Error: Patch member 'Class.missingOriginConstructor' doesn't match a member in the origin class.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 //   Class.missingOriginConstructor(); /* Error: missing origin class */
-//   ^
+//   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:16:8: Error: Patch member 'missingOriginMethod' doesn't match a member in the origin class.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 //   void missingOriginMethod() {} /* Error: missing origin method */
-//        ^
+//        ^^^^^^^^^^^^^^^^^^^
 //
 import self as self2;
 import "dart:_internal" as _in;
diff --git a/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.modular.expect b/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.modular.expect
index 16ac87a..a878ff4 100644
--- a/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.modular.expect
+++ b/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.modular.expect
@@ -48,7 +48,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:22:6: Error: Patch member 'missingOriginMethod' doesn't match a member in the origin library.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 // void missingOriginMethod() {} /* Error: missing origin method */
-//      ^
+//      ^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:22:6: Error: Can't inject public 'missingOriginMethod' into 'dart:test'.
 // Make 'missingOriginMethod' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -58,7 +58,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:25:7: Error: Patch class 'MissingOriginClass' doesn't match a class in the origin library.
 // Try changing the name to an existing class or removing the '@patch' annotation.
 // class MissingOriginClass {} /* Error: missing origin class */
-//       ^
+//       ^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:25:7: Error: Can't inject public 'MissingOriginClass' into 'dart:test'.
 // Make 'MissingOriginClass' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -68,7 +68,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:28:11: Error: Patch 'MissingOriginExtension' doesn't match a declaration in the origin library.
 // Try changing the name to an existing declaration or removing the '@patch' annotation.
 // extension MissingOriginExtension on int {} /* Error: missing origin extension */
-//           ^
+//           ^^^^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:28:11: Error: Can't inject public 'MissingOriginExtension' into 'dart:test'.
 // Make 'MissingOriginExtension' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -89,15 +89,15 @@
 //   void existingOriginMethod() {}
 //        ^^^^^^^^^^^^^^^^^^^^
 //
-// pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:11:3: Error: Patch member 'missingOriginConstructor' doesn't match a member in the origin class.
+// pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:11:3: Error: Patch member 'Class.missingOriginConstructor' doesn't match a member in the origin class.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 //   Class.missingOriginConstructor(); /* Error: missing origin class */
-//   ^
+//   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:16:8: Error: Patch member 'missingOriginMethod' doesn't match a member in the origin class.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 //   void missingOriginMethod() {} /* Error: missing origin method */
-//        ^
+//        ^^^^^^^^^^^^^^^^^^^
 //
 import self as self2;
 import "dart:_internal" as _in;
diff --git a/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.outline.expect b/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.outline.expect
index db1953a..26edcb7 100644
--- a/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.outline.expect
+++ b/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.outline.expect
@@ -49,7 +49,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:22:6: Error: Patch member 'missingOriginMethod' doesn't match a member in the origin library.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 // void missingOriginMethod() {} /* Error: missing origin method */
-//      ^
+//      ^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:22:6: Error: Can't inject public 'missingOriginMethod' into 'dart:test'.
 // Make 'missingOriginMethod' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -59,7 +59,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:25:7: Error: Patch class 'MissingOriginClass' doesn't match a class in the origin library.
 // Try changing the name to an existing class or removing the '@patch' annotation.
 // class MissingOriginClass {} /* Error: missing origin class */
-//       ^
+//       ^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:25:7: Error: Can't inject public 'MissingOriginClass' into 'dart:test'.
 // Make 'MissingOriginClass' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -69,7 +69,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:28:11: Error: Patch 'MissingOriginExtension' doesn't match a declaration in the origin library.
 // Try changing the name to an existing declaration or removing the '@patch' annotation.
 // extension MissingOriginExtension on int {} /* Error: missing origin extension */
-//           ^
+//           ^^^^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:28:11: Error: Can't inject public 'MissingOriginExtension' into 'dart:test'.
 // Make 'MissingOriginExtension' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -90,15 +90,15 @@
 //   void existingOriginMethod() {}
 //        ^^^^^^^^^^^^^^^^^^^^
 //
-// pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:11:3: Error: Patch member 'missingOriginConstructor' doesn't match a member in the origin class.
+// pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:11:3: Error: Patch member 'Class.missingOriginConstructor' doesn't match a member in the origin class.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 //   Class.missingOriginConstructor(); /* Error: missing origin class */
-//   ^
+//   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:16:8: Error: Patch member 'missingOriginMethod' doesn't match a member in the origin class.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 //   void missingOriginMethod() {} /* Error: missing origin method */
-//        ^
+//        ^^^^^^^^^^^^^^^^^^^
 //
 import self as self2;
 import "dart:_internal" as _in;
diff --git a/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.transformed.expect b/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.transformed.expect
index 16ac87a..a878ff4 100644
--- a/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.transformed.expect
+++ b/pkg/front_end/testcases/general/patch_conflict/main.dart.strong.transformed.expect
@@ -48,7 +48,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:22:6: Error: Patch member 'missingOriginMethod' doesn't match a member in the origin library.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 // void missingOriginMethod() {} /* Error: missing origin method */
-//      ^
+//      ^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:22:6: Error: Can't inject public 'missingOriginMethod' into 'dart:test'.
 // Make 'missingOriginMethod' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -58,7 +58,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:25:7: Error: Patch class 'MissingOriginClass' doesn't match a class in the origin library.
 // Try changing the name to an existing class or removing the '@patch' annotation.
 // class MissingOriginClass {} /* Error: missing origin class */
-//       ^
+//       ^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:25:7: Error: Can't inject public 'MissingOriginClass' into 'dart:test'.
 // Make 'MissingOriginClass' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -68,7 +68,7 @@
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:28:11: Error: Patch 'MissingOriginExtension' doesn't match a declaration in the origin library.
 // Try changing the name to an existing declaration or removing the '@patch' annotation.
 // extension MissingOriginExtension on int {} /* Error: missing origin extension */
-//           ^
+//           ^^^^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:28:11: Error: Can't inject public 'MissingOriginExtension' into 'dart:test'.
 // Make 'MissingOriginExtension' private, or make sure injected library has "dart" scheme and is private (e.g. "dart:_internal").
@@ -89,15 +89,15 @@
 //   void existingOriginMethod() {}
 //        ^^^^^^^^^^^^^^^^^^^^
 //
-// pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:11:3: Error: Patch member 'missingOriginConstructor' doesn't match a member in the origin class.
+// pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:11:3: Error: Patch member 'Class.missingOriginConstructor' doesn't match a member in the origin class.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 //   Class.missingOriginConstructor(); /* Error: missing origin class */
-//   ^
+//   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 //
 // pkg/front_end/testcases/general/patch_conflict/patch_lib.dart:16:8: Error: Patch member 'missingOriginMethod' doesn't match a member in the origin class.
 // Try changing the name to an existing member or removing the '@patch' annotation.
 //   void missingOriginMethod() {} /* Error: missing origin method */
-//        ^
+//        ^^^^^^^^^^^^^^^^^^^
 //
 import self as self2;
 import "dart:_internal" as _in;