Skip to content

Commit fea0dd6

Browse files
committed
Refactor some conditions
1 parent 953479a commit fea0dd6

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

library/src/scala/tasty/reflect/SourceCodePrinter.scala

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,8 +1243,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
12431243
val annots = definition.symbol.annots.filter {
12441244
case Annotation(annot, _) =>
12451245
annot.tpe match {
1246-
case TypeRef(prefix: TermRef, _) if prefix.termSymbol == ctx.requiredPackage("scala.annotation.internal") => false
1247-
case TypeRef(prefix: TypeRef, _) if prefix.typeSymbol == ctx.requiredPackage("scala.annotation.internal") => false
1246+
case tpe @ TypeRef if tpe.typeSymbol.maybeOwner == ctx.requiredPackage("scala.annotation.internal") => false
12481247
case TypeRef(Types.ScalaPackage(), "forceInline") => false
12491248
case _ => true
12501249
}
@@ -1444,16 +1443,14 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14441443

14451444
object Sequence {
14461445
def unapply(tpe: Type)(given ctx: Context): Option[Type] = tpe match {
1447-
case AppliedType(TypeRef(prefix: TermRef, "Seq"), (tp: Type) :: Nil) if prefix.termSymbol == ctx.requiredPackage("scala.collection") => Some(tp)
1448-
case AppliedType(TypeRef(prefix: TypeRef, "Seq"), (tp: Type) :: Nil) if prefix.typeSymbol == ctx.requiredPackage("scala.collection") => Some(tp)
1446+
case AppliedType(seq, (tp: Type) :: Nil) if seq.typeSymbol == ctx.requiredClass("scala.collection.Seq") => Some(tp)
14491447
case _ => None
14501448
}
14511449
}
14521450

14531451
object RepeatedAnnotation {
14541452
def unapply(tpe: Type)(given ctx: Context): Boolean = tpe match {
1455-
case TypeRef(prefix: TermRef, "Repeated") => prefix.termSymbol == ctx.requiredPackage("scala.annotation.internal")
1456-
case TypeRef(prefix: TypeRef, "Repeated") => prefix.typeSymbol == ctx.requiredPackage("scala.annotation.internal")
1453+
case tpe: TypeRef => tpe.typeSymbol == ctx.requiredClass("scala.annotation.internal.Repeated")
14571454
case _ => false
14581455
}
14591456
}

0 commit comments

Comments
 (0)