Skip to content

Strong mode analyzer incorrectly infers return type of ??= #26023

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

Closed
charliereams opened this issue Mar 17, 2016 · 3 comments
Closed

Strong mode analyzer incorrectly infers return type of ??= #26023

charliereams opened this issue Mar 17, 2016 · 3 comments
Labels
legacy-area-analyzer Use area-devexp instead.

Comments

@charliereams
Copy link

The following code should be strong-mode compliant:

class X {}

UnmodifiableListView<X> a = new UnmodifiableListView<X>([]);
Iterable<X> b = null;
Iterable<X> c = (b ??= a);

but the analyzer actually produces the error:

#Unsound implicit cast from Object to Iterable<X> [STRONG_MODE_DOWN_CAST_COMPOSITE]

Note that this very similar (and functionally equivalent) code works fine:

class X {}

List<X> a = new UnmodifiableListView<X>([]);
Iterable<X> b = null;
Iterable<X> c = (b ??= a);

so it seems it's specifically having trouble working out the common subtype of Iterable and UnmodifiableListView. Maybe mix-in related?

@leafpetersen
Copy link
Member

I believe that this is an instance of this:

#25821

We are currently using the spec mode LUB, which is not very useful:

@leafpetersen
Copy link
Member

For discussion of spec mode LUB see:

#19282
#19425

@leafpetersen
Copy link
Member

Closing as duplicate of #25821 and #25802 , please re-open if you think something else is going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

3 participants