site-www icon indicating copy to clipboard operation
site-www copied to clipboard

Add more common strong-mode issues

Open matanlurey opened this issue 7 years ago • 4 comments

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

matanlurey avatar Feb 07 '18 15:02 matanlurey

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.

kwalrath avatar Feb 08 '18 01:02 kwalrath

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

matanlurey avatar Feb 15 '18 17:02 matanlurey

I think GitHub Markdown ate your generics on List and List.

srawlins avatar Feb 15 '18 17:02 srawlins

I think GitHub Markdown ate your generics on List and List.

Fixed.

chalin avatar Feb 15 '18 18:02 chalin