Skip to content

Commit 71ca66f

Browse files
authored
Merge pull request #4681 from dotty-staging/fix-annotations
Add missing annotation shapes
2 parents 67b1f03 + 01f19b4 commit 71ca66f

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
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: 6 additions & 10 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
@@ -231,16 +232,8 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
231232
}
232233
this
233234

234-
case tree @ Term.Ident(name) =>
235-
tree.tpe match {
236-
case Type.SymRef(_, Types.EmptyPrefix()) | Type.TermRef(_, Types.EmptyPrefix()) => this += name
237-
case Type.SymRef(_, prefix) =>
238-
printTypeOrBound(prefix)
239-
this += "." += name
240-
case Type.TermRef(_, prefix) =>
241-
printTypeOrBound(prefix)
242-
this += "." += name
243-
}
235+
case tree @ Term.Ident(_) =>
236+
printType(tree.tpe)
244237

245238
case Term.Select(qual, name, sig) =>
246239
printTree(qual)
@@ -907,6 +900,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
907900
case Type.TypeRef(_, Type.SymRef(PackageDef("internal", _), Type.ThisType(Type.SymRef(PackageDef("annotation", _), NoPrefix())))) => false
908901
case _ => true
909902
}
903+
case x => throw new MatchError(x.show)
910904
}
911905
printAnnotations(annots)
912906
if (annots.nonEmpty) this += " "
@@ -969,7 +963,9 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
969963

970964
private object Annotation {
971965
def unapply(arg: Tree)(implicit ctx: Context): Option[(TypeTree, List[Term])] = arg match {
966+
case Term.New(annot) => Some((annot, Nil))
972967
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))
973969
case _ => None
974970
}
975971
}

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)