File tree Expand file tree Collapse file tree 5 files changed +23
-1
lines changed
compiler/src/dotty/tools/dotc/tastyreflect Expand file tree Collapse file tree 5 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -940,6 +940,13 @@ object TastyImpl extends scala.tasty.Tasty {
940940 }
941941 }
942942
943+ object ClassTag extends ClassTagExtractor {
944+ def unapply (x : Constant ): Option [Type ] = x match {
945+ case x : Constants .Constant if x.tag == Constants .ClazzTag => Some (x.typeValue)
946+ case _ => None
947+ }
948+ }
949+
943950 }
944951
945952 // ===== Signature ================================================
Original file line number Diff line number Diff line change @@ -731,6 +731,10 @@ abstract class Tasty { tasty =>
731731 def unapply (x : Constant ): Option [String ]
732732 }
733733
734+ val ClassTag : ClassTagExtractor
735+ abstract class ClassTagExtractor {
736+ def unapply (x : Constant ): Option [Type ]
737+ }
734738 }
735739
736740 // ===== Signature ================================================
Original file line number Diff line number Diff line change @@ -150,6 +150,7 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
150150 case Constant .Float (value) => this += " Constant.Float(" += value += " )"
151151 case Constant .Double (value) => this += " Constant.Double(" += value += " )"
152152 case Constant .String (value) => this += " Constant.String(\" " += value += " \" )"
153+ case Constant .ClassTag (value) => this += " Constant.ClassTag(" += value += " )"
153154 }
154155
155156 def visitType (x : TypeOrBounds ): Buffer = x match {
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
237237
238238 case Term .Select (qual, name, sig) =>
239239 printTree(qual)
240- if (name != " <init>" )
240+ if (name != " <init>" && name != " package " )
241241 this += " ." += name
242242 this
243243
@@ -664,6 +664,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
664664 case Constant .Double (v) => this += v
665665 case Constant .Char (v) => this += '\' ' += escapedChar(v) += '\' '
666666 case Constant .String (v) => this += '"' += escapedString(v) += '"'
667+ case Constant .ClassTag (v) =>
668+ this += " classOf["
669+ printType(v)
670+ this += " ]"
667671 }
668672
669673 def printTypeOrBoundsTree (tpt : TypeOrBoundsTree ): Buffer = tpt match {
Original file line number Diff line number Diff line change 1+ /** Decompiled from out/posTestFromTasty/pos/i566/Test.class */
2+ class Test() {
3+ type T = scala.Predef.String
4+ type U
5+ scala.reflect.classTag[Test.this.T](scala.reflect.ClassTag.apply[Test.this.T](classOf[java.lang.String]))
6+ }
You can’t perform that action at this time.
0 commit comments