I'm surprised to find that dynamic? is allowed and we even see a few uses in google3 ...
Could we lint that you can always switch it to just dynamic? :)
Or perhaps this should be an analyzer diagnostic? (Would anyone ever want to opt-out?)
/fyi @srawlins @bwilkerson
@leafpetersen @munificent is dynamic? different from dynamic in any way? It'd be awkward to immediately default report against using something specified in the spec...
Currently the analyzer even allows dynamic dispatch on dynamic?:
void f(dynamic? a) {
print(a + 2);
}
There's no difference between dynamic and dynamic?, so there's no value in allowing it in code. I doubt that there would be any objections to making it a hint, especially given that hints can be ignored if necessary.
Yeah, dynamic? and void? are completely useless. Never? could be hinted to be equivalent to Null. Null? is also useless. FutureOr<T>? is useless if T is nullable, but you could argue that it's useful documentation.
Thanks for the responses! I agree that it should be Hinted then; dynamic?, void?, etc. would look to me like I'm supposed to read some sort of signal from that ? and I would carefully tiptoe around it for a few minutes before realizing it is meaningless.
This issue was moved by pq to dart-lang/sdk#45165.
Most helpful comment
There's no difference between
dynamicanddynamic?, so there's no value in allowing it in code. I doubt that there would be any objections to making it a hint, especially given that hints can be ignored if necessary.