File tree Expand file tree Collapse file tree 6 files changed +16
-15
lines changed
src/dotty/tools/dotc/tastyreflect Expand file tree Collapse file tree 6 files changed +16
-15
lines changed Original file line number Diff line number Diff line change @@ -1072,6 +1072,12 @@ class TastyImpl(val rootContext: Contexts.Context) extends scala.tasty.Tasty { s
10721072 }
10731073 }
10741074
1075+ object Symbol extends SymbolExtractor {
1076+ def unapply (x : Constant ): Option [scala.Symbol ] = x match {
1077+ case x : Constants .Constant if x.tag == Constants .ScalaSymbolTag => Some (x.scalaSymbolValue)
1078+ case _ => None
1079+ }
1080+ }
10751081 }
10761082
10771083 // ===== Signature ================================================
Original file line number Diff line number Diff line change 1- # Constant(Symbol)
2- desugar.scala
3- sip23-symbols.scala
4- t389.scala
5- t4812.scala
6- t4579.scala
7-
81# assertion failed: asTerm called on not-a-Term val <none>
92cls.scala
103escapes2.scala
Original file line number Diff line number Diff line change @@ -32,14 +32,6 @@ t3651.scala
3232protectedacc.scala
3333t7436.scala
3434
35- # Constant(Symbol)
36- fors.scala
37- t6634.scala
38- t6632.scala
39- t4601.scala
40- t6633.scala
41- arrays.scala
42-
4335# scala.MatchError: SeqLiteral in pattern
4436i3248.scala
4537t6541.scala
Original file line number Diff line number Diff line change @@ -825,6 +825,13 @@ abstract class Tasty { tasty =>
825825 abstract class ClassTagExtractor {
826826 def unapply (x : Constant ): Option [Type ]
827827 }
828+
829+ /** Extractor for scala.Symbol literals */
830+ val Symbol : SymbolExtractor
831+ /** Extractor for scala.Symbol literals */
832+ abstract class SymbolExtractor {
833+ def unapply (x : Constant ): Option [scala.Symbol ]
834+ }
828835 }
829836
830837 // ===== Signature ================================================
Original file line number Diff line number Diff line change @@ -153,6 +153,7 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
153153 case Constant .Double (value) => this += " Constant.Double(" += value += " )"
154154 case Constant .String (value) => this += " Constant.String(\" " += value += " \" )"
155155 case Constant .ClassTag (value) => this += " Constant.ClassTag(" += value += " )"
156+ case Constant .Symbol (value) => this += " Constant.Symbol('" += value.name += " )"
156157 }
157158
158159 def visitType (x : TypeOrBounds ): Buffer = x match {
Original file line number Diff line number Diff line change @@ -722,6 +722,8 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
722722 case Constant .ClassTag (v) =>
723723 this += " classOf"
724724 inSquare(printType(v))
725+ case Constant .Symbol (v) =>
726+ this += " '" += v.name
725727 }
726728
727729 def printTypeOrBoundsTree (tpt : TypeOrBoundsTree ): Buffer = tpt match {
You can’t perform that action at this time.
0 commit comments