Skip to content

Fix parameter accessor forwarding #2124

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

Merged
merged 5 commits into from
Mar 20, 2017
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 20, 2017

Fixes remaining problems of #2116, from which it takes one change and all tests.

odersky added 3 commits March 20, 2017 16:08
Making a name shadowed lost the signature before.
Normal references won't work since the referenced accessor has
the same name as a private name in the class defining the forwarder.
This showed up as pickling failures under separate compilation.
@odersky odersky requested a review from smarter March 20, 2017 15:16
Super(This(currentClass), tpnme.EMPTY, inConstrCall = false)
.select(alias)
val stpe @ TermRef(_, _) = superAcc.tpe
val superAccShadowed = superAcc.withType(stpe.shadowed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, this is only necessary when the super is not the base class where the paramaccessor is defined, but I guess there's no harm in always using .shadowed. However it would be nice to add a comment explaining when the .shadowed is useful.

@@ -1782,15 +1782,19 @@ object Types {
else d.atSignature(sig).checkUnique
}

override def newLikeThis(prefix: Type)(implicit ctx: Context): TermRef = {
val candidate = TermRef.withSig(prefix, name, sig)
private def fixDenot(candidate: TermRef, prefix: Type)(implicit ctx: Context): TermRef =
if (symbol.exists && !candidate.symbol.exists) { // recompute from previous symbol
val ownSym = symbol
val newd = asMemberOf(prefix, allowPrivate = ownSym.is(Private))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we revert the addition of the allowPrivate parameter to asMemberOf since it is no longer useful for ParamForwarder and could mask other bugs that only show up under -Ytest-pickler ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave it in, because the logic makes sense anyway.

@odersky
Copy link
Contributor Author

odersky commented Mar 20, 2017

@smarter We get a difference with actual output and the check file for paramForwarding. But I don't know which one is correct, or whether it is important. Can you check?

@odersky
Copy link
Contributor Author

odersky commented Mar 20, 2017

Also, I am not sure whether we want to avoid the $$local field for "override val" accessors. What's the point? Specifically, should we add forwarders only to PrivateParamAccessors?

@smarter
Copy link
Member

smarter commented Mar 20, 2017

Yes, this difference also happened in my PR. I think updating the check file makes sense, the fact that Y does not get a field is coherent with the fact that C does not get a field, which was already the case before this PR.

@smarter
Copy link
Member

smarter commented Mar 20, 2017

Also, I am not sure whether we want to avoid the $$local field for "override val" accessors. What's the point?

Isn't it always good to avoid adding fields if possible?

@odersky
Copy link
Contributor Author

odersky commented Mar 20, 2017

Isn't it always good to avoid adding fields if possible?

The point is that "override val" seems non-sensical since the val is "overridden" with the same value it has already. But I agree it doe snot matter either way.

@smarter
Copy link
Member

smarter commented Mar 20, 2017

Indeed, but override val also allows you to refine the type of the val

Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@smarter smarter merged commit f009dc0 into scala:master Mar 20, 2017
@allanrenucci allanrenucci deleted the fix-param-fwd branch December 14, 2017 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants