-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Analyzer fails to check exact types of set literal elements #35742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On second thought, I'm considering this a P1 because it concerns a feature we want to ship very soon. |
I think I'm missing something. The current form of the specification (https://github.com/dart-lang/language/blob/master/accepted/future-releases/set-literals/feature-specification.md) says:
But |
It isn't an error for that reason (an expression with static type A would not be such an error). However, I'm not sure that the rules for exact types have gotten written into the spec (@eernstg ?) co19_2/LanguageFeatures/Set-literals/set_literals_A03_t01/04 and co19_2/LanguageFeatures/Set-literals/set_literals_A03_t02/02 should also be an error because the downcast from A to B fails during constant evaluation. |
@eernstg More importantly, are they written anywhere so that I can know what needs to be implemented? @stereotype441 Are these rules implemented anywhere else in analyzer, or is support for exact types something new (and hence orthogonal to set literals)? |
Did you notice this line from the bug report?
You could try running the example with lists, see what error is reported, and then place a breakpoint on the code that reports that error to see how it works. |
Good point. It seems that the analyzer doesn't do this properly for any container types. I've tracked that as a separate bug in #35748. |
Found by the following co19 tests:
Consider this example:
This should produce a compile-time error, because the exact type of
new A()
is known at compile time to beA
, andA
is not a subtype ofB
.Note that the analyzer correctly implements the corresponding behavior for lists, e.g.:
The text was updated successfully, but these errors were encountered: