Skip to content
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

Rename breaks at super.fieldName boundary #55552

Open
lukehutch opened this issue Apr 24, 2024 · 2 comments
Open

Rename breaks at super.fieldName boundary #55552

lukehutch opened this issue Apr 24, 2024 · 2 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on

Comments

@lukehutch
Copy link

lukehutch commented Apr 24, 2024

Field renaming breaks at the boundary between a class and its superclass, when the field is defined in the superclass.

Given the following code:

class A {
  final int a;

  A({required this.a});
}

class B extends A {
  final int b;

  B({required super.a, required this.b});
}

class C {
  void c() {
    final a = A(a: 1);
    final b = B(a: 1, b: 2);    // Put cursor here, at 'a'
  }
}

If you click on the indicated a then observe what is highlighted, you see only the a in super.a additionally highlighted:

image

I would argue that the a in A.a and this.a in class A also should be highlighted.

Now with the cursor in the same location, if you try to rename a to q, the code breaks. This breaks precisely because A.a is not considered to be the same as B.a:

image

@DanTup DanTup added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Apr 24, 2024
@DanTup
Copy link
Collaborator

DanTup commented Apr 24, 2024

I don't know if it's the same issue/fix, but occurrences have the same issue here - only the a in class B is highlighted:

image

@bwilkerson
Copy link
Member

@scheglov

@pq pq added the P2 A bug or feature request we're likely to work on label Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

4 participants