File tree Expand file tree Collapse file tree 6 files changed +44
-4
lines changed
compiler/src/dotty/tools/dotc/tastyreflect Expand file tree Collapse file tree 6 files changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -485,7 +485,7 @@ object TastyImpl extends scala.tasty.Tasty {
485
485
486
486
object Bind extends BindExtractor {
487
487
def unapply (x : Pattern )(implicit ctx : Context ): Option [(String , Pattern )] = x match {
488
- case x : tpd.Bind @ unchecked if x.name.isInstanceOf [ Names . TermName ] => Some (x.name.toString, x.body)
488
+ case x : tpd.Bind @ unchecked if x.name.isTermName => Some (x.name.toString, x.body)
489
489
case _ => None
490
490
}
491
491
}
@@ -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.isTypeName => 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 @@ -758,14 +758,17 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
758
758
this += " => "
759
759
printTypeOrBoundsTree(body)
760
760
761
+ case TypeTree .Bind (name, _) =>
762
+ this += name
763
+
761
764
case _ =>
762
765
throw new MatchError (tree.show)
763
766
764
767
}
765
768
766
769
def printTypeOrBound (tpe : TypeOrBounds ): Buffer = tpe match {
767
770
case tpe@ TypeBounds (lo, hi) =>
768
- this += " >: "
771
+ this += " _ >: "
769
772
printType(lo)
770
773
this += " <: "
771
774
printType(hi)
@@ -847,14 +850,21 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
847
850
848
851
case Type .TypeLambda (paramNames, tparams, body) =>
849
852
this += " ["
853
+ def printBounds (bounds : TypeBounds ): Buffer = {
854
+ val TypeBounds (lo, hi) = bounds
855
+ this += " >: "
856
+ printType(lo)
857
+ this += " <: "
858
+ printType(hi)
859
+ }
850
860
def printSeparated (list : List [(String , TypeBounds )]): Unit = list match {
851
861
case Nil =>
852
862
case (name, bounds) :: Nil =>
853
863
this += name
854
- printTypeOrBound (bounds)
864
+ printBounds (bounds)
855
865
case (name, bounds) :: xs =>
856
866
this += name
857
- printTypeOrBound (bounds)
867
+ printBounds (bounds)
858
868
this += " , "
859
869
printSeparated(xs)
860
870
}
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