-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement for
clauses for implied imports
#6594
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
If we have a situation like this: ``` type A type B <: A implied a for A implied b for B ``` we should recognize `b` to be more specific than `a`. Before this commit that was not the case, since `a: A$`, `b: B$` and `B$` is not a subtype of `A$`.
b789e87
to
0f7e939
Compare
In a `for` clause of an implied imports, allow several bounds, separated by commas. Writing ``` import a.b.{for C, D} ``` is equivalent to ``` import a.b.{for C | D} ``` but feels more natural.
Need to use normalizedCompatible instead of `<:<`.
d10e0cb
to
4a488c8
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.
LGTM
Some minor comments about the syntax:
-
In the case
import implied path.{for A, B}
, it would be nicer to writeimport implied path._ for A, B
-
In
import implied path.{for A, B}
, the keywordimplied
seems repetitive, asfor
already expresses the intent. It will be annoying if this is going to be the common case. -
Inside the brace, I feel something is missing before
for
. What aboutimport implied path.{d, _ for A, B}
? I agree the_
is meaningless unless we allow{ d for A, f for B}
.
renamed <- reverseMapping.keys | ||
denot <- pre.member(reverseMapping(renamed)).altsWith(_ is implicitFlag) | ||
} yield { | ||
yield { | ||
val original = reverseMapping(renamed) | ||
val ref = TermRef(pre, original, denot) | ||
if (renamed == original) ref |
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.
Nice for
syntax 👍
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.
Hum ... It doesn't look like valid Scala code to me, actually :-s Maybe with the indentation-based syntax, but that shouldn't be enabled there? Is the parser too lenient?
Merging this for now, but we can continue the discussion about what's the best syntax to use. |
Syntax:
More details in
import-implied.md
.