Skip to content
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

(Set literals) Disambiguating sets and maps issue #36209

Open
sgrekhov opened this Issue Mar 14, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@sgrekhov
Copy link
Contributor

sgrekhov commented Mar 14, 2019

Please see the following code

class C<T extends Iterable<Object>>  {
  T t = {}; //  Error: A value of type 'Map<dynamic, dynamic>' can't be assigned to a variable of type 'T'.
}

main() {
  Iterable<Object> o = {};  // Works
}

Tested on Dart VM version: 2.2.1-dev.1.0 (Fri Mar 8 13:28:47 2019 +0100) on "windows_x64"

According to the https://github.com/dart-lang/language/blob/master/accepted/future-releases/unified-collections/feature-specification.md#disambiguating-sets-and-maps there should be no error

Let e be a setOrMapLiteral.

If e has a context C, and the base type of C is Cbase (that is, Cbase is C with all wrapping FutureOrs removed), and Cbase is not ?, then let S be the greatest closure.
...
Else, if S is defined and is a subtype of Iterable<Object> and S is not a subtype of Map<Object, Object>,then e is a set literal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.