Skip to content

Prepare to make StringContext.{f,raw} into macros#7678

Merged
adriaanm merged 1 commit intoscala:2.13.xfrom
adriaanm:interpol_fasttr
Feb 4, 2019
Merged

Prepare to make StringContext.{f,raw} into macros#7678
adriaanm merged 1 commit intoscala:2.13.xfrom
adriaanm:interpol_fasttr

Conversation

@adriaanm
Copy link
Contributor

@adriaanm adriaanm commented Jan 23, 2019

hijack string interpolators during typer

after bootstrap, we can turn the def s / def raw's RHS into macro ???
until then, pretend they are

Fix scala/bug#11366
Backstop for scala/bug#10870, but could be improved

@smarter
Copy link
Member

smarter commented Jan 23, 2019

after bootstrap, we can turn the def s / def raw's RHS into macro ???

That will break any use of these methods from projects compiled with Dotty. We might be able to shadow them to avoid that but we'll need to coordinate on that.

@scala-jenkins scala-jenkins added this to the 2.13.0-RC1 milestone Jan 23, 2019
@adriaanm adriaanm requested a review from smarter January 23, 2019 15:12
@adriaanm
Copy link
Contributor Author

We'd like to perform the bootstrap before RC1. Do you think that's workable?

@adriaanm adriaanm requested a review from retronym January 23, 2019 15:38
@smarter
Copy link
Member

smarter commented Jan 23, 2019

Not sure, we still have some work to do to catch up with the recent changes to the standard library (unapply for string interpolators, ...).

after bootstrap, we can turn the def s / def raw's RHS into macro ???
until then, pretend they are

Minimal backstop for bug 10870
final class RunDefinitions {
// until we bootstrap and they are implemented as `macro ???` to trigger fasttrack directly
def treatLikeMacro(sym: Symbol) =
sym.isMethod && ((sym.name == nme.s || sym.name == nme.raw_) && sym.owner == StringContextClass) && (sym == StringContext_s || sym == StringContext_raw)
Copy link
Member

Choose a reason for hiding this comment

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

Why not just:

def treatLikeMacro(sym: Symbol) = (sym eq StringContext_s) || (sym eq StringContext_raw)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This method seemed to be hit a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Early on in type checking, so didn’t want to force symbols when not needed.)

@retronym
Copy link
Member

This is a novel approach to fast-tracking the way to FastTrack. I think I understand it, seems okay :)

Have you locally tried the followup change? Could you share that branch so we can see the end result?

try
parts.mapConserve { case lit@Literal(Constant(stringVal: String)) =>
val k = Constant(StringContext.processEscapes(stringVal))
// To avoid the backlash of backslash, taken literally by Literal, escapes are processed strictly (scala/bug#11196)
Copy link
Contributor

Choose a reason for hiding this comment

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

That's quite some comment archaeology.

@adriaanm
Copy link
Contributor Author

adriaanm commented Jan 24, 2019

Yep, I’ve confirmed that STARRing this PR, the method bodies of the two interpolators can be macro ???. That’s the entirety of the patch (although we can also remove the ugly treatLikeMacro)

@adriaanm adriaanm merged commit 949e7c5 into scala:2.13.x Feb 4, 2019
@SethTisue SethTisue changed the title hijack string interpolators during typer Make StringContext.{f,raw} into macros Feb 4, 2019
@SethTisue SethTisue changed the title Make StringContext.{f,raw} into macros Prepare to make StringContext.{f,raw} into macros Feb 4, 2019
@SethTisue
Copy link
Member

we have now re-STARRed

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.

6 participants