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 {
940
940
}
941
941
}
942
942
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
+
943
950
}
944
951
945
952
// ===== Signature ================================================
Original file line number Diff line number Diff line change @@ -731,6 +731,10 @@ abstract class Tasty { tasty =>
731
731
def unapply (x : Constant ): Option [String ]
732
732
}
733
733
734
+ val ClassTag : ClassTagExtractor
735
+ abstract class ClassTagExtractor {
736
+ def unapply (x : Constant ): Option [Type ]
737
+ }
734
738
}
735
739
736
740
// ===== 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
150
150
case Constant .Float (value) => this += " Constant.Float(" += value += " )"
151
151
case Constant .Double (value) => this += " Constant.Double(" += value += " )"
152
152
case Constant .String (value) => this += " Constant.String(\" " += value += " \" )"
153
+ case Constant .ClassTag (value) => this += " Constant.ClassTag(" += value += " )"
153
154
}
154
155
155
156
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
237
237
238
238
case Term .Select (qual, name, sig) =>
239
239
printTree(qual)
240
- if (name != " <init>" )
240
+ if (name != " <init>" && name != " package " )
241
241
this += " ." += name
242
242
this
243
243
@@ -664,6 +664,10 @@ class ShowSourceCode[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
664
664
case Constant .Double (v) => this += v
665
665
case Constant .Char (v) => this += '\' ' += escapedChar(v) += '\' '
666
666
case Constant .String (v) => this += '"' += escapedString(v) += '"'
667
+ case Constant .ClassTag (v) =>
668
+ this += " classOf["
669
+ printType(v)
670
+ this += " ]"
667
671
}
668
672
669
673
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