Skip to content

unnecessary_lambdas false positive when affecting inference #58986

Open
@FMorschel

Description

@FMorschel

Describe the issue
I had a tear-off on my parameter, but I had to change it with a ternary operator. That triggered this false positive.

To Reproduce
argument_type_not_assignable triggering on:

void fn({
required void Function(String) parameter,
}) {...}

void function2([String? text]) {...}

void callback() {...}

// Example:
...
  fn(
    parameter: (test) ? function2 : (_) => callback(),
  );
...

When I "solved" that with:

  fn(
    parameter: (test) ? (str) => function2(str) : (_) => callback(), // triggering `unnecessary_lambdas`
  );

Previously I had (and it was working):

  fn(
    parameter: function2,
  );

Expected behavior
argument_type_not_assignable not triggering when that solves unnecessary_lambdas or stopping unnecessary_lambdasfrom triggering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-false-positiveIssues related to lint rules that report a problem when it isn't a problem.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