@@ -71,7 +71,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
71
71
}
72
72
73
73
val parents1 = parents.filter {
74
- case Term .Apply (Term .Select (Term .New (tpt), _, _), _) if Types .isJavaLangObject (tpt.tpe) => false
74
+ case Term .Apply (Term .Select (Term .New (tpt), _, _), _) => ! Types .JavaLangObject .unapply (tpt.tpe)
75
75
case TypeTree .TypeSelect (Term .Select (Term .Ident (" _root_" ), " scala" , _), " Product" ) => false
76
76
case _ => true
77
77
}
@@ -612,8 +612,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
612
612
613
613
case Type .SymRef (sym, prefix) =>
614
614
prefix match {
615
- case EmptyPackage () =>
616
- case RootPackage () =>
615
+ case Type .ThisType (Types .EmptyPackage () | Types .RootPackage ()) =>
617
616
case prefix@ Type .SymRef (ClassDef (_, _, _, _, _), _) =>
618
617
printType(prefix)
619
618
this += " #"
@@ -717,44 +716,44 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
717
716
}
718
717
}
719
718
719
+ // TODO Provide some of these in scala.tasty.Tasty.scala and implement them using checks on symbols for performance
720
720
private object Types {
721
- def isJavaLangObject (tpe : Type )(implicit ctx : Context ): Boolean = tpe match {
722
- case Type .TypeRef (" Object" , Type .SymRef (PackageDef (" lang" , _), Type .ThisType (Type .SymRef (PackageDef (" java" , _), NoPrefix ())))) => true
723
- case _ => false
721
+
722
+ object JavaLangObject {
723
+ def unapply (tpe : Type )(implicit ctx : Context ): Boolean = tpe match {
724
+ case Type .TypeRef (" Object" , Type .SymRef (PackageDef (" lang" , _), Type .ThisType (Type .SymRef (PackageDef (" java" , _), NoPrefix ())))) => true
725
+ case _ => false
726
+ }
724
727
}
725
-
728
+
726
729
object Repeated {
727
730
def unapply (tpe : Type )(implicit ctx : Context ): Option [Type ] = tpe match {
728
731
case Type .AppliedType (Type .TypeRef (" <repeated>" , ScalaPackage ()), (tp@ Type ()) :: Nil ) => Some (tp)
729
732
case _ => None
730
733
}
731
734
}
732
- }
733
735
734
- private object ScalaPackage {
735
- def unapply (tpe : TypeOrBounds )(implicit ctx : Context ): Boolean = tpe match {
736
- case Type .SymRef (PackageDef (" scala" , _), RootPackage ()) => true
737
- case _ => false
736
+ object ScalaPackage {
737
+ def unapply (tpe : TypeOrBounds )(implicit ctx : Context ): Boolean = tpe match {
738
+ case Type .SymRef (PackageDef (" scala" , _), Type .ThisType (RootPackage ())) => true
739
+ case _ => false
740
+ }
738
741
}
739
- }
740
742
741
- private object RootPackage {
742
- def unapply (tpe : TypeOrBounds )(implicit ctx : Context ): Boolean = tpe match {
743
- case Type .ThisType (Type .SymRef (PackageDef (" <root>" , _), NoPrefix ())) => true
744
- case _ => false
743
+ object RootPackage {
744
+ def unapply (tpe : TypeOrBounds )(implicit ctx : Context ): Boolean = tpe match {
745
+ case Type .SymRef (PackageDef (" <root>" , _), NoPrefix ()) => true
746
+ case _ => false
747
+ }
745
748
}
746
- }
747
749
748
- private object EmptyPackage {
749
- def unapply (tpe : TypeOrBounds )(implicit ctx : Context ): Boolean = tpe match {
750
- case Type .ThisType (Type .SymRef (PackageDef (" <empty>" , _), prefix)) =>
751
- prefix match {
752
- case NoPrefix () => true
753
- case RootPackage () => true
754
- case _ => false
755
- }
756
- case _ => false
750
+ object EmptyPackage {
751
+ def unapply (tpe : TypeOrBounds )(implicit ctx : Context ): Boolean = tpe match {
752
+ case Type .SymRef (PackageDef (" <empty>" , _), NoPrefix () | Type .ThisType (RootPackage ())) => true
753
+ case _ => false
754
+ }
757
755
}
758
756
}
759
757
758
+
760
759
}
0 commit comments