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

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

Open
FMorschel opened this issue Nov 14, 2024 · 1 comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. 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)

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; // Unneded 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 area-front-end Use area-front-end for front end / CFE / kernel format related issues. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. 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)
Projects
None yet
Development

No branches or pull requests

2 participants