Partial support for super accessors (fix #100) #326
Merged
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.
While working on #100, I realized that we're in trouble.
In order to generate super accessors, a Scala compiler needs to go through method bodies, typecheck super selections and see which of them qualify. At the moment, Rsc doesn't look into method bodies at all, which looks like a game over.
All's not lost, however. Since super accessors are pretty exotic, our users may be willing to accept additional notational overhead to express them. A workaround along these lines has been implemented in this pull request. For example, let's look at #100:
In order to nudge Rsc into generating a ScalaSignature entry for
super$x
, we can adopt the following notation (due to some reason, Scalac needs to know which base class the superaccessor is referring to, and we encode that in an additional parameter section):I've explored a prettier notation for the same thing:
private def super$x: Int = super[T1].x
, but unfortunately it doesn't work when the type in brackets is a class (due to some reason, Scalac says "implementation restriction: traits may not select fields or methods from super[C] where C is a class").