Skip to content

Commit 77c060c

Browse files
committed
Fix rebase
1 parent 8ddb8c8 commit 77c060c

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

library/src-bootstrapped/scala/quoted/Type.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import scala.runtime.quoted.Unpickler.Pickled
66

77
sealed abstract class Type[T <: AnyKind] {
88
type `$splice` = T
9+
10+
/** Show a source code like representation of this type */
11+
final def show(implicit toolbox: Toolbox): String = toolbox.show(this.asInstanceOf[Type[Any]])
912
}
1013

1114
/** Some basic type tags, currently incomplete */

library/src/scala/tasty/reflect/Printers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ trait Printers
14841484

14851485
case Type.SymRef(sym, prefix) if sym.isTerm =>
14861486
prefix match {
1487-
case NoPrefix() =>
1487+
case NoPrefix() | Type.ThisType(Types.EmptyPackage() | Types.RootPackage()) =>
14881488
this += highlightTypeDef(sym.name, color)
14891489
case _ =>
14901490
printTypeOrBound(prefix)

tests/run/type-show/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted._
22
import scala.tasty._
33

44
object TypeToolbox {
5-
inline def show[A]: String = ~showImpl('[A])
5+
inline def show[A]: String = ${ showImpl('[A]) }
66
private def showImpl[A, B](a: Type[A])(implicit refl: Reflection): Expr[String] = {
77
import refl._
88
import scala.quoted.Toolbox.Default._

tests/run/type-show/Test_2.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ object Test {
33
import TypeToolbox._
44
def main(args: Array[String]): Unit = {
55
val x = 5
6-
println(show[Nil.type])
7-
println(show[Int => Int])
8-
println(show[(Int, String)])
9-
println(show[x.type])
106
assert(show[x.type] == "x.type")
117
assert(show[Nil.type] == "scala.Nil.type")
128
assert(show[Int] == "scala.Int")

0 commit comments

Comments
 (0)