Skip to content

Commit ac7c395

Browse files
committed
Remove useless extractors
1 parent 120c033 commit ac7c395

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
11151115
tp match {
11161116
case tp: TypeLambda =>
11171117
printType(tpe.dealias)
1118-
case TypeRef(Types.ScalaPackage(), "<repeated>") =>
1118+
case tp: TypeRef if tp.typeSymbol == ctx.requiredClass("scala.<repeated>") =>
11191119
this += "_*"
11201120
case _ =>
11211121
printType(tp)
@@ -1242,11 +1242,9 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
12421242
def printDefAnnotations(definition: Definition)(given elideThis: Option[Symbol]): Buffer = {
12431243
val annots = definition.symbol.annots.filter {
12441244
case Annotation(annot, _) =>
1245-
annot.tpe match {
1246-
case tpe @ TypeRef if tpe.typeSymbol.maybeOwner == ctx.requiredPackage("scala.annotation.internal") => false
1247-
case TypeRef(Types.ScalaPackage(), "forceInline") => false
1248-
case _ => true
1249-
}
1245+
val sym = annot.tpe.typeSymbol
1246+
sym != ctx.requiredClass("scala.forceInline") &&
1247+
sym.maybeOwner != ctx.requiredPackage("scala.annotation.internal")
12501248
case x => throw new MatchError(x.showExtractors)
12511249
}
12521250
printAnnotations(annots)
@@ -1443,18 +1441,11 @@ class SourceCodePrinter[R <: Reflection & Singleton](val tasty: R)(syntaxHighlig
14431441

14441442
object Repeated {
14451443
def unapply(tpe: Type)(given ctx: Context): Option[Type] = tpe match {
1446-
case AppliedType(TypeRef(ScalaPackage(), "<repeated>"), (tp: Type) :: Nil) => Some(tp)
1444+
case AppliedType(rep, (tp: Type) :: Nil) if rep.typeSymbol == ctx.requiredClass("scala.<repeated>") => Some(tp)
14471445
case _ => None
14481446
}
14491447
}
14501448

1451-
object ScalaPackage {
1452-
def unapply(tpe: TypeOrBounds)(given ctx: Context): Boolean = tpe match {
1453-
case tpe: Type => tpe.termSymbol == defn.ScalaPackage
1454-
case _ => false
1455-
}
1456-
}
1457-
14581449
}
14591450

14601451
object PackageObject {

0 commit comments

Comments
 (0)