-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Export as a Dual of Import #6169
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
This is interesting. Can we use it to define aliases within the same class? trait IterableOps[+A, +CC[_], +C] {
def concat[B >: A](other: IterableOnce[B]): CC[B]
export this.{concat => ++}
} Note that a difference with the examples you mentioned is that class members can be refined, in which case the alias should be refined accordingly: trait X[+A] extends IterableOps[A, Seq, List[A]] {
def concat[B >: A](other: IterableOnce[B]): List[B] = ... // note that return type is `List[B]` instead of the inherited `Seq[B]`
} |
No, |
Should we have a Contributors thread to discuss the proposal, independently of its implementation? In the meantime:
So, |
@srjd Yes, I was going to open a thread on contributors. Regarding implicits, we fortunately will have better ways now to prioritze than by location of original definition.: #6071 (comment). |
e404bd9
to
f36c5d9
Compare
It is a compile-time error if a simple or renaming selector does not identify any eligible | ||
members. | ||
|
||
Type members are aliased by type definitions, and term members are aliased by method definitions. Export aliases copy the type and value parameters of the members they refer to. |
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.
What about annotations, access modifiers, and the inline modifier?
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.
None of them are copied (I believe that's implied by the text).
1. Elaborate any annotations of the class. | ||
2. Elaborate the parameters of the class. | ||
3. Elaborate the self type of the class, if one is given. | ||
4. Enter all definitions of the class as class members, with types to be completed |
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.
From this it's not very clear if definitions in classes can use exported aliases...
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.
They can, but paths to exported aliases cannot refer to other exported aliases.
val maybeStable = if (mbr.symbol.isStableMember) StableRealizable else EmptyFlags | ||
ctx.newSymbol( | ||
cls, alias, | ||
Method | Final | maybeStable | mbr.symbol.flags & ImplicitOrImplied, |
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.
Synthetic
?
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.
No, I don't think we want to make them Synthetic .
val sym = mbr.symbol | ||
if (sym.is(ImplicitOrImplied) != exp.impliedOnly) s"is ${if (exp.impliedOnly) "not " else ""}implied" | ||
else if (!sym.isAccessibleFrom(path.tpe)) "is not accessible" | ||
else if (sym.isConstructor || sym.is(ModuleClass) || sym.is(Bridge)) "_" |
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.
Missing error message?
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.
No, it's intended to be skipped later. I'll change it to something less obscure.
Copier.cfg | ||
Copier.config | ||
Copier.config2 | ||
} |
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.
It would be nice to also have an example with inline since it was mentioned in the meeting.
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.
inline
is not implemented in this PR. Not clear we want it.
Proposal for error test cases: class Foo {
lazy foo : Foo = new Foo
export foo._
} class Foo {
lazy bar: Bar = new Bar
export bar._
}
class Bar {
lazy foo: Foo = new Foo
export foo._
} |
So far, this gave a "member already exists" error. Also, fix info of type export aliases.
- Clearer code for skipped whynoMatchStr - Surivive missing ExportForwarders attachments - Add tests with self-referential exports
This is a pre-SIP proposal and its implementation to introduce export clauses to the language.
Motivation and details are in the
export.md
file of this PR.I co-developed proposal and implementation because the type checking details are a bit tricky, so it paid to have a concrete algorithm to work on that can be tested.
This pre-SIP addresses what must be the longest standing proposal to improve the Scala language. The suggestion to have something like this was first brought up by Jamie Webb in 2005.
Cf also the pre-SIP by David Barry: https://github.com/japgolly/SIP/blob/master/SIP-xx-export/SIP.md