Skip to content

Demonstrate regression in #4949 for positions of quote-inlined code #5048

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

Closed

Conversation

Blaisorblade
Copy link
Contributor

@Blaisorblade Blaisorblade commented Aug 27, 2018

Testcase moved here from #5009. Edited comment from there:

It seems to have been broken by #4949 (not by #4990, I rechecked). /cc @nicolasstucki

Reason: After #4949, calling from Test.main transparent function from the same file Test.assert2 causes no repositioning; but the output trees actually come from Macros so they must be repositioned. This was an existing bug (which affected sourcePos even earlier); to fix this without changing enclosedInlineds, one needs
a node Inlined(Macros.assertImpl(...), ...) around the quote body, in addition.

Especially if there can be both code from the transparent function and from the splice, we'd need something like

Inlined(assert2(...), ...,
  Inlined(Macros.assertImpl(...), ..., {
    printStack("assertImpl")
    println(Inlined(EmptyTree, Nil, Inlined(EmptyTree, Nil, x != 0)))
  })
)

We do need two EmptyTree around x != 0 to signal it does come from the original call site. Not 100% sure what goes in the ellipses.

PostTyper can strip the call as usual, no problem.

// in the call field of an Inlined node.
// The trace has enough info to completely reconstruct positions.
val callTrace = Ident(ctx.owner.topLevelClass.typeRef).withPos(body1.pos)
Inlined(callTrace, Nil, body1)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Readers will like a reference to code in PostTyper.transform producing this format, since they’ll need to keep them in sync.

@nicolasstucki nicolasstucki force-pushed the show-4949-regressions branch 3 times, most recently from 6658fb2 to c59e09f Compare September 4, 2018 15:20
@nicolasstucki nicolasstucki force-pushed the show-4949-regressions branch 11 times, most recently from c236e4f to 1632156 Compare September 6, 2018 11:45
Also move logic that flattens blocks to the decompiler and make it stricter
@nicolasstucki
Copy link
Contributor

Waiting for refactorings of #5132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants