[element model] migrate `error_verifier` (enclosing element getters)

Cleans up getters as per our discussion.

Sorry for the delay on this one!

Change-Id: I3eabce599d5ea4696c7c478b0ca3aedb4097a5eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410661
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 28f2eed..1fa3eac 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -318,17 +318,12 @@
 
   /// The class containing the AST nodes being visited, or `null` if we are not
   /// in the scope of a class.
-  InterfaceElement2? get _enclosingClass2 => switch (_enclosingClass) {
-        InterfaceElement element => element.asElement2,
-        _ => null,
-      };
+  InterfaceElement2? get _enclosingClass2 => _enclosingClass?.asElement2;
 
   /// The element of the extension being visited, or `null` if we are not
   /// in the scope of an extension.
-  ExtensionElement2? get _enclosingExtension2 => switch (_enclosingExtension) {
-        ExtensionElement element => element.asElement2,
-        _ => null,
-      };
+  ExtensionElement2? get _enclosingExtension2 =>
+      _enclosingExtension?.asElement2;
 
   /// The language team is thinking about adding abstract fields, or external
   /// fields. But for now we will ignore such fields in `Struct` subtypes.