Create an issue #57024
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
closed-as-intended
Closed as the reported issue is expected behavior
triage-automation
See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot.
type-question
A question about expected behavior or functionality
Dart infers type incorrectly with inheritance.
Dart type inference is not working properly with inheritance and field overriding.
If we don't explicitly write
final Dog pet = Dog();
(repetitive) the analyzer thinks thatpet
isAnimal
. (which is not wrong but problematic, it should beDog
)However,
DogOwner.pet
is clearly of typeDog
(at least for the human reader)Is this a bug in Dart or intended ? I am curious to know why would this be intended.
Dart version 3.4.3
The text was updated successfully, but these errors were encountered: