Add dynamic return type when creating noSuchMethod

Fixes https://github.com/dart-lang/sdk/issues/47142

Change-Id: I9fe504c91bff2486774285ce1b147eefefe7e2b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239125
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/create_no_such_method.dart b/pkg/analysis_server/lib/src/services/correction/dart/create_no_such_method.dart
index 8c93801..e885c0e 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/create_no_such_method.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/create_no_such_method.dart
@@ -33,8 +33,8 @@
         builder.write('@override');
         builder.write(eol);
         builder.write(prefix);
-        builder.write(
-            'noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);');
+        builder.write('dynamic noSuchMethod(Invocation invocation) => '
+            'super.noSuchMethod(invocation);');
         builder.write(eol);
       });
     });
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_no_such_method_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_no_such_method_test.dart
index 00c6398..74de357 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_no_such_method_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_no_such_method_test.dart
@@ -40,7 +40,7 @@
   existing() {}
 
   @override
-  noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+  dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
 }
 ''');
   }