Skip to content

Use imported library with prefix (remove hide/add show) adds new prefix to use #57090

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

Closed
FMorschel opened this issue Nov 14, 2024 · 2 comments
Closed
Labels
legacy-area-analyzer Use area-devexp instead. 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

@FMorschel
Copy link
Contributor

FMorschel commented Nov 14, 2024

After #54786 was closed, we now have a bug in the following code when using the assist:

file.dart:

class A {}

main.dart

import 'file.dart' as f hide A;

void foo(l.A a) {} // <-- Use imported library with prefix...

Currently adds a new prefix so at that line we end up with void foo(l.l.A a) {}.


Also, prefix-related, I think this could probably be fixed together. If the code was instead:

import 'file.dart' as f hide A; // Uneeded for the explanation but a reason for the prefix later in the file
import 'file.dart' hide A;

void foo(l.A a) {} // <-- Update library import

It removes the hide A but it doesn't look whether there is a prefix on the element. I'm unsure if this suggestion should be suppressed or if we should remove the prefix (preferred) in that case (there is no suggestion if the hide A or a show is not present at the import).

@dart-github-bot
Copy link
Collaborator

Summary: The "Use imported library with prefix" assist incorrectly adds a new prefix when the import already has a prefix, resulting in a double prefix. Additionally, the assist removes hide A from imports without considering existing prefixes, potentially leading to incorrect code.

@dart-github-bot dart-github-bot added legacy-area-front-end Legacy: Use area-dart-model instead. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 14, 2024
@devoncarew devoncarew added legacy-area-analyzer Use area-devexp instead. and removed legacy-area-front-end Legacy: Use area-dart-model instead. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Nov 15, 2024
@pq pq added the P2 A bug or feature request we're likely to work on label Nov 20, 2024
@FMorschel
Copy link
Contributor Author

copybara-service bot pushed a commit that referenced this issue Dec 11, 2024
This is a follow up on https://dart-review.googlesource.com/c/sdk/+/396563 which missed these two tests.

[email protected]

Bug: #57090
Change-Id: I5ab71842def9ad7defdc5ada6ceb4b33e26c3ff1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399220
Auto-Submit: Felipe Morschel <[email protected]>
Reviewed-by: Samuel Rawlins <[email protected]>
Commit-Queue: Phil Quitslund <[email protected]>
Reviewed-by: Phil Quitslund <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
legacy-area-analyzer Use area-devexp instead. 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

4 participants