You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a macro annotation with paradise, which typechecks an annotated ValDef. It compiles in scala 2.11.11, but gives an illegal cyclic reference error in 2.12.2. I am not sure whether this a scala bug or because of paradise. A short example:
importscala.reflect.macros.whitebox.Contextimportscala.language.experimental.macrosimportscala.annotation.{StaticAnnotation, compileTimeOnly}
objectMacro {
defimpl(c: Context)(annottees: c.Expr[Any]*): c.Expr[Any] = {
importc.universe._
annottees.map(_.tree) match {
case (valDef: ValDef) :: _ =>//this works in scala 2.11.11 and 2.12.2
c.typecheck(valDef, withMacrosDisabled =true)
//this works in scala 2.11.11, but not in 2.12.2valunmodValDef=ValDef(Modifiers(), valDef.name, valDef.tpt, valDef.rhs)
c.typecheck(unmodValDef, withMacrosDisabled =true)
annottees.head
case _ => c.abort(c.enclosingPosition, "unsupported annotation")
}
}
}
@compileTimeOnly("only for compile time expansion")
classexampleextendsStaticAnnotation {
defmacroTransform(annottees: Any*):Any= macro Macro.impl
}
Using this annotation on a val:
// using a trait instead of a class compiles in 2.12.2classWrap {
@example valx:Int=1
}
In 2.12.2, this leads to an illegal cyclic reference error:
[error] [0] /scala/ExampleSpec.scala:7: illegal cyclic reference involving class Wrap
This is the failing code:
valunmodValDef=ValDef(Modifiers(), valDef.name, valDef.tpt, valDef.rhs)
//this works in scala 2.11.11, but not in 2.12.2
c.typecheck(unmodValDef, withMacrosDisabled =true)
I have a macro annotation with paradise, which typechecks an annotated
ValDef
. It compiles in scala2.11.11
, but gives anillegal cyclic reference
error in2.12.2
. I am not sure whether this a scala bug or because of paradise. A short example:Using this annotation on a
val
:In
2.12.2
, this leads to anillegal cyclic reference
error:This is the failing code:
An example project with repro.
The text was updated successfully, but these errors were encountered: