Elements. Remove V1 FunctionElement.

Change-Id: Ic0e5828b00bfd234106b582412ed2cbe2cff4ec8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423400
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analyzer/api.txt b/pkg/analyzer/api.txt
index 660367d..b950f44 100644
--- a/pkg/analyzer/api.txt
+++ b/pkg/analyzer/api.txt
@@ -2978,7 +2978,6 @@
     new (constructor: CompilationUnitElement Function())
     accessors (getter: List<PropertyAccessorElement>)
     enclosingElement3 (getter: CompilationUnitElement?)
-    functions (getter: List<FunctionElement>)
     libraryExports (getter: List<LibraryExportElement>)
     libraryImportPrefixes (getter: List<PrefixElement>)
     libraryImports (getter: List<LibraryImportElement>)
@@ -3174,14 +3173,6 @@
   FieldFormalParameterElement (class extends Object implements ParameterElement, deprecated):
     new (constructor: FieldFormalParameterElement Function())
     field (getter: FieldElement?, deprecated)
-  FunctionElement (class extends Object implements ExecutableElement, LocalElement, deprecated):
-    CALL_METHOD_NAME (static getter: String)
-    LOAD_LIBRARY_NAME (static getter: String)
-    MAIN_FUNCTION_NAME (static getter: String)
-    NO_SUCH_METHOD_METHOD_NAME (static getter: String)
-    new (constructor: FunctionElement Function())
-    isDartCoreIdentical (getter: bool)
-    isEntryPoint (getter: bool)
   FunctionTypedElement (class extends Object implements TypeParameterizedElement, deprecated):
     new (constructor: FunctionTypedElement Function())
     parameters (getter: List<ParameterElement>)
@@ -3215,7 +3206,6 @@
     new (constructor: LibraryElement Function())
     definingCompilationUnit (getter: CompilationUnitElement, deprecated)
     enclosingElement3 (getter: Null)
-    entryPoint (getter: FunctionElement?, deprecated)
     exportNamespace (getter: Namespace)
     exportedLibraries (getter: List<LibraryElement>)
     featureSet (getter: FeatureSet)
@@ -3226,7 +3216,6 @@
     isInSdk (getter: bool)
     languageVersion (getter: LibraryLanguageVersion)
     library (getter: LibraryElement)
-    loadLibraryFunction (getter: FunctionElement, deprecated)
     name (getter: String)
     publicNamespace (getter: Namespace)
     session (getter: AnalysisSession)
diff --git a/pkg/analyzer/lib/dart/element/element.dart b/pkg/analyzer/lib/dart/element/element.dart
index 89fedf3..ad89114 100644
--- a/pkg/analyzer/lib/dart/element/element.dart
+++ b/pkg/analyzer/lib/dart/element/element.dart
@@ -105,9 +105,6 @@
   @override
   CompilationUnitElement? get enclosingElement3;
 
-  /// The top-level functions declared in this compilation unit.
-  List<FunctionElement> get functions;
-
   /// The libraries exported by this unit.
   List<LibraryExportElement> get libraryExports;
 
@@ -915,36 +912,6 @@
   FieldElement? get field;
 }
 
-/// A (non-method) function. This can be either a top-level function, a local
-/// function, a closure, or the initialization expression for a field or
-/// variable.
-///
-/// Clients may not extend, implement or mix-in this class.
-@Deprecated('Use TopLevelFunctionElement or LocalFunctionElement')
-abstract class FunctionElement implements ExecutableElement, LocalElement {
-  /// The name of the method that can be implemented by a class to allow its
-  /// instances to be invoked as if they were a function.
-  static final String CALL_METHOD_NAME = "call";
-
-  /// The name of the synthetic function defined for libraries that are
-  /// deferred.
-  static final String LOAD_LIBRARY_NAME = "loadLibrary";
-
-  /// The name of the function used as an entry point.
-  static const String MAIN_FUNCTION_NAME = "main";
-
-  /// The name of the method that will be invoked if an attempt is made to
-  /// invoke an undefined method on an object.
-  static final String NO_SUCH_METHOD_METHOD_NAME = "noSuchMethod";
-
-  /// Whether the function represents `identical` from the `dart:core` library.
-  bool get isDartCoreIdentical;
-
-  /// Whether the function is an entry point, i.e. a top-level function and
-  /// has the name `main`.
-  bool get isEntryPoint;
-}
-
 /// An element that has a [FunctionType] as its [type].
 ///
 /// This also provides convenient access to the parameters and return type.
@@ -1059,14 +1026,6 @@
   @override
   Null get enclosingElement3;
 
-  /// The entry point for this library, or `null` if this library does
-  /// not have an entry point.
-  ///
-  /// The entry point is defined to be a zero argument top-level function
-  /// whose name is `main`.
-  @Deprecated(elementModelDeprecationMsg)
-  FunctionElement? get entryPoint;
-
   /// The libraries that are exported from this library.
   List<LibraryElement> get exportedLibraries;
 
@@ -1105,12 +1064,6 @@
   @override
   LibraryElement get library;
 
