-
Notifications
You must be signed in to change notification settings - Fork 3.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
Import selector respects backquotes [ci: last-only] #6218
Conversation
9a264d8
to
eb0a231
Compare
A couple of fixes for reflection. I was inclined to add API for |
faae4c8
to
0ea6c72
Compare
Btw, you need to say "fixes xx/yy#zz" for each xx/yy#zz, otherwise it'll just close the first one. |
Also fix |
I'd be most worried about compatibility with Scala IDE and Scala refactoring.
I wonder if we can find a way to leave the encoding as is, but sneak an extra boolean onto |
Yes, for sure, I meant tooling needs communication, but that it would nicer if there were an API to make the change easier and more uniform, too. I could experiment on refactoring. I think my first thought was a tree attachment. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
d76b832
to
e7ac907
Compare
This comment has been minimized.
This comment has been minimized.
Refactoring requested and new commits pushed. Re-review by @retronym, perhaps? |
I like using The caution about breaking tooling remains, but I'm fine moving forward as long as scalafix etc is not affected. (Which seems unlikely since they reimplemented all this ;-)) |
* | ||
* Would be represented as: | ||
* | ||
* Import(qual, List(("x", "x"), ("y", "z"), (WILDCARD, null))) | ||
* Import(qual, List(("w", EMPTY), ("x", "x"), ("y", "z"), (EMPTY, EMPTY))) |
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.
As mentioned in the discussion, could we use (WILDCARD, WILDCARD)
for the last element?
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.
Now (WILD, WILD) means import backticked underscore, possibly with rename. Otherwise, the encoding is unchanged.
@som-snytt do you plan to resume work on this? |
@adriaanm This is totally incrementable and useful and unoffensive and could be moved up to 2.13.0 cycle. I was looking at imports today thinking I thought I'd changed that code. |
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.
💯 the code is much, much nicer! encapsulation FTW
🏅 for moxie
🃏 because wild card
This project now compiles with Scala 2.13 by default, while still cross-compiling to Scala 2.12. Issues addressed with this upgrade: ### Underscore (`_`) is no longer a valid identifer for vals Using underscore like this is no longer allowed... ``` implicit val _ = ... ``` ...we have to give the `val` a valid name: ``` implicit val v = ... ``` See also: * scala/bug#10384 * scala/bug#7691 * scala/scala#6218 ### `Map.mapValues()` now returns a `MapView` rather than a `Map` We usually want a `Map`, so we can just add in a `.toMap` to the end of the expression - it's harmless in Scala 2.12, and allows the code to compile in Scala 2.13. `Map.mapValues()` itself is deprecated in Scala 2.13, but using the new recommended alternative doesn't work in Scala 2.12. https://docs.scala-lang.org/overviews/core/collections-migration-213.html#what-are-the-breaking-changes See also: * scala/bug#10919 * scala/scala#7014
This project now compiles with Scala 2.13 by default, while still cross-compiling to Scala 2.12. Issues addressed with this upgrade: ### Underscore (`_`) is no longer a valid identifer for `val`s Using underscore like this is no longer allowed... ``` implicit val _ = ... ``` ...we have to give the `val` a valid name (even if it's just `v`): ``` implicit val v = ... ``` See also: * scala/bug#10384 * scala/bug#7691 * scala/scala#6218 ### `Map.mapValues()` now returns a `MapView` rather than a `Map` We usually want a `Map`, so we can just add in a `.toMap` to the end of the expression - it's harmless in Scala 2.12, and allows the code to compile in Scala 2.13. `Map.mapValues()` itself is deprecated in Scala 2.13, but using the new recommended alternative doesn't work in Scala 2.12. https://docs.scala-lang.org/overviews/core/collections-migration-213.html#what-are-the-breaking-changes See also: * scala/bug#10919 * scala/scala#7014 ### `.to` can no longer infer what resulting collection type you want This is all part of `CanBuildFrom` going away in Scala 2.13: https://www.scala-lang.org/blog/2018/06/13/scala-213-collections.html#life-without-canbuildfrom
This project now compiles with Scala 2.13 by default, while still cross-compiling to Scala 2.12 & 2.11. Issues addressed with this upgrade: ### Underscore (`_`) is no longer a valid identifer for `val`s Using underscore like this is no longer allowed... ``` implicit val _ = ... ``` ...we have to give the `val` a valid name (even if it's just `v`): ``` implicit val v = ... ``` See also: * scala/bug#10384 * scala/bug#7691 * scala/scala#6218 ### `Map.mapValues()` now returns a `MapView` rather than a `Map` We usually want a `Map`, so we can just add in a `.toMap` to the end of the expression - it's harmless in Scala 2.12, and allows the code to compile in Scala 2.13. `Map.mapValues()` itself is deprecated in Scala 2.13, but using the new recommended alternative doesn't work in Scala 2.12. https://docs.scala-lang.org/overviews/core/collections-migration-213.html#what-are-the-breaking-changes See also: * scala/bug#10919 * scala/scala#7014 ### `.to` can no longer infer what resulting collection type you want This is all part of `CanBuildFrom` going away in Scala 2.13: https://www.scala-lang.org/blog/2018/06/13/scala-213-collections.html#life-without-canbuildfrom
This project now compiles with Scala 2.13 by default, while still cross-compiling to Scala 2.12 & 2.11. Issues addressed with this upgrade: ### Underscore (`_`) is no longer a valid identifer for `val`s Using underscore like this is no longer allowed... ``` implicit val _ = ... ``` ...we have to give the `val` a valid name (even if it's just `v`): ``` implicit val v = ... ``` See also: * scala/bug#10384 * scala/bug#7691 * scala/scala#6218 ### `Map.mapValues()` now returns a `MapView` rather than a `Map` We usually want a `Map`, so we can just add in a `.toMap` to the end of the expression - it's harmless in Scala 2.12, and allows the code to compile in Scala 2.13. `Map.mapValues()` itself is deprecated in Scala 2.13, but using the new recommended alternative doesn't work in Scala 2.12. https://docs.scala-lang.org/overviews/core/collections-migration-213.html#what-are-the-breaking-changes See also: * scala/bug#10919 * scala/scala#7014 ### `.to` can no longer infer what resulting collection type you want This is all part of `CanBuildFrom` going away in Scala 2.13: https://www.scala-lang.org/blog/2018/06/13/scala-213-collections.html#life-without-canbuildfrom
This project now compiles with Scala 2.13 by default, while still cross-compiling to Scala 2.12 & 2.11. Issues addressed with this upgrade: ### Underscore (`_`) is no longer a valid identifer for `val`s Using underscore like this is no longer allowed... ``` implicit val _ = ... ``` ...we have to give the `val` a valid name (even if it's just `v`): ``` implicit val v = ... ``` See also: * scala/bug#10384 * scala/bug#7691 * scala/scala#6218 ### `Map.mapValues()` now returns a `MapView` rather than a `Map` We usually want a `Map`, so we can just add in a `.toMap` to the end of the expression - it's harmless in Scala 2.12, and allows the code to compile in Scala 2.13. `Map.mapValues()` itself is deprecated in Scala 2.13, but using the new recommended alternative doesn't work in Scala 2.12. https://docs.scala-lang.org/overviews/core/collections-migration-213.html#what-are-the-breaking-changes See also: * scala/bug#10919 * scala/scala#7014 ### `.to` can no longer infer what resulting collection type you want This is all part of `CanBuildFrom` going away in Scala 2.13: https://www.scala-lang.org/blog/2018/06/13/scala-213-collections.html#life-without-canbuildfrom
This project now compiles with Scala 2.13 by default, while still cross-compiling to Scala 2.12 & 2.11. Although Scala 2.13.1 has been released, this change sticks with 2.13.0, as `scoverage` has not yet released an update compatible with 2.13.1: scoverage/sbt-scoverage#295 scoverage/scalac-scoverage-plugin#283 scoverage/sbt-scoverage#299 Migration issues addressed with the update to Scala 2.13: ### Underscore (`_`) is no longer a valid identifer for `val`s Using underscore like this is no longer allowed... ``` implicit val _ = ... ``` ...we have to give the `val` a valid name (even if it's just `v`): ``` implicit val v = ... ``` See also: * scala/bug#10384 * scala/bug#7691 * scala/scala#6218 ### `Map.mapValues()` now returns a `MapView` rather than a `Map` We usually want a `Map`, so we can just add in a `.toMap` to the end of the expression - it's harmless in Scala 2.12, and allows the code to compile in Scala 2.13. `Map.mapValues()` itself is deprecated in Scala 2.13, but using the new recommended alternative doesn't work in Scala 2.12. https://docs.scala-lang.org/overviews/core/collections-migration-213.html#what-are-the-breaking-changes See also: * scala/bug#10919 * scala/scala#7014 ### `.to` can no longer infer what resulting collection type you want This is all part of `CanBuildFrom` going away in Scala 2.13: https://www.scala-lang.org/blog/2018/06/13/scala-213-collections.html#life-without-canbuildfrom
This project now compiles with Scala 2.13 by default, while still cross-compiling to Scala 2.12 & 2.11. Although Scala 2.13.1 has been released, this change sticks with 2.13.0, as `scoverage` has not yet released an update compatible with 2.13.1: scoverage/sbt-scoverage#295 scoverage/scalac-scoverage-plugin#283 scoverage/sbt-scoverage#299 Migration issues addressed with the update to Scala 2.13: ### Underscore (`_`) is no longer a valid identifer for `val`s Using underscore like this is no longer allowed... ``` implicit val _ = ... ``` ...we have to give the `val` a valid name (even if it's just `v`): ``` implicit val v = ... ``` See also: * scala/bug#10384 * scala/bug#7691 * scala/scala#6218 ### `Map.mapValues()` now returns a `MapView` rather than a `Map` We usually want a `Map`, so we can just add in a `.toMap` to the end of the expression - it's harmless in Scala 2.12, and allows the code to compile in Scala 2.13. `Map.mapValues()` itself is deprecated in Scala 2.13, but using the new recommended alternative doesn't work in Scala 2.12. https://docs.scala-lang.org/overviews/core/collections-migration-213.html#what-are-the-breaking-changes See also: * scala/bug#10919 * scala/scala#7014 ### `.to` can no longer infer what resulting collection type you want This is all part of `CanBuildFrom` going away in Scala 2.13: https://www.scala-lang.org/blog/2018/06/13/scala-213-collections.html#life-without-canbuildfrom
|
Thanks for fixing this. Maybe we could mention in https://github.com/scala/scala/releases/tag/v2.13.0 that this allows multiple dummy binding. What do you think about the following edit? * Underscore is no longer a legal identifier unless backquoted ([bug\#10384](https://github.com/scala/bug/issues/10384))
+ * Multiple dummy bindings can now be used within a scope: `{ val _ = 3; val _ = 5; 7 }`
* `val _ =` is now a pattern match
* `implicit val _ =` is also now a pattern match which does not introduce an identifier and therefore does not add anything to implicit scope |
@eed3si9n hmm... not against adding some wording, but I think we should make it very clear to the reader why we're telling them this. (which the existing text isn't necessarily doing an ideal job of, either) what is the recommended way to value-discard, warning-free? is it |
Between the two, val _ = compile.value
val _ = copyResources.value
|
"Warn-free, as free as the wind blows..." 🎶 |
okay, I changed that section of the notes to:
(The fact that as an additional consequence it is now allowed to |
Also, from now on, we should call them the release 🎶 or is that already the name of Seth's band? |
#7563 makes |
An import selector from WILDCARD to WILDCARD is taken as importing member underscore, and WILDCARD to anything else not null as renaming it. Renaming unquoted wildcard is not allowed.
was:
To disambiguate backquoted underscore, the convention
for ImportSelector is tweaked by using EMPTY instead of
WILDCARD as the special value. So EMPTY => EMPTY is
wildcard import, nonempty => EMPTY is hidden.
This encoding also avoids a null value for the rename field.
A rename is detected more simply by name != rename.
This change would require communication with anyone who builds ImportSelector manually. It would be nice to use ImportSelector.wild instead of relying on the encoding. See the test that does that.
Fixes scala/bug#6426
Fixes scala/bug#10641
Fixes scala/bug#7691