Skip to content

Move Staging to Typer #5846

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

Merged
merged 17 commits into from
Mar 7, 2019
Merged

Conversation

nicolasstucki
Copy link
Contributor

@nicolasstucki nicolasstucki commented Feb 5, 2019

The main motivation for moving staging to typer is to support whitebox macros.

Using the <: T return type notation.

/** Returns a Char if the string is of length 1 or a String otherwise */
inline def charOrString(inline str: String) <: Char | String = ${ impl(str) }
def impl(str: String) = if (str.length == 1) str.charAt(0).toExpr else str.toExpr
// Different file
val x: Char = charOrString("1")
val y: String = charOrString("123")

Modification:

  • Staging is used in Typer to check contents of inline macros
  • Expand macros in Inliner durring typing
  • Keep track of quotation level in the context
  • Lose support for inspection of any tree in the current compilation unit. With the exception of parameter bindings which can be inspected.

@nicolasstucki nicolasstucki self-assigned this Feb 5, 2019
@nicolasstucki nicolasstucki force-pushed the move-staging-to-typer branch 6 times, most recently from 361f777 to 20447f1 Compare February 12, 2019 12:08
@nicolasstucki nicolasstucki force-pushed the move-staging-to-typer branch 6 times, most recently from b30731f to 177373a Compare February 14, 2019 14:46
@nicolasstucki
Copy link
Contributor Author

nicolasstucki commented Feb 18, 2019

Needs rebase on #5940 and remove 08a391d

@OlivierBlanvillain
Copy link
Contributor

@nicolasstucki Can you explain the motivation for this change?

@nicolasstucki
Copy link
Contributor Author

Mainly to support whitebox macros

@nicolasstucki nicolasstucki force-pushed the move-staging-to-typer branch 5 times, most recently from 08d6113 to 867e7dc Compare February 20, 2019 12:30
@nicolasstucki nicolasstucki force-pushed the move-staging-to-typer branch 6 times, most recently from defc91e to 0693667 Compare February 21, 2019 13:54
@odersky odersky assigned nicolasstucki and unassigned odersky Mar 5, 2019
@odersky
Copy link
Contributor

odersky commented Mar 6, 2019

I only have one more comment on the last commit. Otherwise it's good.

@nicolasstucki nicolasstucki force-pushed the move-staging-to-typer branch from 1a192fa to a6dcc2e Compare March 7, 2019 12:23
@nicolasstucki nicolasstucki force-pushed the move-staging-to-typer branch from a6dcc2e to cb4497a Compare March 7, 2019 12:34
Macros seem to be expanded before the comments are registered in the symbol.
Comments where added to be used while loadind a TASTy file trough the tasty.Reflection API,
hence this use case is not critical.

See scala#6032
@nicolasstucki
Copy link
Contributor Author

Rebased

@odersky odersky merged commit 757e2d1 into scala:master Mar 7, 2019
@ghost ghost removed the stat:needs review label Mar 7, 2019
@smarter smarter added this to the 0.14 Tech Preview milestone Mar 14, 2019
@liufengyun liufengyun deleted the move-staging-to-typer branch August 12, 2019 12:12
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.

4 participants