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

0.13.11 regression: incremental compiler misses when macro expansion references another source #2560

Closed
eed3si9n opened this issue Apr 15, 2016 · 2 comments
Assignees
Labels
Milestone

Comments

@eed3si9n
Copy link
Member

eed3si9n commented Apr 15, 2016

steps

  1. Macro expansion in A.scala references another source B.scala.
  2. Change B.scala.

problem

A.scala doesn't get compiled.

expectation

A.scala gets compiled.

notes

This can be confirmed when "member reference internal dependencies" doesn't contain the entry from A.scala to B.scala.

This was caused by 0f61629:

   override def traverse(tree: Tree): Unit = tree match {
     ....
      case MacroExpansionOf(original) if inspectedOriginalTrees.add(original) => traverse(original)
      case other => super.traverse(other)
    }

This won't traverse into an Apply tree, for instance if it has MacroExpansionAttachment. The fix is to call super.traverse(tree) for MacroExpansionOf case as well.

@eed3si9n eed3si9n added the Bug label Apr 15, 2016
@eed3si9n eed3si9n added this to the 0.13.12 milestone Apr 15, 2016
@gkossakowski
Copy link
Contributor

Do you know why existing scripted tests for macros didn't catch the regression?

eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 18, 2016
Unlike other scripted macro tests, the call site of this macro is
`Provider.tree(0)`, which does not introduce internal member reference.
Instead the macro itself calls `Bar.bar(0)`. Due to sbt#2560, the expanded
tree is not traversed, and thus the reference to `Bar` is not caught
during incremental compilation.
eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 18, 2016
traverse(tree: Tree) used to call super.traverse(tree) at the end.
sbt/sbt@0f61629 brought the traversing
call to inside of the pattern matching.
For the case of MacroExpansionOf(original), it amounts to not traveling
the macro-expanded code. See
sbt/src/sbt-test/source-dependencies/macro-nonarg-dep for the repro.
@eed3si9n eed3si9n self-assigned this Apr 18, 2016
@eed3si9n
Copy link
Member Author

@gkossakowski See the new repro in #2563. The existing scripted tests didn't catch this because the macro is too simple, and it doesn't introduce new member ref beyond the original tree.

eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 18, 2016
Unlike other scripted macro tests, the call site of this macro is
`Provider.tree(0)`, which does not introduce internal member reference.
Instead the macro itself calls `Bar.bar(0)`. Due to sbt#2560, the expanded
tree is not traversed, and thus the reference to `Bar` is not caught
during incremental compilation.
eed3si9n added a commit to eed3si9n/sbt that referenced this issue Apr 18, 2016
traverse(tree: Tree) used to call super.traverse(tree) at the end.
sbt/sbt@0f61629 brought the traversing
call to inside of the pattern matching.
For the case of MacroExpansionOf(original), it amounts to not traveling
the macro-expanded code. See
sbt/src/sbt-test/source-dependencies/macro-nonarg-dep for the repro.
eed3si9n added a commit that referenced this issue Apr 19, 2016
Fixes incremental compiler missing member ref from macro expansion #2560
eed3si9n added a commit to eed3si9n/scala that referenced this issue May 14, 2019
traverse(tree: Tree) used to call super.traverse(tree) at the end.
sbt/sbt@0f61629 brought the traversing
call to inside of the pattern matching.
For the case of MacroExpansionOf(original), it amounts to not traveling
the macro-expanded code. See
sbt/src/sbt-test/source-dependencies/macro-nonarg-dep for the repro.
lrytz pushed a commit to lrytz/scala that referenced this issue Nov 5, 2019
traverse(tree: Tree) used to call super.traverse(tree) at the end.
sbt/sbt@0f61629 brought the traversing
call to inside of the pattern matching.
For the case of MacroExpansionOf(original), it amounts to not traveling
the macro-expanded code. See
sbt/src/sbt-test/source-dependencies/macro-nonarg-dep for the repro.

Rewritten from sbt/zinc@acf4fac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants