Skip to content

Commit 8b83989

Browse files
committed
Make show a proper method of Expr and type
Now that there is a single show implementation we do not need to have it as an extension method
1 parent 11acdd9 commit 8b83989

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

library/src/scala/quoted/Expr.scala

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,18 @@ package quoted {
1313
@deprecated("Use scala.quoted.run", "")
1414
final def run(implicit toolbox: Toolbox): T = toolbox.run(_ => this)
1515

16+
/** Show a source code like representation of this expression without syntax highlight */
17+
def show(implicit qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain)
18+
19+
/** Show a source code like representation of this expression */
20+
def show(syntaxHighlight: SyntaxHighlight)(implicit qctx: QuoteContext): String = qctx.show(this, syntaxHighlight)
21+
1622
}
1723

1824
object Expr {
1925

2026
import scala.internal.quoted._
2127

22-
implicit class ExprOps[T](expr: Expr[T]) {
23-
24-
/** Show a source code like representation of this expression without syntax highlight */
25-
def show(implicit qctx: QuoteContext): String = qctx.show(expr, SyntaxHighlight.plain)
26-
27-
/** Show a source code like representation of this expression */
28-
def show(syntaxHighlight: SyntaxHighlight)(implicit qctx: QuoteContext): String = qctx.show(expr, syntaxHighlight)
29-
30-
}
31-
3228
/** Converts a tuple `(T1, ..., Tn)` to `(Expr[T1], ..., Expr[Tn])` */
3329
type TupleOfExpr[Tup <: Tuple] = Tuple.Map[Tup, Expr]
3430

library/src/scala/quoted/QuoteContext.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ import scala.quoted.show.SyntaxHighlight
1212
*/
1313
class QuoteContext(val tasty: scala.tasty.Reflection) {
1414

15-
def show[T](expr: Expr[T], syntaxHighlight: SyntaxHighlight): String = {
15+
def show(expr: Expr[_], syntaxHighlight: SyntaxHighlight): String = {
1616
import tasty._
1717
expr.unseal.show(syntaxHighlight)
1818
}
1919

20-
def show[T](tpe: Type[T], syntaxHighlight: SyntaxHighlight): String = {
20+
def show(tpe: Type[_], syntaxHighlight: SyntaxHighlight): String = {
2121
import tasty._
2222
tpe.unseal.show(syntaxHighlight)
2323
}

library/src/scala/quoted/Type.scala

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,17 @@ package quoted {
66

77
sealed abstract class Type[T <: AnyKind] {
88
type `$splice` = T
9-
}
10-
11-
/** Some basic type tags, currently incomplete */
12-
object Type {
13-
14-
implicit class TypeOps[T](tpe: Type[T]) {
159

16-
/** Show a source code like representation of this type without syntax highlight */
17-
def show(implicit qctx: QuoteContext): String = qctx.show(tpe, SyntaxHighlight.plain)
10+
/** Show a source code like representation of this type without syntax highlight */
11+
def show(implicit qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain)
1812

19-
/** Show a source code like representation of this type */
20-
def show(syntaxHighlight: SyntaxHighlight)(implicit qctx: QuoteContext): String = qctx.show(tpe, syntaxHighlight)
13+
/** Show a source code like representation of this type */
14+
def show(syntaxHighlight: SyntaxHighlight)(implicit qctx: QuoteContext): String = qctx.show(this, syntaxHighlight)
2115

22-
}
16+
}
2317

18+
/** Some basic type tags, currently incomplete */
19+
object Type {
2420
implicit val UnitTag: Type[Unit] = new TaggedType[Unit]
2521
implicit val BooleanTag: Type[Boolean] = new TaggedType[Boolean]
2622
implicit val ByteTag: Type[Byte] = new TaggedType[Byte]

0 commit comments

Comments
 (0)