Skip to content

Commit e7bf627

Browse files
committed
Use extensions for show* in Reflection
Workaround #8188 by renaming on of the `show` to `showWith`
1 parent c48a598 commit e7bf627

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

library/src/scala/quoted/QuoteContext.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ class QuoteContext(val tasty: scala.tasty.Reflection) {
1414

1515
def show(expr: Expr[_], syntaxHighlight: SyntaxHighlight): String = {
1616
import tasty.{_, given}
17-
expr.unseal.show(syntaxHighlight)
17+
expr.unseal.showWith(syntaxHighlight)
1818
}
1919

2020
def show(tpe: Type[_], syntaxHighlight: SyntaxHighlight): String = {
2121
import tasty.{_, given}
22-
tpe.unseal.show(syntaxHighlight)
22+
tpe.unseal.showWith(syntaxHighlight)
2323
}
2424

2525
/** Report an error at the position of the macro expansion */

library/src/scala/tasty/Reflection.scala

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2641,75 +2641,78 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
26412641
//////////////
26422642

26432643
/** Adds `show` as an extension method of a `Tree` */
2644-
implicit class TreeShowDeco(tree: Tree) {
2644+
extension TreeShowDeco on (tree: Tree) {
26452645
/** Shows the tree as extractors */
26462646
def showExtractors(given ctx: Context): String =
26472647
new ExtractorsPrinter[self.type](self).showTree(tree)
26482648

26492649
/** Shows the tree as fully typed source code */
26502650
def show(given ctx: Context): String =
2651-
show(SyntaxHighlight.plain)
2651+
tree.showWith(SyntaxHighlight.plain)
26522652

26532653
/** Shows the tree as fully typed source code */
2654-
def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
2654+
def showWith(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
26552655
new SourceCodePrinter[self.type](self)(syntaxHighlight).showTree(tree)
26562656

26572657
}
26582658

26592659
/** Adds `show` as an extension method of a `TypeOrBounds` */
2660-
implicit class TypeOrBoundsShowDeco(tpe: TypeOrBounds) {
2660+
extension TypeOrBoundsShowDeco on (tpe: TypeOrBounds) {
26612661
/** Shows the tree as extractors */
26622662
def showExtractors(given ctx: Context): String =
26632663
new ExtractorsPrinter[self.type](self).showTypeOrBounds(tpe)
26642664

26652665
/** Shows the tree as fully typed source code */
26662666
def show(given ctx: Context): String =
2667-
show(SyntaxHighlight.plain)
2667+
tpe.showWith(SyntaxHighlight.plain)
26682668

26692669
/** Shows the tree as fully typed source code */
2670-
def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
2670+
def showWith(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
26712671
new SourceCodePrinter[self.type](self)(syntaxHighlight).showTypeOrBounds(tpe)
26722672
}
26732673

26742674
/** Adds `show` as an extension method of a `Constant` */
2675-
implicit class ConstantShowDeco(const: Constant) {
2675+
extension ConstantShowDeco on (const: Constant) {
26762676
/** Shows the tree as extractors */
26772677
def showExtractors(given ctx: Context): String =
26782678
new ExtractorsPrinter[self.type](self).showConstant(const)
26792679

26802680
/** Shows the tree as fully typed source code */
2681-
def show(given ctx: Context): String = show(SyntaxHighlight.plain)
2681+
def show(given ctx: Context): String =
2682+
const.showWith(SyntaxHighlight.plain)
26822683

26832684
/** Shows the tree as fully typed source code */
2684-
def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
2685+
def showWith(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
26852686
new SourceCodePrinter[self.type](self)(syntaxHighlight).showConstant(const)
26862687
}
26872688

26882689
/** Adds `show` as an extension method of a `Symbol` */
2689-
implicit class SymbolShowDeco(symbol: Symbol) {
2690+
extension SymbolShowDeco on (symbol: Symbol) {
26902691
/** Shows the tree as extractors */
26912692
def showExtractors(given ctx: Context): String =
26922693
new ExtractorsPrinter[self.type](self).showSymbol(symbol)
26932694

26942695
/** Shows the tree as fully typed source code */
2695-
def show(given ctx: Context): String = show(SyntaxHighlight.plain)
2696+
def show(given ctx: Context): String =
2697+
symbol.showWith(SyntaxHighlight.plain)
26962698

26972699
/** Shows the tree as fully typed source code */
2698-
def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
2700+
def showWith(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
26992701
new SourceCodePrinter[self.type](self)(syntaxHighlight).showSymbol(symbol)
27002702
}
27012703

27022704
/** Adds `show` as an extension method of a `Flags` */
2703-
implicit class FlagsShowDeco(flags: Flags) {
2705+
extension FlagsShowDeco on (flags: Flags) {
27042706
/** Shows the tree as extractors */
27052707
def showExtractors(given ctx: Context): String =
27062708
new ExtractorsPrinter[self.type](self).showFlags(flags)
27072709

27082710
/** Shows the tree as fully typed source code */
2709-
def show(given ctx: Context): String = show(SyntaxHighlight.plain)
2711+
def show(given ctx: Context): String =
2712+
flags.showWith(SyntaxHighlight.plain)
27102713

27112714
/** Shows the tree as fully typed source code */
2712-
def show(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
2715+
def showWith(syntaxHighlight: SyntaxHighlight)(given ctx: Context): String =
27132716
new SourceCodePrinter[self.type](self)(syntaxHighlight).showFlags(flags)
27142717
}
27152718

0 commit comments

Comments
 (0)