Skip to content

Commit b003867

Browse files
committed
Simplify show for Constant
1 parent 4c2432a commit b003867

File tree

2 files changed

+2
-26
lines changed

2 files changed

+2
-26
lines changed

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
21562156
given ConstantMethods: ConstantMethods with
21572157
extension (self: Constant):
21582158
def value: Any = self.value
2159-
def show(using printer: Printer[Constant]): String = printer.show(self)
2159+
def show: String = Extractors.showConstant(using QuotesImpl.this)(self)
21602160
end extension
21612161
end ConstantMethods
21622162

@@ -2694,18 +2694,6 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
26942694
def show(tpe: TypeRepr): String =
26952695
Extractors.showType(using QuotesImpl.this)(tpe)
26962696

2697-
lazy val ConstantCode: Printer[Constant] = new Printer[Constant]:
2698-
def show(const: Constant): String =
2699-
SourceCode.showConstant(using QuotesImpl.this)(const)(SyntaxHighlight.plain, fullNames = true)
2700-
2701-
lazy val ConstantAnsiCode: Printer[Constant] = new Printer[Constant]:
2702-
def show(const: Constant): String =
2703-
SourceCode.showConstant(using QuotesImpl.this)(const)(SyntaxHighlight.ANSI, fullNames = true)
2704-
2705-
lazy val ConstantCase: Printer[Constant] = new Printer[Constant]:
2706-
def show(const: Constant): String =
2707-
Extractors.showConstant(using QuotesImpl.this)(const)
2708-
27092697
end Printer
27102698
end reflect
27112699

library/src/scala/quoted/Quotes.scala

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2849,7 +2849,7 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
28492849
def value: Any
28502850

28512851
/** Shows the constant as a String */
2852-
def show(using Printer[Constant]): String
2852+
def show: String
28532853

28542854
end extension
28552855
}
@@ -4025,9 +4025,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
40254025
/** Default pinter for `TypeRepr` used when calling `tpe.show` */
40264026
given TypeReprPrinter: Printer[TypeRepr] = Printer.TypeReprCode
40274027

4028-
/** Default pinter for `Flags` used when calling `flags.show` */
4029-
given ConstantPrinter: Printer[Constant] = Printer.ConstantCase
4030-
40314028
/** Module object of `type Printer`.
40324029
* Contains custom printers such as `TreeCode`, `TreeAnsiCode`, `TreeCases`, `TypeReprCode`, ..., `SymbolFullName` and `FlagsCombination`.
40334030
*/
@@ -4067,15 +4064,6 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
40674064
*/
40684065
def TypeReprStructure: Printer[TypeRepr]
40694066

4070-
/** Prints the Constant as source code. */
4071-
def ConstantCode: Printer[Constant]
4072-
4073-
/** Prints the Constant as source code using ANSI colors. */
4074-
def ConstantAnsiCode: Printer[Constant]
4075-
4076-
/** Prints a pattern like representation of the `Constant`. */
4077-
def ConstantCase: Printer[Constant]
4078-
40794067
}
40804068

40814069
}

0 commit comments

Comments
 (0)