Skip to content

Conversation

@nicolasstucki
Copy link
Contributor

  • Only allow access to inline macro parameters in stage 0 if they have type Boolean, Byte, Short, Int, Long, Float, Double, Char or String

This change in semantics allows us to support inline parameters of function type.

@Blaisorblade
Copy link
Contributor

Blaisorblade commented May 4, 2018

For context: the motivation for this semantics in #4431 is that this is a limited form of cross-stage persistence (maybe in reverse) or inspection of trees, which is easy for literals/primitive types but hard in general. (Tho, I was thinking of using a typeclass for extensibility). 👍 for the semantic change (and for updating docs).

* to
* ```
* inline def foo[T1, ...](inline x1: X, ..., y1: Y, ....): Seq[Any] => Object = { (args: Seq[Any]) => {
* inline def foo[T1, ...](inline x1: X, ..., y1: Y, ..., inline f1: X => Y): Seq[Any] => Object = { (args: Seq[Any]) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add f1 at the original form as well in the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it and made it part of the comment below

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems good, nice.

@nicolasstucki nicolasstucki requested review from biboudis and removed request for odersky May 12, 2018 06:53
@nicolasstucki nicolasstucki assigned biboudis and unassigned odersky May 12, 2018
}

private def isStage0Value(sym: Symbol)(implicit ctx: Context): Boolean =
sym.is(Inline) && sym.owner.is(Macro) && !defn.isFunctionType(sym.info)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The addition of !defn.isFunctionType(sym.info) is the only real change in this PR, the rest is refactoring.

Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

After discussion with Aggelos, also LGTM for me.

@Blaisorblade "cross stage persistence in reverse" is a good way to characterize this.

@nicolasstucki nicolasstucki merged commit 0a486e3 into scala:master May 14, 2018
@Blaisorblade Blaisorblade deleted the fix-#4431 branch May 14, 2018 16:01
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