-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
area:metaprogramming:macro-annotationsitype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymore
Milestone
Description
Compiler version
3.4.0-RC2
3.4.1-RC1-bin-20240125-453658b-NIGHTLY
Minimized code
import scala.annotation.{experimental, MacroAnnotation}
import scala.quoted.*
@experimental
class annotation extends MacroAnnotation:
def transform(using Quotes)(tree: quotes.reflect.Definition) = List(tree)
@scala.annotation.experimental
@annotation
class Test:
println()
Output
The code produces the following compilation error:
[error] -- Error: ~/test/src/main/scala/Test.scala:17:9
[error] 17 | println()
[error] | ^^^^^^^^^
[error] |Macro added a definition with the wrong owner - object Predef - class Test in ~/test/src/main/scala/Test.scala
[error] one error found
The macro annotation just returns the input tree without any modification.
The tested class only contains a single println()
statement, which triggers the issue. Both Scala 3.3.1 and 3.3.2-RC1 compile without an error. It would be nice if the issue would not make it into 3.4.
Expectation
The code should compile without errors.
The term println
indeed has the owner Predef
and not Test
(as the error message says). Yet, this is expected, not an error.
Metadata
Metadata
Assignees
Labels
area:metaprogramming:macro-annotationsitype:bugregressionThis worked in a previous version but doesn't anymoreThis worked in a previous version but doesn't anymore