-  /// The element representing the synthetic function `loadLibrary` that is
-  /// implicitly defined for this library if the library is imported using a
-  /// deferred import.
-  @Deprecated(elementModelDeprecationMsg)
-  FunctionElement get loadLibraryFunction;
-
   /// The name of this library, possibly the empty string if this library does
   /// not have an explicit name.
   @override
diff --git a/pkg/analyzer/lib/src/dart/element/element.dart b/pkg/analyzer/lib/src/dart/element/element.dart
index d067724..4eefc80 100644
--- a/pkg/analyzer/lib/src/dart/element/element.dart
+++ b/pkg/analyzer/lib/src/dart/element/element.dart
@@ -877,7 +877,6 @@
   List<ExtensionTypeFragment> get extensionTypes2 =>
       extensionTypes.cast<ExtensionTypeFragment>();
 
-  @override
   List<TopLevelFunctionFragmentImpl> get functions {
     return _functions;
   }
@@ -4961,11 +4960,7 @@
 }
 
 sealed class FunctionElementImpl extends ExecutableElementImpl
-    implements
-        // ignore:deprecated_member_use_from_same_package,analyzer_use_new_elements
-        FunctionElement,
-        FunctionTypedElementImpl,
-        ExecutableElementOrMember {
+    implements FunctionTypedElementImpl, ExecutableElementOrMember {
   @override
   String? name2;
 
@@ -6630,12 +6625,6 @@
     return _definingCompilationUnit;
   }
 
-  @Deprecated('Use entryPoint2 instead')
-  @override
-  FunctionElement? get entryPoint {
-    return entryPoint2?.lastFragment;
-  }
-
   @override
   TopLevelFunctionElementImpl? get entryPoint2 {
     linkedData?.read(this);
@@ -6783,11 +6772,6 @@
   }
 
   @override
-  TopLevelFunctionFragmentImpl get loadLibraryFunction {
-    return loadLibraryFunction2.firstFragment;
-  }
-
-  @override
   TopLevelFunctionElementImpl get loadLibraryFunction2 {
     return loadLibraryProvider.getElement(this);
   }
@@ -7294,12 +7278,6 @@
   LocalFunctionFragmentImpl.forOffset(super.nameOffset) : super.forOffset();
 
   @override
-  bool get isDartCoreIdentical => false;
-
-  @override
-  bool get isEntryPoint => false;
-
-  @override
   bool get _includeNameOffsetInIdentifier {
     return super._includeNameOffsetInIdentifier ||
         enclosingElement3 is ExecutableFragment ||
@@ -10017,10 +9995,14 @@
   }
 
   @override
-  bool get isDartCoreIdentical => firstFragment.isDartCoreIdentical;
+  bool get isDartCoreIdentical {
+    return name3 == 'identical' && library2.isDartCore;
+  }
 
   @override
-  bool get isEntryPoint => firstFragment.isEntryPoint;
+  bool get isEntryPoint {
+    return displayName == TopLevelFunctionElement.MAIN_FUNCTION_NAME;
+  }
 
   @override
   ElementKind get kind => ElementKind.FUNCTION;
@@ -10065,16 +10047,6 @@
 
   @override
   set enclosingElement3(covariant CompilationUnitElementImpl element);
-
-  @override
-  bool get isDartCoreIdentical {
-    return name == 'identical' && library.isDartCore;
-  }
-
-  @override
-  bool get isEntryPoint {
-    return displayName == TopLevelFunctionElement.MAIN_FUNCTION_NAME;
-  }
 }
 
 class TopLevelVariableElementImpl extends PropertyInducingElementImpl
diff --git a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
index a949f7c..4157ea9 100644
--- a/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/method_invocation_resolver.dart
@@ -780,9 +780,9 @@
         var firstPrefix = imports[0].prefix2;
         if (firstPrefix != null && firstPrefix.isDeferred) {
           var importedLibrary = imports[0].importedLibrary;
-          var element = importedLibrary?.loadLibraryFunction;
+          var element = importedLibrary?.loadLibraryFunction2;
           if (element != null) {
-            nameNode.element = element.asElement2;
+            nameNode.element = element;
             _setResolution(node, element.type, whyNotPromotedArguments,
                 contextType: contextType);
             return null;
diff --git a/pkg/analyzer/test/src/summary/elements/library_import_test.dart b/pkg/analyzer/test/src/summary/elements/library_import_test.dart
index fd7fa1f..57cb554 100644
--- a/pkg/analyzer/test/src/summary/elements/library_import_test.dart
+++ b/pkg/analyzer/test/src/summary/elements/library_import_test.dart
@@ -1127,7 +1127,7 @@
     var library = await buildLibrary("import 'foo.dart';");
     var libraryImports = library.definingCompilationUnit.libraryImports;
     var importedLibrary = libraryImports[0].importedLibrary!;
-    expect(importedLibrary.loadLibraryFunction, isNotNull);
+    expect(importedLibrary.loadLibraryFunction2, isNotNull);
     expect(importedLibrary.publicNamespace, isNotNull);
     expect(importedLibrary.exportNamespace, isNotNull);
     checkElementText(library, r'''