Skip to content

Editor type inference should consider what is in assert #4410

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
DartBot opened this issue Aug 7, 2012 · 5 comments
Closed

Editor type inference should consider what is in assert #4410

DartBot opened this issue Aug 7, 2012 · 5 comments
Assignees
Labels
type-enhancement A request for a change that isn't a bug
Milestone

Comments

@DartBot
Copy link

DartBot commented Aug 7, 2012

This issue was originally filed by [email protected]


Hi guys,

I'm getting some "x is not a member of z" warnings in the editor (when I don't use that little check box in the preferences - as a side note - can't we make that check box a 'positive' - i.e. "use inferred type information..." instead of a "don't use..."?) where I think that the inference should work.

Here is my example:

void drawImage(Image image, num dx, num dy) {
    assert(image is HtmlImage);
    final htmlImage = image;// as HtmlImage;
    _context2d.drawImage(htmlImage.element, dx, dy);
  }

since the assert contains an "is" check I would expect not to get a "not a member of" warning on the .element of my HtmlImage class. If I uncomment the 'as' the warning goes away, but I think the 'is' should be enough?

if I wrap the assignment and the method call in an if statement then the warning goes away:

void drawImage(Image image, num dx, num dy) {
    assert(image is HtmlImage);
    if(image is HtmlImage)
    {
      final htmlImage = image;// as HtmlImage;
      _context2d.drawImage(htmlImage.element, dx, dy);
    }
  }

What version of the product are you using? On what operating system?

Dart Editor 10315, Windows 64

@danrubel
Copy link

danrubel commented Aug 9, 2012

Set owner to @scheglov.
Added this to the M1 milestone.
Removed Type-Defect label.
Added Type-Enhancement, Area-Editor, Triaged labels.

@scheglov
Copy link
Contributor

Added Accepted label.

@scheglov
Copy link
Contributor

@scheglov
Copy link
Contributor

@DartBot
Copy link
Author

DartBot commented Aug 13, 2012

This comment was originally written by [email protected]


awesome turnaround on this guys! will verify the fix on my end

cheers

@DartBot DartBot added this to the M1 milestone Aug 13, 2012
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants