Skip to content

Analyzer is of two minds regarding a property/super-parameter accessed as the prefix of a method call target. #59996

@srawlins

Description

@srawlins

There are a few requirements to triggering this, which explains why it still exists on stable branch (and all the way up to main branch):

class C {
  late int f;
  C({int? f}) {
    this.f = f ?? 7;
  }
}

class D extends C {
  D({super.f}) {
    f .isEven.toString();
  }
}
  • Given this code, there is a compile-time error at f.isEven claiming that f could be null.
  • If you change the statement to start as f?.isEven or f!.isEven, then there are warnings that f cannot be null.

Code requirements:

  • super class has field f.
  • subclass has nullable super formal parameter, f.
  • property is called on f (.isEven) in ctor body, and a method (.toString()) is called on the property.

A hint: when you Go-to-definition of f in the original code, you are taken to super.f. When you Go-to-definition at f? or f!, you are taken to the super field.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions