Closed
Description
For the below case, there is a compiler error
The argument type 'TypeAnnotation?' can't be assigned to the parameter type 'AstNode'
I believe this shouldn't happen, since there is a check for returnType != null
, also the error is removed if the returnType is declared as
var returnType = function?.returnType;
void fun(FunctionDeclaration? function, ChangeBuilder builder, String file) async {
TypeAnnotation? returnType;
returnType = function?.returnType;
// var returnType = function?.returnType; // this doesn't give an error
if (returnType != null) {
await builder.addDartFileEdit(file, (builder) {
builder.addReplacement(range.node(returnType), (builder) {
// ^^^^^^^^^^ error is here
});
});
}
}
Dart SDK version: 2.15.0-6.0.dev (dev) (Wed Aug 11 14:48:30 2021 -0700) on "windows_x64"