flutter / flutter/flutter-intellij

Argument that is a callback that returns a tuple breaks navigation

Open
#8,302 1 comment 0 reactions 0 assignees View on GitHub
dependency: dart plugin P2 topic-editing
Dominant language
Java
Stars
2k
Forks
356
Avg merge
1d 11h
Merged PRs (30d)
27

Description

The following example breaks navigation in intellij (cmd + click on _someFunction)

```dart
int _someFunction((int a, int b) Function(int) cb) {
final (a, b) = cb(10);
return a + b;
}

void _x() {
print(_someFunction((x) => (x ~/ 2, x * 2)));
}
```

However, if I extract the signature of the callback to a typedef, the bug is gone
```dart
typedef CB = (int a, int b) Function(int);

int _someFunction(CB cb) {
final (a, b) = cb(10);
return a + b;
}

void _x() {
print(_someFunction((x) => (x ~/ 2, x * 2)));
}
```

If I create some other function before the culprit line, the navigation there works, showing that everything after the culprit is broken.
```dart
void _y() {
print(_someFunction((x) => (x ~/ 2, x * 2)));
}

int _someFunction((int a, int b) Function(int) cb) {
final (a, b) = cb(10);
return a + b;
}

void _x() {
print(_someFunction((x) => (x ~/ 2, x * 2)));
}
```

I tested the same thing on visual studio code and it worked fine (just to show it is either the analyzer server version or something specific to intellij plugin)

Plugin version used: [86.0.2](https://plugins.jetbrains.com/plugin/9212-flutter/versions/stable/774394)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the inline callback example in IntelliJ and compare navigation with the typedef and reordered-function examples; the issue names no project files or tests. Trace whether the failure is in the IntelliJ plugin or analyzer integration, using the working Visual Studio Code result as a comparison. Done means cmd-click navigation works for the inline callback without breaking navigation below it.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, java
Domain
developer-experience, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.