Skip to content

Editor type inference should consider what is in assert #4410

Closed
@DartBot

Description

@DartBot

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

Metadata

Metadata

Assignees

Labels

type-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions