diff --git a/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala b/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala index b9efdf59146d..7d33317a9eef 100644 --- a/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala +++ b/compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala @@ -152,8 +152,12 @@ object TastyImpl extends scala.tasty.Tasty { else None } - def annots(implicit ctx: Context): List[Term] = - x.symbol.annotations.map(_.tree) + def annots(implicit ctx: Context): List[Term] = { + x.symbol.annotations.flatMap { + case _: core.Annotations.LazyBodyAnnotation => Nil + case annot => annot.tree :: Nil + } + } def localContext(implicit ctx: Context): Context = if (x.hasType && x.symbol.exists) ctx.withOwner(x.symbol) diff --git a/library/src/scala/tasty/util/ShowSourceCode.scala b/library/src/scala/tasty/util/ShowSourceCode.scala index d28cad8b4f7d..86a1b629bc75 100644 --- a/library/src/scala/tasty/util/ShowSourceCode.scala +++ b/library/src/scala/tasty/util/ShowSourceCode.scala @@ -214,6 +214,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty val flags = ddef.flags if (flags.isImplicit) this += "implicit " + if (flags.isInline) this += "inline " if (flags.isOverride) this += "override " this += "def " += name @@ -231,16 +232,8 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty } this - case tree @ Term.Ident(name) => - tree.tpe match { - case Type.SymRef(_, Types.EmptyPrefix()) | Type.TermRef(_, Types.EmptyPrefix()) => this += name - case Type.SymRef(_, prefix) => - printTypeOrBound(prefix) - this += "." += name - case Type.TermRef(_, prefix) => - printTypeOrBound(prefix) - this += "." += name - } + case tree @ Term.Ident(_) => + printType(tree.tpe) case Term.Select(qual, name, sig) => printTree(qual) @@ -907,6 +900,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty case Type.TypeRef(_, Type.SymRef(PackageDef("internal", _), Type.ThisType(Type.SymRef(PackageDef("annotation", _), NoPrefix())))) => false case _ => true } + case x => throw new MatchError(x.show) } printAnnotations(annots) if (annots.nonEmpty) this += " " @@ -969,7 +963,9 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty private object Annotation { def unapply(arg: Tree)(implicit ctx: Context): Option[(TypeTree, List[Term])] = arg match { + case Term.New(annot) => Some((annot, Nil)) case Term.Apply(Term.Select(Term.New(annot), "", _), args) => Some((annot, args)) + case Term.Apply(Term.TypeApply(Term.Select(Term.New(annot), "", _), targs), args) => Some((annot, args)) case _ => None } } diff --git a/tests/pos/i1570.decompiled b/tests/pos/i1570.decompiled new file mode 100644 index 000000000000..3f4d040e376b --- /dev/null +++ b/tests/pos/i1570.decompiled @@ -0,0 +1,5 @@ +/** Decompiled from out/posTestFromTasty/pos/i1570/Test.class */ +object Test { + inline def foo(n: scala.Int): scala.Int = Test.bar(n) + inline def bar(n: scala.Int): scala.Int = n +}