-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Align with Scala 3: Under -Xsource:3
, allow importing given
, for cross-building
#10786
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
Conversation
spurious spec failure |
add test for Edit: |
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 otherwsie!
My previous to-do comment was wrong. |
38a2b95
to
66e9c39
Compare
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.
Thanks!
@@ -1950,6 +1950,11 @@ trait Contexts { self: Analyzer => | |||
renamed = true | |||
else if (current.isWildcard && !renamed && !requireExplicit) | |||
result = maybeNonLocalMember(name) | |||
else if (current.isGiven && !requireExplicit) { |
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.
this should have the !renamed
condition, same as the wildcard case.
import x.{y as z, given}
means z
should resolve to y
not implicit x.z
via the given selector.
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.
But this works in Scala 3
scala> object Renamer {
| import TX.{f as tInt, given}
| def test = implicitly[T[Int]]
| }
so a rename is not like a mask. That is, x.y as z
means y
is not available in subsequent wildcard selectors. But it does not mean z
is not made available by wildcard selector!
But Scala 2 now: diverging implicit expansion for type T[Int]
-Xsource:3
, allow importing given
, for cross-building
Fixes scala/bug#12999
Under
-Xsource:3
, instead of ignoringimport x.given
, use it to import implicits only. Takeimport x.{given, *}
asimport x.*
.Although
import x.*
will import "legacy implicits" under Scala 3 migration rules, it's desirable to express justimport x.given
and have it work in Scala 2..Import by type is not supported.
The selector is encoded as if it were
_ as given
.