Skip to content

Type propagation/inference not symmetric for ?: #26086

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
munificent opened this issue Mar 25, 2016 · 5 comments
Closed

Type propagation/inference not symmetric for ?: #26086

munificent opened this issue Mar 25, 2016 · 5 comments
Assignees
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report

Comments

@munificent
Copy link
Member

This program generates an error on line 2, but not line 1:

class A {}
class B extends A {
  b() {}
}

main() {
  A a = new B();
  a is B ? a.b() : null; // 1
  a is! B ? null : a.b(); // 2
}

I would expect them to both be valid.

@munificent munificent added the legacy-area-analyzer Use area-devexp instead. label Mar 25, 2016
@lrhn
Copy link
Member

lrhn commented Mar 25, 2016

You say "error", but it should only be a warning on line 2, and it's required by the specification.

The type promotion is only defined for positive tests by the current specification. That means that the static type of a is A in all of line 2.

@munificent
Copy link
Member Author

You say "error", but it should only be a warning on line 2, and it's required by the specification.

In strong mode, where I noticed this, type warnings are promoted to errors. But, yes, this is reported as a warning when strong mode is not enabled.

The type promotion is only defined for positive tests by the current specification.

Should I reassign to area-language?

@lrhn
Copy link
Member

lrhn commented Mar 29, 2016

By all means request a better type promotion specification. I can't find an open feature request for it, but there might be one already that I couldn't find.

Or request that the analyzer can be allowed to not show warnings that it knows are spurious.

@bwilkerson bwilkerson added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). and removed legacy-area-analyzer Use area-devexp instead. labels Mar 31, 2016
@leafpetersen
Copy link
Member

@munificent This is covered by the proposal that you and @bwilkerson are working, correct?

@munificent
Copy link
Member Author

Yes. Duplicate of #29624.

@munificent munificent added the closed-duplicate Closed in favor of an existing report label May 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

4 participants