Skip to content

unnecessary_parenthesis false positive with null-aware toString #59021

@oprypin

Description

@oprypin

But seems that this case still slips through:

  • String foo() {
      int? a;
      return (a?.abs().sign).toString(); // Unnecessary use of parentheses.
    }
  • String foo() {
      int? a;
      return a?.abs().sign.toString(); // 'String?' can't be returned from a function with return type 'String'
    }

Probably the complicating factor is that toString is available on Object? and the null-aware expression has another dot after it

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-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