Skip to content

Unable to link to named constructor with same name as field #3409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Pante opened this issue May 6, 2023 · 1 comment
Open

Unable to link to named constructor with same name as field #3409

Pante opened this issue May 6, 2023 · 1 comment
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Pante
Copy link

Pante commented May 6, 2023

Dart version: 2.19.6

This issue seems to be a reappearance of #2276.

Example:

class Min {
  final int value;

  Min.open(this.value);
  
  bool get open => false;
}

Trying to use any of the following:

  • [new Min.open(value)]: does not resolve to anything, shows "warning: unresolved doc reference"
  • [new Min.open]: does not resolve to anything, shows "warning: unresolved doc reference", but has the correct highlighting in the IDE
  • [Min.open]: resolves to property, no warning
  • [Min.open(value)]: resolves to property, no warning
@jcollins-g jcollins-g added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels May 8, 2023
@srawlins
Copy link
Member

srawlins commented Oct 16, 2023

Sorry for the delay, I've just stumbled into this code as well. I think the current supported situation is:

  • [Min.open] is ambiguous between the constructor and the field. Dartdoc and the analyzer each choose the field.
  • [new Min.open] is deprecated, both in the analyzer, and dartdoc. It refers to a non-idiomatic syntax (the new keyword). It's not a good solution.
  • [Min.open()] has disambiguating parentheses, which changes the choice to the constructor. The analyzer does not support the () suffix in a doc comment reference, but I hope to remedy that ASAP. Follow Identifiers in dartdocs with parens /// [functionName()] do not generate navigation regions sdk#47553.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants