Skip to content

FullParameterization: fix rewiring of Returns #383

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 1 commit into from
Mar 5, 2015

Conversation

smarter
Copy link
Member

@smarter smarter commented Feb 27, 2015

This assumes that an Ident corresponding to a method with extensions only occurs as the from field of a Return, can someone confirm that this will always be the case?
EDIT: I updated the code to do a case Return so the assumption above is no longer needed, but I'm still curious if Ident can appear anywhere else, otherwise we could remove the case Ident

Review by @odersky or @DarkDimius .

@DarkDimius
Copy link
Contributor

@smarter can you please include details about bug that you are fixing in commit message?

case Ident(_) => rewireCall(thisRef)
case Ident(_) =>
val rewired = rewiredTarget(tree, derived)
if (rewired.exists) // This only happens when `tree` is the `from` part of a Return
Copy link
Contributor

Choose a reason for hiding this comment

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

If Idents inside Returns need special handling, I'd prefer to handle them on Return node level. IE add case t: Return => which has special handling of return.

@smarter
Copy link
Member Author

smarter commented Feb 28, 2015

@DarkDimius: My hope was that the commit message + the test case was enough to understand what the commit was doing, but I'll see if I can add something to the description

@smarter smarter force-pushed the fix/fullyParameterizedDef branch from 9e3a9aa to a92f936 Compare February 28, 2015 00:54
if (rewired.exists)
Return(expr, Ident(rewired.termRef))
else
EmptyTree
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. That's a silent failure. Should at least issue ctx.error
  2. From could be an EmptyTree(which means return from enclsoing method), in this case calling
    rewiredTarget(NoSymbol, derived) doesn't make sense.
    Based on this I would better check if from.isEmpty and only if nonempty rewire from

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, EmptyTree here is a sentinel value. Disregard my comment about ctx.error

The `from` field of a Return tree should either be EmptyTree or an Ident
corresponding to the method we're returning from.
@smarter smarter force-pushed the fix/fullyParameterizedDef branch from a92f936 to a273f38 Compare March 2, 2015 21:35
@smarter
Copy link
Member Author

smarter commented Mar 3, 2015

Issue addressed, I also replaced my use of Return by tpd.cpy.Return, let me know if it's not appropriate in this context.

@DarkDimius
Copy link
Contributor

tpd.cpy.Return is going to fail to discover that it can reuse old tree, as it doesn't look at the internals of Ident, it looks only at reference equality of the Ident itself.
But at some moment it could be extended, though I don't believe that there would be a need to.
As this isn't a hotspot, and single virtual dispatch here isn't a problem, leaving as is.

DarkDimius added a commit that referenced this pull request Mar 5, 2015
FullParameterization: fix rewiring of Returns
@DarkDimius DarkDimius merged commit 23681e4 into scala:master Mar 5, 2015
tgodzik added a commit to tgodzik/scala3 that referenced this pull request May 2, 2025
Backport "Process Export for unused check" to 3.3 LTS
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