[cfe] Move _omittedTypeDeclarationBuilders to SourceCompilationUnitImpl

Change-Id: I41dab2a2fee27f988e8e26de1575651cadde848e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375120
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
diff --git a/pkg/front_end/lib/src/source/source_compilation_unit.dart b/pkg/front_end/lib/src/source/source_compilation_unit.dart
index 5bfd64b..aa51c82 100644
--- a/pkg/front_end/lib/src/source/source_compilation_unit.dart
+++ b/pkg/front_end/lib/src/source/source_compilation_unit.dart
@@ -88,14 +88,23 @@
   final List<StructuralVariableBuilder> _unboundStructuralVariables =
       <StructuralVariableBuilder>[];
 
+  /// Map from synthesized names used for omitted types to their corresponding
+  /// synthesized type declarations.
+  ///
+  /// This is used in macro generated code to create type annotations from
+  /// inferred types in the original code.
+  final Map<String, Builder>? _omittedTypeDeclarationBuilders;
+
   SourceCompilationUnitImpl(
       this._sourceLibraryBuilder, this._libraryTypeParameterScopeBuilder,
       {required this.importUri,
       required this.fileUri,
       required this.packageLanguageVersion,
-      required this.indexedLibrary})
+      required this.indexedLibrary,
+      Map<String, Builder>? omittedTypeDeclarationBuilders})
       : currentTypeParameterScopeBuilder = _libraryTypeParameterScopeBuilder,
-        _languageVersion = packageLanguageVersion;
+        _languageVersion = packageLanguageVersion,
+        _omittedTypeDeclarationBuilders = omittedTypeDeclarationBuilders;
 
   @override
   LibraryFeatures get libraryFeatures => _sourceLibraryBuilder.libraryFeatures;
@@ -2656,10 +2665,9 @@
       List<TypeBuilder>? arguments,
       int charOffset,
       {required InstanceTypeVariableAccessState instanceTypeVariableAccess}) {
-    if (_sourceLibraryBuilder._omittedTypeDeclarationBuilders != null) {
+    if (_omittedTypeDeclarationBuilders != null) {
       // Coverage-ignore-block(suite): Not run.
-      Builder? builder =
-          _sourceLibraryBuilder._omittedTypeDeclarationBuilders[typeName.name];
+      Builder? builder = _omittedTypeDeclarationBuilders[typeName.name];
       if (builder is OmittedTypeDeclarationBuilder) {
         return new DependentTypeBuilder(builder.omittedTypeBuilder);
       }
diff --git a/pkg/front_end/lib/src/source/source_library_builder.dart b/pkg/front_end/lib/src/source/source_library_builder.dart
index c535450..7bf9adc 100644
--- a/pkg/front_end/lib/src/source/source_library_builder.dart
+++ b/pkg/front_end/lib/src/source/source_library_builder.dart
@@ -218,14 +218,6 @@
   /// `true` if this is a patch library.
   final bool isPatchLibrary;
 
-  /// Map from synthesized names used for omitted types to their corresponding
-  /// synthesized type declarations.
-  ///
-  /// This is used in macro generated code to create type annotations from
-  /// inferred types in the original code.
-  // TODO(johnniwinther): Move to [SourceCompilationUnitImpl].
-  final Map<String, Builder>? _omittedTypeDeclarationBuilders;
-
   MergedLibraryScope? _mergedScope;
 
   /// If `null`, [SourceLoader.computeFieldPromotability] hasn't been called
@@ -284,7 +276,6 @@
       required bool isPatch,
       Map<String, Builder>? omittedTypes})
       : _immediateOrigin = origin,
-        _omittedTypeDeclarationBuilders = omittedTypes,
         libraryName = new LibraryName(library.reference),
         isAugmentationLibrary = isAugmentation,
         isPatchLibrary = isPatch,
@@ -311,7 +302,8 @@
         importUri: importUri,
         fileUri: fileUri,
         packageLanguageVersion: packageLanguageVersion,
-        indexedLibrary: indexedLibrary);
+        indexedLibrary: indexedLibrary,
+        omittedTypeDeclarationBuilders: omittedTypes);
   }
 
   MergedLibraryScope get mergedScope {