File tree Expand file tree Collapse file tree 6 files changed +43
-3
lines changed
compiler/src/dotty/tools/dotc/tastyreflect Expand file tree Collapse file tree 6 files changed +43
-3
lines changed Original file line number Diff line number Diff line change @@ -616,6 +616,13 @@ object TastyImpl extends scala.tasty.Tasty {
616
616
case _ => None
617
617
}
618
618
}
619
+
620
+ object Bind extends BindExtractor {
621
+ def unapply (x : TypeTree )(implicit ctx : Context ): Option [(String , TypeBoundsTree )] = x match {
622
+ case x : tpd.Bind @ unchecked if x.name.isInstanceOf [Names .TypeName ] => Some ((x.name.toString, x.body))
623
+ case _ => None
624
+ }
625
+ }
619
626
}
620
627
621
628
// ----- TypeBoundsTrees ------------------------------------------------
@@ -638,6 +645,7 @@ object TastyImpl extends scala.tasty.Tasty {
638
645
object SyntheticBounds extends SyntheticBoundsExtractor {
639
646
def unapply (x : TypeBoundsTree )(implicit ctx : Context ): Boolean = x match {
640
647
case x @ Trees .TypeTree () => x.tpe.isInstanceOf [Types .TypeBounds ]
648
+ case Trees .Ident (nme.WILDCARD ) => x.tpe.isInstanceOf [Types .TypeBounds ]
641
649
case _ => false
642
650
}
643
651
}
Original file line number Diff line number Diff line change @@ -477,6 +477,11 @@ abstract class Tasty { tasty =>
477
477
abstract class TypeLambdaTreeExtractor {
478
478
def unapply (x : TypeTree )(implicit ctx : Context ): Option [(List [TypeDef ], TypeOrBoundsTree )]
479
479
}
480
+
481
+ val Bind : BindExtractor
482
+ abstract class BindExtractor {
483
+ def unapply (x : TypeTree )(implicit ctx : Context ): Option [(String , TypeBoundsTree )]
484
+ }
480
485
}
481
486
482
487
// ----- TypeBoundsTrees ------------------------------------------------
Original file line number Diff line number Diff line change @@ -112,6 +112,8 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
112
112
this += " TypeTree.Annotated(" += arg += " , " += annot += " )"
113
113
case TypeTree .TypeLambdaTree (tparams, body) =>
114
114
this += " LambdaTypeTree(" ++= tparams += " , " += body += " )"
115
+ case TypeTree .Bind (name, bounds) =>
116
+ this += " Bind(" += name += " , " += bounds += " )"
115
117
case TypeBoundsTree (lo, hi) =>
116
118
this += " TypeBoundsTree(" += lo += " , " += hi += " )"
117
119
case SyntheticBounds () =>
Original file line number Diff line number Diff line change @@ -755,14 +755,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
755
755
this += " => "
756
756
printTypeOrBoundsTree(body)
757
757
758
+ case TypeTree .Bind (name, _) =>
759
+ this += name
760
+
758
761
case _ =>
759
762
throw new MatchError (tree.show)
760
763
761
764
}
762
765
763
766
def printTypeOrBound (tpe : TypeOrBounds ): Buffer = tpe match {
764
767
case tpe@ TypeBounds (lo, hi) =>
765
- this += " >: "
768
+ this += " _ >: "
766
769
printType(lo)
767
770
this += " <: "
768
771
printType(hi)
@@ -844,14 +847,21 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
844
847
845
848
case Type .TypeLambda (paramNames, tparams, body) =>
846
849
this += " ["
850
+ def printBounds (bounds : TypeBounds ): Buffer = {
851
+ val TypeBounds (lo, hi) = bounds
852
+ this += " >: "
853
+ printType(lo)
854
+ this += " <: "
855
+ printType(hi)
856
+ }
847
857
def printSeparated (list : List [(String , TypeBounds )]): Unit = list match {
848
858
case Nil =>
849
859
case (name, bounds) :: Nil =>
850
860
this += name
851
- printTypeOrBound (bounds)
861
+ printBounds (bounds)
852
862
case (name, bounds) :: xs =>
853
863
this += name
854
- printTypeOrBound (bounds)
864
+ printBounds (bounds)
855
865
this += " , "
856
866
printSeparated(xs)
857
867
}
Original file line number Diff line number Diff line change
1
+ /** Decompiled from out/posTestFromTasty/pos/i0306/bar.class */
2
+ object bar {
3
+ class C[T <: scala.Seq[_ >: scala.Nothing <: scala.Any]]()
4
+ val x: scala.AnyRef = new bar.C[scala.collection.Seq[_ >: scala.Nothing <: scala.Any]]()
5
+ val y: scala.collection.Seq[_ >: scala.Nothing <: scala.Any] = bar.x match {
6
+ case x: bar.C[u] =>
7
+ def xx: u = xx
8
+ ((xx: u): scala.collection.Seq[_ >: scala.Nothing <: scala.Any])
9
+ }
10
+ val z: java.lang.String = {
11
+ def xx: scala.Predef.String = xx
12
+ (xx: java.lang.String)
13
+ }
14
+ }
Original file line number Diff line number Diff line change @@ -101,6 +101,7 @@ object definitions {
101
101
case Or (left : TypeTree , right : TypeTree )
102
102
case ByName (tpt : TypeTree )
103
103
case TypeLambda (tparams : List [TypeDef ], body : Type | TypeBoundsTree )
104
+ case Bind (name : String , bounds : TypeBoundsTree )
104
105
}
105
106
106
107
/** Trees denoting type bounds */
You can’t perform that action at this time.
0 commit comments