[element model] fix `prefer_final_locals`

Migrates `isPotentiallyMutatedInScope2` call.


Bug: https://github.com/dart-lang/linter/issues/5099
Change-Id: I031d2133d492b42f8cb55ae0835f6de865e467d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391845
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/linter/lib/src/rules/prefer_final_locals.dart b/pkg/linter/lib/src/rules/prefer_final_locals.dart
index 6319ebc..3c2bdee 100644
--- a/pkg/linter/lib/src/rules/prefer_final_locals.dart
+++ b/pkg/linter/lib/src/rules/prefer_final_locals.dart
@@ -55,8 +55,8 @@
 
   bool isPotentiallyMutated(AstNode pattern, FunctionBody function) {
     if (pattern is DeclaredVariablePattern) {
-      var element = pattern.declaredElement;
-      if (element == null || function.isPotentiallyMutatedInScope(element)) {
+      var element = pattern.declaredElement2;
+      if (element == null || function.isPotentiallyMutatedInScope2(element)) {
         return true;
       }
     }