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 @@ -623,6 +623,13 @@ object TastyImpl extends scala.tasty.Tasty {
623
623
case _ => None
624
624
}
625
625
}
626
+
627
+ object Bind extends BindExtractor {
628
+ def unapply (x : TypeTree )(implicit ctx : Context ): Option [(String , TypeBoundsTree )] = x match {
629
+ case x : tpd.Bind @ unchecked if x.name.isInstanceOf [Names .TypeName ] => Some ((x.name.toString, x.body))
630
+ case _ => None
631
+ }
632
+ }
626
633
}
627
634
628
635
// ----- TypeBoundsTrees ------------------------------------------------
@@ -645,6 +652,7 @@ object TastyImpl extends scala.tasty.Tasty {
645
652
object SyntheticBounds extends SyntheticBoundsExtractor {
646
653
def unapply (x : TypeBoundsTree )(implicit ctx : Context ): Boolean = x match {
647
654
case x @ Trees .TypeTree () => x.tpe.isInstanceOf [Types .TypeBounds ]
655
+ case Trees .Ident (nme.WILDCARD ) => x.tpe.isInstanceOf [Types .TypeBounds ]
648
656
case _ => false
649
657
}
650
658
}
Original file line number Diff line number Diff line change @@ -482,6 +482,11 @@ abstract class Tasty { tasty =>
482
482
abstract class TypeLambdaTreeExtractor {
483
483
def unapply (x : TypeTree )(implicit ctx : Context ): Option [(List [TypeDef ], TypeOrBoundsTree )]
484
484
}
485
+
486
+ val Bind : BindExtractor
487
+ abstract class BindExtractor {
488
+ def unapply (x : TypeTree )(implicit ctx : Context ): Option [(String , TypeBoundsTree )]
489
+ }
485
490
}
486
491
487
492
// ----- TypeBoundsTrees ------------------------------------------------
Original file line number Diff line number Diff line change @@ -114,6 +114,8 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
114
114
this += " TypeTree.Annotated(" += arg += " , " += annot += " )"
115
115
case TypeTree .TypeLambdaTree (tparams, body) =>
116
116
this += " LambdaTypeTree(" ++= tparams += " , " += body += " )"
117
+ case TypeTree .Bind (name, bounds) =>
118
+ this += " Bind(" += name += " , " += bounds += " )"
117
119
case TypeBoundsTree (lo, hi) =>
118
120
this += " TypeBoundsTree(" += lo += " , " += hi += " )"
119
121
case SyntheticBounds () =>
Original file line number Diff line number Diff line change @@ -754,14 +754,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
754
754
this += " => "
755
755
printTypeOrBoundsTree(body)
756
756
757
+ case TypeTree .Bind (name, _) =>
758
+ this += name
759
+
757
760
case _ =>
758
761
throw new MatchError (tree.show)
759
762
760
763
}
761
764
762
765
def printTypeOrBound (tpe : TypeOrBounds ): Buffer = tpe match {
763
766
case tpe@ TypeBounds (lo, hi) =>
764
- this += " >: "
767
+ this += " _ >: "
765
768
printType(lo)
766
769
this += " <: "
767
770
printType(hi)
@@ -843,14 +846,21 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
843
846
844
847
case Type .TypeLambda (paramNames, tparams, body) =>
845
848
this += " ["
849
+ def printBounds (bounds : TypeBounds ): Buffer = {
850
+ val TypeBounds (lo, hi) = bounds
851
+ this += " >: "
852
+ printType(lo)
853
+ this += " <: "
854
+ printType(hi)
855
+ }
846
856
def printSeparated (list : List [(String , TypeBounds )]): Unit = list match {
847
857
case Nil =>
848
858
case (name, bounds) :: Nil =>
849
859
this += name
850
- printTypeOrBound (bounds)
860
+ printBounds (bounds)
851
861
case (name, bounds) :: xs =>
852
862
this += name
853
- printTypeOrBound (bounds)
863
+ printBounds (bounds)
854
864
this += " , "
855
865
printSeparated(xs)
856
866
}
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 @@ -102,6 +102,7 @@ object definitions {
102
102
case Or (left : TypeTree , right : TypeTree )
103
103
case ByName (tpt : TypeTree )
104
104
case TypeLambda (tparams : List [TypeDef ], body : Type | TypeBoundsTree )
105
+ case Bind (name : String , bounds : TypeBoundsTree )
105
106
}
106
107
107
108
/** Trees denoting type bounds */
You can’t perform that action at this time.
0 commit comments