Skip to content

Privates fields should get promoted #1167

@Hixie

Description

@Hixie

One can statically prove that this code does not have a null dereference risk:

class A {
  int _foo;

  void test() {
    if (_foo != null)
      print(_foo + 1);
  }
}

As far as I can tell, there is no way, even with implements and noSuchMethod and other shenanigans, for _foo to ever be null on the line with the print.

cc @leafpetersen who pointed out that some similar cases aren't so cut and dry because privates can be implemented using noSuchMethod.

Metadata

Metadata

Assignees

No one assigned

    Labels

    field-promotionIssues related to addressing the lack of field promotion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions