site-www
site-www copied to clipboard
Add more common strong-mode issues
Page: https://dart.dev/guides/language/sound-problems https://github.com/dart-lang/site-www/blob/master/src/_guides/language/sound-problems.md
I'd love to see two more items here, and I'm happy to help send/edit:
- [x]
uses_dynamic_as_bottom(contravariant function type parameters, etc) - [x] Invalid type casts (
JSArray is not List<String>) - [ ] type parameter conflicts
- [ ] callable classes
/cc @leafpetersen @lrhn @srawlins @munificent
If you could do a quick first pass (even just pointing to before and after examples, along with any other text you can easily put together), I'd be happy to finish it and publish it.
From @leafpetersen, two more issues we should highlight:
Type parameter conflicts:
- A class may not implement (even transitively, anywhere in its superclass hierarchy) the same generic interface with different type parameters.
- So no having List<int> and List<double> in your class hierarchy somewhere.
- You can have the same generic interface with the same type parameters
Callable classes:
- A class with a call method can still be "called" using the call syntax: o(arguments)
- A function can still be called with the ".call" syntax
- But if
- you use an object o with static type C
- where C has a call method
- in a context where a function typed thing is expected
- then this will be treated as a tearoff of the call method, instead of just passing the object directly
There's a good comment on this bug: https://github.com/dart-lang/sdk/issues/32151
with concrete examples of how Dart 2 will differ from Dart 1
I think GitHub Markdown ate your generics on List and List.
I think GitHub Markdown ate your generics on List and List.
Fixed.