Skip to content

Conversation

@som-snytt
Copy link
Contributor

Fixes scala/scala3#20591

Besides the use of jpath, the scala 2 macro impl must be public. I tried to verify the steps as presented, but did not quite have the patience; probably the sophisticated user will fill in any gaps.

It's hard not to turn it into an sbt tutorial.

It's nicer just to say + test.

import quotes.reflect.Position
val pos = Position.ofMacroExpansion
val file = Expr(pos.sourceFile.jpath.toString)
val path = Expr(pos.sourceFile.path)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

They preferred getJPath.getOrElse on the related PR. But I think source must have a path, but may not have a file. A source must have a path because I need to be able to report errors at a location, even if the location is virtual. It's not a Scala thing but an API thing.

@som-snytt som-snytt closed this Aug 10, 2024
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.

Issue with macros and in-memory (virtual) source files

1 participant