-
Notifications
You must be signed in to change notification settings - Fork 383
Open
Labels
Scala 3Generic ticket relating to Scala 3Generic ticket relating to Scala 3bugSomething that is making a piece of functionality unusableSomething that is making a piece of functionality unusablepresentation-compilerSomething relating to the presentation compilerSomething relating to the presentation compiler
Description
Describe the bug
Scala version: 3.7.0
object Main extends App {
val x = Macros.foo
val y = Macros.bar
x.substring(2, 4) // works as expected
y.substring(2, 4) // compiles, but no IDE suggestions
println(y)
}
There are IDE suggestions for x
, but no suggestions for y
(see screenshots below).
The only difference between the macros foo
and bar
is that bar
accesses the position of macro expansion:
import scala.quoted.*
object Macros {
transparent inline def foo: String =
${ fooImpl }
private def fooImpl(using Quotes): Expr[String] =
Expr("foo...")
transparent inline def bar: String =
${ barImpl }
private def barImpl(using Quotes): Expr[String] =
quotes.reflect.Position.ofMacroExpansion.sourceFile.getJPath.get // this line is the culprit
Expr("bar...")
}
Good (type of x
is known to be String
):
Bad (type of y
is unknown):
Expected behavior
Mere access to source position in macro expansion should not break the IDE experience.
Operating system
macOS
Editor/Extension
VS Code
Version of Metals
1.50.0
Extra context or search terms
No response
Metadata
Metadata
Assignees
Labels
Scala 3Generic ticket relating to Scala 3Generic ticket relating to Scala 3bugSomething that is making a piece of functionality unusableSomething that is making a piece of functionality unusablepresentation-compilerSomething relating to the presentation compilerSomething relating to the presentation compiler
Type
Projects
Status
Triage