Skip to content

Commit 661dcc6

Browse files
committed
Add missing annotation shapes
1 parent c03c9b8 commit 661dcc6

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/TastyImpl.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ object TastyImpl extends scala.tasty.Tasty {
152152
else None
153153
}
154154

155-
def annots(implicit ctx: Context): List[Term] =
156-
x.symbol.annotations.map(_.tree)
155+
def annots(implicit ctx: Context): List[Term] = {
156+
x.symbol.annotations.flatMap {
157+
case _: core.Annotations.LazyBodyAnnotation => Nil
158+
case annot => annot.tree :: Nil
159+
}
160+
}
157161

158162
def localContext(implicit ctx: Context): Context =
159163
if (x.hasType && x.symbol.exists) ctx.withOwner(x.symbol)

library/src/scala/tasty/util/ShowSourceCode.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
214214

215215
val flags = ddef.flags
216216
if (flags.isImplicit) this += "implicit "
217+
if (flags.isInline) this += "inline "
217218
if (flags.isOverride) this += "override "
218219

219220
this += "def " += name
@@ -899,6 +900,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
899900
case Type.TypeRef(_, Type.SymRef(PackageDef("internal", _), Type.ThisType(Type.SymRef(PackageDef("annotation", _), NoPrefix())))) => false
900901
case _ => true
901902
}
903+
case x => throw new MatchError(x.show)
902904
}
903905
printAnnotations(annots)
904906
if (annots.nonEmpty) this += " "
@@ -961,7 +963,9 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
961963

962964
private object Annotation {
963965
def unapply(arg: Tree)(implicit ctx: Context): Option[(TypeTree, List[Term])] = arg match {
966+
case Term.New(annot) => Some((annot, Nil))
964967
case Term.Apply(Term.Select(Term.New(annot), "<init>", _), args) => Some((annot, args))
968+
case Term.Apply(Term.TypeApply(Term.Select(Term.New(annot), "<init>", _), targs), args) => Some((annot, args))
965969
case _ => None
966970
}
967971
}

tests/pos/i1570.decompiled

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** Decompiled from out/posTestFromTasty/pos/i1570/Test.class */
2+
object Test {
3+
inline def foo(n: scala.Int): scala.Int = Test.bar(n)
4+
inline def bar(n: scala.Int): scala.Int = n
5+
}

0 commit comments

Comments
 (0)