@@ -1941,8 +1941,23 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
1941
1941
// CONSTANTS //
1942
1942
// /////////////
1943
1943
1944
+ /** Members of `Constant` */
1944
1945
extension ConstantOps on (const : Constant ) {
1946
+
1947
+ /** Returns the value of the constant */
1945
1948
def value : Any = internal.Constant_value (const)
1949
+
1950
+ /** Shows the tree as extractors */
1951
+ def showExtractors (given ctx : Context ): String =
1952
+ new ExtractorsPrinter [self.type ](self).showConstant(const)
1953
+
1954
+ /** Shows the tree as fully typed source code */
1955
+ def show (given ctx : Context ): String =
1956
+ const.showWith(SyntaxHighlight .plain)
1957
+
1958
+ /** Shows the tree as fully typed source code */
1959
+ def showWith (syntaxHighlight : SyntaxHighlight )(given ctx : Context ): String =
1960
+ new SourceCodePrinter [self.type ](self)(syntaxHighlight).showConstant(const)
1946
1961
}
1947
1962
1948
1963
/** Module of Constant literals */
@@ -2671,21 +2686,6 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
2671
2686
new SourceCodePrinter [self.type ](self)(syntaxHighlight).showTypeOrBounds(tpe)
2672
2687
}
2673
2688
2674
- /** Adds `show` as an extension method of a `Constant` */
2675
- extension ConstantShowDeco on (const : Constant ) {
2676
- /** Shows the tree as extractors */
2677
- def showExtractors (given ctx : Context ): String =
2678
- new ExtractorsPrinter [self.type ](self).showConstant(const)
2679
-
2680
- /** Shows the tree as fully typed source code */
2681
- def show (given ctx : Context ): String =
2682
- const.showWith(SyntaxHighlight .plain)
2683
-
2684
- /** Shows the tree as fully typed source code */
2685
- def showWith (syntaxHighlight : SyntaxHighlight )(given ctx : Context ): String =
2686
- new SourceCodePrinter [self.type ](self)(syntaxHighlight).showConstant(const)
2687
- }
2688
-
2689
2689
/** Adds `show` as an extension method of a `Symbol` */
2690
2690
extension SymbolShowDeco on (symbol : Symbol ) {
2691
2691
/** Shows the tree as extractors */
0 commit comments