-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow new import syntax #11244
Merged
Merged
Allow new import syntax #11244
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
odersky
force-pushed
the
change-imports
branch
2 times, most recently
from
January 30, 2021 13:04
4df21b0
to
46fcfd6
Compare
Based on #11240 |
odersky
force-pushed
the
change-imports
branch
from
January 30, 2021 16:19
605c31d
to
db4f837
Compare
- Replace wildcard import `_` with `*`, which is what basically all other languages use - Replace renaming `=>` with a soft keyword `as`. - Allow `as` outside braces, as in ```scala import scala.collection.mutable as mut import NumPy as np ```
Support imports import a as b where `a` is a simple identifier.
More test cases and fixes for simple renaming imports. Disallow them for exports for now, since the primary use case of a renaming export is not handled yet: lampepfl/dotty-feature-requests#148
odersky
force-pushed
the
change-imports
branch
from
February 5, 2021 13:51
82394f2
to
1ef6abd
Compare
@liufengyun Can you review the technical side here? It looks like the proposal has strong support, so we will probably go ahead and merge this. |
liufengyun
approved these changes
Feb 8, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Fengyun Liu <liu@fengy.me>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
_
with*
, which is what basically all other languages use=>
with a soft keywordas
.as
outside braces, as inFrom the doc page:
The syntax of wildcard and renaming imports (and exports) has changed.
Wildcard Imports
Wildcard imports are now expressed with
*
instead of underscore. Example:If you want to import a member named
*
specifically, you can use backticks around it.Renaming Imports
To rename or exclude an import, we now use
as
instead of=>
. A single renaming import no longer needs to be enclosed in braces. Examples:Migration
To support cross-building, Scala 3.0 supports the old import syntax with
_
for wildcards and=>
for renamings in addition to the new one. The old syntaxwill be dropped in a future versions. Automatic rewritings from old to new syntax
are offered under settings
-source 3.1-migration -rewrite
.Syntax