-
Notifications
You must be signed in to change notification settings - Fork 28
Compile-time error errors due to exact types of set literals #230
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
For the same reason, LinkedHashSet<int> test4() => {}; which is a compile-time error. |
Correct. The "exact type" for set and map literals is going to be |
@lrhn, please, update feature specification examples section. It contains
I can add an issue for Language, if needed |
Good catch. I've fixed it |
Uh oh!
There was an error while loading. Please reload this page.
LanguageFeatures/Set-literals/exact_types_of_literals_A01_t03.dart
has:The first line is a compile-time error. The empty non-const set/map literal is a set literal, so it has static type
Set<T>
for someT
.Type inference tries to satisfy
Set<T> <: LinkedHashSet<int>
by choosingT
but there is no suchT
and so it infersSet<dynamic>
.The rules for exact types of literals require us to reject the assignment of the
Set<dynamic>
toLinkedHashSet<int>
with a compile-time error becauseLinkedHashSet<int>
is not a supertype ofLinkedHashSet<dynamic>
.The text was updated successfully, but these errors were encountered: