Skip to content

Private interface method flagged as not referenced #60697

Closed
@dowski

Description

@dowski

Problem

In Dart 3.7.2, when I declare a private interface method that I implement in some other classes, the Dart analyzer complains that it isn't referenced.

The declaration `_foo` isn't referenced.

Repro

Here's a DartPad that demonstrates the issue. I'll also paste the code here for clarity.

void main() {
  Bar().bar();
}

final class Bar {
  final foo = Foo();
  
  void bar() {
    foo._foo();
  }
}

final class Foo implements _Foo {
  @override
  void _foo() {}
}

abstract interface class _Foo {
  void _foo();
}

Additional Info

When using VS Code, it seems like the analyzer knows that _foo is used elsewhere because I can jump to implementors and callers. I assume that's powered by the analyzer too, so it's odd that this error is present.

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-warningIssues with the analyzer's Warning codes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions