Skip to content

IDE auto-imports first implementation library over public export of implementation library #47842

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
bernaferrari opened this issue Dec 2, 2021 · 9 comments
Labels
devexp-server Issues related to some aspect of the analysis server legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request

Comments

@bernaferrari
Copy link
Contributor

I think

  • a) Don't import implementation files from another package. shouldn't show up for package:collection?
  • b) package:collection/ should export(?) the extensions?

image

With #45680 recommending firstWhereOrNull, I can't use it without this warning.

@bwilkerson
Copy link
Member

That library is exported from the public library of the package, which can be imported using

import 'package:collection/collection.dart';

@lrhn
Copy link
Member

lrhn commented Dec 3, 2021

And the warning definitely should show up. The warning is for your protection.
Never import files in src/ directories, not unless you are the author of both packages and know what you're doing.

@lrhn lrhn added legacy-area-analyzer Use area-devexp instead. closed-as-intended Closed as the reported issue is expected behavior labels Dec 3, 2021
@bernaferrari
Copy link
Contributor Author

So is this an IDE issue? Because the IDE auto imported the src/ file now that it imports extensions.

@bwilkerson
Copy link
Member

... the IDE auto imported the src/ file ...

Yes, that's a known bug (I haven't looked to see whether there's an issue open for it). The IDE support currently doesn't have the information necessary to determine which public libraries should be imported in order to import something that's declared in a src library, so it currently defaults to importing the library containing the declaration.

@scheglov Perhaps we can talk soon about efficient ways to capture that information.

@srawlins
Copy link
Member

srawlins commented Dec 6, 2021

@bernaferrari can you say which IDE auto-imported the library in src/?

@bernaferrari
Copy link
Contributor Author

Intellij

@srawlins srawlins changed the title Disable implementation_imports for package:collection IDE auto-imports first implementation library over public export of implementation library Dec 6, 2021
@srawlins srawlins added devexp-server Issues related to some aspect of the analysis server P3 A lower priority bug or feature request and removed closed-as-intended Closed as the reported issue is expected behavior labels Dec 6, 2021
@scheglov
Copy link
Contributor

scheglov commented Dec 6, 2021

I can reproduce the issue.
https://dart-review.googlesource.com/c/sdk/+/222243

We should know extensions exported from a library, and probably should use exported namespaces instead of looking at declarations.

copybara-service bot pushed a commit that referenced this issue Dec 6, 2021
Bug: #47842
Change-Id: Ib6c4d6791f823191ef39998a6e350c48915d52fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222243
Reviewed-by: Phil Quitslund <[email protected]>
@scheglov
Copy link
Contributor

copybara-service bot pushed a commit that referenced this issue Dec 12, 2021
So, we don't need ExtensionCache anymore.

This fixes the issue with importing a library from lib/src sometimes.

Bug: #47842
Change-Id: I9a28fb2e1e14ab96a58c3ef72daa87562f1bccd6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/223441
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
@scheglov
Copy link
Contributor

The issue was fixed with the CL above.
I'm landing one more clean up https://dart-review.googlesource.com/c/sdk/+/223741

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-server Issues related to some aspect of the analysis server legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

5 participants