-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
lint request: ambiguous imports which include an element from the Dart SDK #58326
Comments
Maybe I'm missing something about the rules of ambiguous imports, because CFE matches analyzer's behavior. The first example results in this error:
The second example results in no error. |
@scheglov points out the exception is specified in the spec: "a declaration from a non-system library shadows declarations from system libraries". I imagine authors generally still want a check here though, so converting this to a lint request. |
The exception was added so that the core libraries could be extended without breaking previously existing code. Given that, why do you think users would want this lint? What broken code will this help to catch? |
I think most users are unaware of this singular exception to library element name collisions. There are libraries in flutter's codebase which import both If I had files like that in my code, I would want a lint to let me know, so that I could hide names that are being shadowed. |
I agree with this. It's unexpected for me that it's not an error, but after the explanation of why this is this way, I can understand why. Even so, having an opt-in would be interesting, as, most of the time, shadowing a core identifier is done without intention, and may be overlooked. |
Agreed, happened to me. Found this while working on #56830. |
Analyzer has a diagnostic for when two imports provide an element of the same name:
But this error does not appear when a
dart:
element is at play.Flutter is hitting this in a few places, like https://github.com/flutter/flutter/blob/master/packages/flutter_goldens/test/flutter_goldens_test.dart with "package:file/file.dart" and "dart:io". It does not cause runtime problems, but I think is still confusing.
The text was updated successfully, but these errors were encountered: