diff --git a/parsley-debug/shared/src/main/scala-2/parsley/debuggable.scala b/parsley-debug/shared/src/main/scala-2/parsley/debuggable.scala index 6b0708bba..cea7ef0e6 100644 --- a/parsley-debug/shared/src/main/scala-2/parsley/debuggable.scala +++ b/parsley-debug/shared/src/main/scala-2/parsley/debuggable.scala @@ -48,16 +48,18 @@ private object debuggable { private def collect(c: blackbox.Context)(treeName: String, defs: List[c.Tree], recon: List[c.Tree] => c.Tree): c.Tree = { import c.universe._ val parsleyTy = c.typeOf[Parsley[_]].typeSymbol + val noBody = atPos(c.enclosingPosition)(q"??? : @scala.annotation.nowarn") // can't typecheck constructors in a stand-alone block val noConDefs = defs.flatMap { case DefDef(_, name, _, _, _, _) if name == TermName("") => None // in addition, on 2.12, we need to remove `paramaccessor` modifiers on constructor arguments case ValDef(Modifiers(_, _, annotations), name, tpt, x) => // if the type tree is not empty, then we might as well scratch out the body -- helps remove problem values! - // just to be safe, we'll also mark them as LAZY to avoid "dead code following construct" - Some(ValDef(Modifiers(Flag.LAZY, typeNames.EMPTY, annotations), name, tpt, if (tpt.nonEmpty) q"???" else x)) + // must use lazy here to fix problems with nested objects, for some reason... + Some(ValDef(Modifiers(Flag.LAZY, typeNames.EMPTY, annotations), name, tpt, if (tpt.nonEmpty) noBody else x)) + // FIXME: probably strip mods from all defdefs as above? // if the type tree is not empty, then we might as well scratch out the body -- helps remove problem values! - case DefDef(mods, name, tyArgs, args, tpt, _) if tpt.nonEmpty => Some(DefDef(mods, name, tyArgs, args, tpt, q"???")) + case DefDef(mods, name, tyArgs, args, tpt, _) if tpt.nonEmpty => Some(DefDef(mods, name, tyArgs, args, tpt, noBody)) case dfn => Some(dfn) } val typeMap = c.typecheck(q"..${noConDefs}", c.TERMmode, silent = true) match { diff --git a/parsley-debug/shared/src/test/scala/annotation/AnnotationTestObjects.scala b/parsley-debug/shared/src/test/scala/annotation/AnnotationTestObjects.scala index 0d8e1f506..d1f25570a 100644 --- a/parsley-debug/shared/src/test/scala/annotation/AnnotationTestObjects.scala +++ b/parsley-debug/shared/src/test/scala/annotation/AnnotationTestObjects.scala @@ -20,7 +20,7 @@ class parsers(val x: Int) { val q = p ~> p lazy val r: Parsley[Char] = ~r ~> q def s = otherParsers.a - val y = 7 + val y = 8 def this(f: Float) = this(f.toInt) def many[A](p: Parsley[A]): Parsley[List[A]] = Parsley.many(p) @@ -38,4 +38,3 @@ object Extender extends AbsCls { override val xs = List(7) override def foo = 5 } - diff --git a/parsley-debug/shared/src/test/scala/parsley/debugger/DebuggerUsageSpec.scala b/parsley-debug/shared/src/test/scala/parsley/debugger/DebuggerUsageSpec.scala index e092c5e2c..08ff98ff2 100644 --- a/parsley-debug/shared/src/test/scala/parsley/debugger/DebuggerUsageSpec.scala +++ b/parsley-debug/shared/src/test/scala/parsley/debugger/DebuggerUsageSpec.scala @@ -90,7 +90,6 @@ class DebuggerUsageSpec extends ParsleyTest { } } -// Look, for some reason the annotation dies if it's nested, I don't know why, it's impossible to diagnose object DebuggerUsageSpec { @experimental @parsley.debuggable private [parsley] object Arithmetic {