sdk icon indicating copy to clipboard operation
sdk copied to clipboard

DartCode/Analyzer: "Find All References" can't find dot-shorthand references to constructors if type name is never mentioned

Open mernen opened this issue 1 day ago • 0 comments

You need two different files for this.

example.dart:

class Example {
  Example.foo();

  static final bar = Example.foo();
}

void youKnowWho(Example e) {}

main.dart:

import 'example.dart';

void main() {
  youKnowWho(.foo());
  youKnowWho(.bar);
}

With this setup and DartCode, right-click the constructor Example.foo() and pick "Find All References" (or "Go to References"). The only reference found will be static final bar, in the same file.

Try the same in bar, and the cross-file reference will be found.

If main.dart gets any explicit mention of Example (for example, add a youKnowWho(Example.bar) call), the reference will be found.


DartCode version: 3.124.1

$ dart --version
Dart SDK version: 3.10.3 (stable) (Tue Dec 2 01:04:53 2025 -0800) on "macos_arm64"

mernen avatar Dec 10 '25 03:12 mernen