Skip to content
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

Traverser and Transformer in reflection API do not handle owner chains #10214

Open
scabug opened this issue Feb 28, 2017 · 5 comments
Open

Traverser and Transformer in reflection API do not handle owner chains #10214

scabug opened this issue Feb 28, 2017 · 5 comments
Milestone

Comments

@scabug
Copy link

scabug commented Feb 28, 2017

I think each of the following 2 lines contain a bug; a Template cannot become the owner of other symbols, isn't it?

This issue may lead compiler crashes when compiler plugins using Traverser class are enabled since it breaks owner chains.

I made a patch only for Traverser: hiroshi-cl/scala@b219db7, but I failed to make for Transformer.
This fixing breaks existing compiler phases and a lot of test cases in partest fail.

@scabug
Copy link
Author

scabug commented Feb 28, 2017

Imported From: https://issues.scala-lang.org/browse/SI-10214?orig=1
Reporter: Hiroshi Yamaguchi (hiroshi-cl)
Affected Versions: 2.11.8, 2.12.1

@scabug
Copy link
Author

scabug commented Mar 1, 2017

@adriaanm said:
A template does have a symbol, which is called the "local dummy", and it is used as the owner for blocks inside the template body.

The symbol is created in typedTemplate:

      if (templ.symbol == NoSymbol)
        templ setSymbol clazz.newLocalDummy(templ.pos)

@scabug
Copy link
Author

scabug commented Mar 1, 2017

Hiroshi Yamaguchi (hiroshi-cl) said (edited on Mar 1, 2017 1:16:12 AM UTC):
Thank you for your response. I have a question: is the following code correct?

      case Template(parents, self, body) =>
        traverseParents(parents)
        traverseSelfType(self)
        traverseStats(body, if(templ.symbol == NoSymbol) currentOwner else tree.symbol

@scabug
Copy link
Author

scabug commented Mar 1, 2017

@adriaanm said:
I'm not sure, sorry, but I suspect the underlying problem is related to traversing untyped trees. I suggest looking at https://github.com/scala/scala/blob/2.12.x/src/compiler/scala/tools/nsc/transform/TypingTransformers.scala#L40-L40 for some inspiration.

@scabug
Copy link
Author

scabug commented Mar 2, 2017

Hiroshi Yamaguchi (hiroshi-cl) said:
I will try your suggestion. Thank you.

@scabug scabug added the quickfix label Apr 7, 2017
@scabug scabug added this to the Backlog milestone Apr 7, 2017
@SethTisue SethTisue changed the title Traverser and Transformer in reflaction API do not handle owner chains Traverser and Transformer in reflection API do not handle owner chains Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants