@@ -71,7 +71,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
7171 }
7272
7373 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)
7575 case TypeTree .TypeSelect (Term .Select (Term .Ident (" _root_" ), " scala" , _), " Product" ) => false
7676 case _ => true
7777 }
@@ -612,8 +612,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
612612
613613 case Type .SymRef (sym, prefix) =>
614614 prefix match {
615- case EmptyPackage () =>
616- case RootPackage () =>
615+ case Type .ThisType (Types .EmptyPackage () | Types .RootPackage ()) =>
617616 case prefix@ Type .SymRef (ClassDef (_, _, _, _, _), _) =>
618617 printType(prefix)
619618 this += " #"
@@ -717,44 +716,44 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
717716 }
718717 }
719718
719+ // TODO Provide some of these in scala.tasty.Tasty.scala and implement them using checks on symbols for performance
720720 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+ }
724727 }
725-
728+
726729 object Repeated {
727730 def unapply (tpe : Type )(implicit ctx : Context ): Option [Type ] = tpe match {
728731 case Type .AppliedType (Type .TypeRef (" <repeated>" , ScalaPackage ()), (tp@ Type ()) :: Nil ) => Some (tp)
729732 case _ => None
730733 }
731734 }
732- }
733735
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+ }
738741 }
739- }
740742
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+ }
745748 }
746- }
747749
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+ }
757755 }
758756 }
759757
758+
760759}
0 commit comments