From 300332f2ae2abfc290b8c95826ee8b2d70ca946d Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Wed, 11 Mar 2020 07:22:13 +0100 Subject: [PATCH] Remove unnecessary indirection --- library/src/scala/quoted/Expr.scala | 6 ++++-- library/src/scala/quoted/QuoteContext.scala | 12 ------------ library/src/scala/quoted/Type.scala | 6 ++++-- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/library/src/scala/quoted/Expr.scala b/library/src/scala/quoted/Expr.scala index c4138e9575c6..63e932d9de55 100644 --- a/library/src/scala/quoted/Expr.scala +++ b/library/src/scala/quoted/Expr.scala @@ -6,10 +6,12 @@ import scala.quoted.show.SyntaxHighlight class Expr[+T] private[scala] { /** Show a source code like representation of this expression without syntax highlight */ - def show(using qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain) + def show(using qctx: QuoteContext): String = + this.unseal.showWith(SyntaxHighlight.plain) /** Show a source code like representation of this expression */ - def show(syntaxHighlight: SyntaxHighlight)(using qctx: QuoteContext): String = qctx.show(this, syntaxHighlight) + def show(syntaxHighlight: SyntaxHighlight)(using qctx: QuoteContext): String = + this.unseal.showWith(syntaxHighlight) /** Return the value of this expression. * diff --git a/library/src/scala/quoted/QuoteContext.scala b/library/src/scala/quoted/QuoteContext.scala index 8cca608ec2ec..5545c7e2c783 100644 --- a/library/src/scala/quoted/QuoteContext.scala +++ b/library/src/scala/quoted/QuoteContext.scala @@ -29,18 +29,6 @@ class QuoteContext(val tasty: scala.tasty.Reflection) { self => val tasty: self.tasty.type } - /** Show the fully elaborated source code representation of an expression */ - def show(expr: Expr[_], syntaxHighlight: SyntaxHighlight): String = { - import tasty.{_, given _} - expr.unseal(using this).showWith(syntaxHighlight) - } - - /** Show the fully elaborated source code representation of a type */ - def show(tpe: Type[_], syntaxHighlight: SyntaxHighlight): String = { - import tasty.{_, given _} - tpe.unseal(using this).showWith(syntaxHighlight) - } - /** Report an error at the position of the macro expansion */ def error(msg: => String): Unit = { import tasty.{_, given _} diff --git a/library/src/scala/quoted/Type.scala b/library/src/scala/quoted/Type.scala index c2074f0a9f14..6b9a06748702 100644 --- a/library/src/scala/quoted/Type.scala +++ b/library/src/scala/quoted/Type.scala @@ -7,10 +7,12 @@ class Type[T <: AnyKind] private[scala] { type `$splice` = T /** Show a source code like representation of this type without syntax highlight */ - def show(using qctx: QuoteContext): String = qctx.show(this, SyntaxHighlight.plain) + def show(using qctx: QuoteContext): String = + this.unseal.showWith(SyntaxHighlight.plain) /** Show a source code like representation of this type */ - def show(syntaxHighlight: SyntaxHighlight)(using qctx: QuoteContext): String = qctx.show(this, syntaxHighlight) + def show(syntaxHighlight: SyntaxHighlight)(using qctx: QuoteContext): String = + this.unseal.showWith(syntaxHighlight) /** View this expression `quoted.Type[T]` as a `TypeTree` */ def unseal(using qctx: QuoteContext): qctx.tasty.TypeTree =