Skip to content

Fix the source of inlined trees after Erasure #5883

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 3 commits into from
Feb 14, 2019

Conversation

nicolasstucki
Copy link
Contributor

To ensure that the sources change, the trees need to be copied with the
new source rather than preserving it.

@nicolasstucki nicolasstucki self-assigned this Feb 8, 2019
@nicolasstucki nicolasstucki force-pushed the fix-source-after-erasure branch 5 times, most recently from e6a7ce8 to 036ab3b Compare February 11, 2019 12:44
To ensure that the sources change, the trees need to be copied with the
new source rather than preserving it.
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

I wonder whether there's not a less intrusive way to do it:

  • In Reposition, copy all leaf trees manually, using untpd constructor methods instead of cpy.
  • Then use the tree copier for the rest. That still needs sourceFile, but we don't need to test for
    sameSource anymore.

@odersky odersky assigned nicolasstucki and unassigned odersky Feb 11, 2019
@nicolasstucki nicolasstucki force-pushed the fix-source-after-erasure branch from 665afb3 to 0984428 Compare February 12, 2019 10:58
@nicolasstucki nicolasstucki force-pushed the fix-source-after-erasure branch from 0984428 to 983eb87 Compare February 12, 2019 11:02
@odersky odersky merged commit fa8471d into scala:master Feb 14, 2019
@ghost ghost removed the stat:needs review label Feb 14, 2019
@liufengyun liufengyun deleted the fix-source-after-erasure branch February 14, 2019 12:39
}
def RefinedTypeTree(tree: Tree)(tpt: Tree, refinements: List[Tree])(implicit ctx: Context): RefinedTypeTree = tree match {
case tree: RefinedTypeTree if (tpt eq tree.tpt) && (refinements eq tree.refinements) => tree
case _ => finalize(tree, untpd.RefinedTypeTree(tpt, refinements)(tree.source))
case _ => finalize(tree, untpd.RefinedTypeTree(tpt, refinements)(sourceFile(tree)))
}
def AppliedTypeTree(tree: Tree)(tpt: Tree, args: List[Tree])(implicit ctx: Context): AppliedTypeTree = tree match {
case tree: AppliedTypeTree if (tpt eq tree.tpt) && (args eq tree.args) => tree
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember from #5892 there used to be a check sameSourceFile in the case, why it is not needed anymore?

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.

3 participants