Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support zinc invalidation for type arguments in macro calls #23900

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

Open
jchyb wants to merge 3 commits into scala:main
base: main
Choose a base branch
Loading
from dotty-staging:fix-23852-invalidate-macro-type-arg

Conversation

Copy link
Contributor

@jchyb jchyb commented Sep 11, 2025
edited
Loading

Fixes #23852
Closes #19426

Around a year ago a new DependencyContext value was added to the zinc api: DependencyByMacroExpansion.
It causes the recorded dependency to trigger recompilation if there is any API change in the recorded type, not just if the feudal/method member that was explicitly referenced was changed. So now, for every inline call:
macroCall[T1, T2, ...], in file call.scala, if anything changes in a TN definition, call.scala is recompiled.

Since DependencyByMacroExpansion was added later to the API, referencing it in older versions (e.g. any sbt < 1.10.0), would cause crashes. to avoid that, we use reflection to check if that field exists.

These changes do not seem to affect #23783, likely the way annotations are handled needs to be changed in zinc itself, as the APIInfo phase does successfully record the change in the annotation argument.

Related discussion: sbt/zinc#1316 (a PR adding the functionality to zinc and scala-2 plugin).

He-Pin reacted with thumbs up emoji
Copy link
Contributor Author

jchyb commented Sep 15, 2025

Hi @bishabosha, would you be able to review this? If not, then I think I can ask @tgodzik, but he's more of an expert on the zinc side than the compiler side I think.

Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

A valuable improvement!

He-Pin reacted with thumbs up emoji
private def addMacroDependency(sym: Symbol)(using Context): Unit =
if (allowsDependencyByMacroExpansion) {
if (!ignoreDependency(sym)) {
if (!sym.is(Package)) {
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the package test redundant, because it's already in TypeDependencyTraverser.traverse?

val traverser = new TypeDependencyTraverser {
def addDependency(symbol: Symbol) = addMacroDependency(symbol)
}
trees.foreach(tree => traverser.traverse(tree.tpe))
Copy link
Member

@bishabosha bishabosha Sep 18, 2025

Choose a reason for hiding this comment

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

Looks like this whole function should be elided when the macro dependency tracking is unavailable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@bishabosha bishabosha bishabosha left review comments

@lrytz lrytz lrytz approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Macro usage is not invalidated Test impact of macros on incremental compilation when type parameter changes

AltStyle によって変換されたページ (->オリジナル) /