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

Fix #7138: Suspend callers of macros compiled in the same run #7324

Merged
merged 31 commits into from
Oct 28, 2019

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 26, 2019

Allows macros to be defined and called in the same project. The idea is to suspend
the callers of a macro (and their upstream dependencies), compile the sourcefile(s)
containing the macro(s), and then compile the suspended files in a second run.

The scheme detects and flags as errors calls to macros in the same file and mutual
dependencies between different files which would not work with suspensions.

It needs to be complemented by another mechanism that checks that class files loaded
by a macro class loader do not have associated source files that are currently compiled.

@odersky

This comment has been minimized.

@nicolasstucki

This comment has been minimized.

@odersky

This comment has been minimized.

@nicolasstucki

This comment has been minimized.

@liufengyun

This comment has been minimized.

@odersky

This comment has been minimized.

@nicolasstucki

This comment has been minimized.

@nicolasstucki
Copy link
Contributor

I tried converting all pos-macros and run-macros be compiled in a single step and use suspension. They all passed the tests. I will not add them to avoid duplication in tests.

@nicolasstucki nicolasstucki force-pushed the add-suspend branch 2 times, most recently from e436d28 to 4317e7c Compare October 2, 2019 14:28
@nicolasstucki nicolasstucki marked this pull request as ready for review October 3, 2019 11:20
@nicolasstucki nicolasstucki changed the title Suspend callers of macros compiled in the same run Fix #7138: Suspend callers of macros compiled in the same run Oct 4, 2019
@nicolasstucki nicolasstucki requested review from liufengyun and removed request for smarter October 4, 2019 15:54
@nicolasstucki nicolasstucki assigned liufengyun and unassigned smarter Oct 4, 2019
@nicolasstucki
Copy link
Contributor

nicolasstucki commented Oct 4, 2019

@liufengyun the commits from @odersky LGTM but you should have a second look.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

While the utility enabled by the PR is doubtless, this PR makes it easier to write code that has subtle dependencies than before. The current error messages may not be helpful enough to resolve cyclic compilation errors, which may hurt usability.

What about putting the feature under a compiler flag?

docs/docs/reference/metaprogramming/macros.md Outdated Show resolved Hide resolved
docs/docs/reference/metaprogramming/macros.md Outdated Show resolved Hide resolved
docs/docs/reference/metaprogramming/macros.md Outdated Show resolved Hide resolved
docs/docs/reference/metaprogramming/macros.md Outdated Show resolved Hide resolved
@nicolasstucki
Copy link
Contributor

@liufengyun the incremental compilation example actually works (or fails as expected). The incremental compiler trigger recompilation of macros when b is recompiled which makes it fail the same way it would from a clean compilation. I added it as a regression test.

@liufengyun
Copy link
Contributor

rebased to fix conflicts

@anatoliykmetyuk anatoliykmetyuk merged commit 9193c44 into scala:master Oct 28, 2019
@anatoliykmetyuk anatoliykmetyuk deleted the add-suspend branch October 28, 2019 15:09
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.

5 participants