Skip to content

Intrinsify StringContext.f #9929

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

Conversation

nicolasstucki
Copy link
Contributor

Ported the current macro implementation

@nicolasstucki
Copy link
Contributor Author

This will unblock #9925

import dotty.tools.dotc.core.Types._

// Ported from old dotty.internal.StringContextMacro
// TODO: port Scala 2 logic? (see https://github.com/scala/scala/blob/2.13.x/src/compiler/scala/tools/reflect/FormatInterpolator.scala#L74)
Copy link
Member

Choose a reason for hiding this comment

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

What does the Scala 2 logic do that is different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is a completely different implementation. Not sure which one is better. Someone will have to check that at some point.

Copy link
Contributor

Choose a reason for hiding this comment

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

scala 2 f goes overboard to verify the format, but is it worthwhile maintaining code for a slow string mechanism.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I remember this implementation covered all the Scala 2 f interpolator test cases. They diverged slightly on the second error after some kinds of error in the format part of the string.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought I saw checks that weren't implemented (way in the past); if I have a chance, I'll compare again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We might have missed something. It would be ok for me to use the Scala 2 implementation but it would take a more effort to port. I could have a look in the future or let someone else try it. The current priority is to unblock #9925.

Ported the current macro implementation
@nicolasstucki nicolasstucki force-pushed the intrinsify-StringContext.f branch from 14ae862 to ef19bcd Compare October 1, 2020 14:55
@nicolasstucki nicolasstucki marked this pull request as ready for review October 1, 2020 16:42
@nicolasstucki nicolasstucki requested a review from smarter October 1, 2020 16:42
@nicolasstucki nicolasstucki merged commit 826a089 into scala:master Oct 1, 2020
@nicolasstucki nicolasstucki deleted the intrinsify-StringContext.f branch October 1, 2020 18:56
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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