You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug report] extract method: The argument type 'void Function(SnackBarData)' can't be assigned to the parameter type 'void Function(dynamic)' #5350
Are you able to provide a complete code sample I can use to repro this? I tried stubbing out the things missing from your code, but I wasn't able to reproduce the issue:
Future<void> main() async {
var jxlFile =1;
var value =1;
var selectedOutputDirPath ='';
var snackBarData =await_executeConversionWithExceptionAsValue(
() async {
awaitJxlToJpeg.convert(
jxlFile,
outputPath:join(
selectedOutputDirPath,
'.jpg',
),
);
},
);
if (snackBarData !=null) {
displayFeedbackForTheUser(snackBarData);
}
value +=1;
}
Future<Object?> _executeConversionWithExceptionAsValue(Function f) =>throwUnimplementedError();
Future<void> foo() async {}
Future<Object?> bar(Function x) async {}
classJxlToJpeg {
staticFuture<void> convert(int a, {requiredString outputPath}) {
throwUnimplementedError();
}
}
Stringjoin(String a, String b) =>throwUnimplementedError();
voiddisplayFeedbackForTheUser(Object? o) {}
Extracting the same code from here didn't produce any incorrect code.
Future<void> f(void Function(String) f, String a) async {
f(a);
}
The issue here is that the refactor was written before the generic function syntax (where function types can have parameters with no names) and writes a signature using the old style (which doesn't support not having names).
Activity
DanTup commentedon Nov 26, 2024
Are you able to provide a complete code sample I can use to repro this? I tried stubbing out the things missing from your code, but I wasn't able to reproduce the issue:
Extracting the same code from here didn't produce any incorrect code.
Thanks!
stephane-archer commentedon Nov 26, 2024
with this code in another file:
sorry my code is pretty ugly, I hope this helps you solve the issue, make sure to use a typedef, I think this is what cause the issue
DanTup commentedon Nov 27, 2024
Thanks! I was able to trim this down to:
The issue here is that the refactor was written before the generic function syntax (where function types can have parameters with no names) and writes a signature using the old style (which doesn't support not having names).
DanTup commentedon Nov 27, 2024
Got a fix up for review at https://dart-review.googlesource.com/c/sdk/+/397900
The fix is in the Dart analysis server so once merged, will ship in a future Dart/Flutter SDK release (not a VS Code extension release).
stephane-archer commentedon Nov 27, 2024
@DanTup you are the best! thank you for solving my issue!
[analysis_server] Use generic function syntax for function parameters…
DanTup commentedon Dec 2, 2024
Thanks, no problem! The fix has now landed in the Dart SDK and will be included in a future Dart/Flutter SDK release.