Skip to content

Analyzer needs to handle @optionalTypeArgs w/ static extensions #38105

@srawlins

Description

@srawlins

Take this example from the static extension spec:

import "all.dart";  // exposes extensions `Foo`, `Bar` and `Baz`.
// ...
main() {
  // ...
  Baz("ok").baz();  // Explicit reference to `Baz` extension.
  // ...
}
  1. Can the extension, Baz, be marked @optionalTypeArgs? (I think so)

In the context of linter rules which take @optionalTypeArgs under consideration, and the strict-raw-types static analysis mode:

  1. If Baz<T> is an extension on a class, C<T>, then I think Baz("ok") is not ok; analyzer/linter should hint/lint where appropriate then Baz("ok") is fine; inference takes place here, similar to how it does on constructors.
  2. The extension, extension Baz on C, where C is generic (e.g. C<T>), should be considered a raw type; analyzer/linter should hint/lint where appropriate.
  3. The extension, extension on C, where C is generic (e.g. C<T>), should be considered a raw type; analyzer/linter should hint/lint where appropriate.

Any of the above can be suppressed with @optionalTypeArgs.

CC @pq

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagedevexp-warningIssues with the analyzer's Warning codeslegacy-area-analyzerUse area-devexp instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions