Skip to content

Commit 8984cf8

Browse files
committed
Add .info methods to quotes API
1 parent 0e9b84c commit 8984cf8

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,15 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
27692769
def warning(msg: String, pos: Position): Unit =
27702770
dotc.report.warning(msg, pos)
27712771

2772+
def info(msg: String): Unit =
2773+
dotc.report.echo(msg, Position.ofMacroExpansion)
2774+
2775+
def info(msg: String, expr: Expr[Any]): Unit =
2776+
dotc.report.echo(msg, asTerm(expr).pos)
2777+
2778+
def info(msg: String, pos: Position): Unit =
2779+
dotc.report.echo(msg, pos)
2780+
27722781
end report
27732782

27742783
private def optional[T <: dotc.ast.Trees.Tree[?]](tree: T): Option[tree.type] =

library/src/scala/quoted/Quotes.scala

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4098,24 +4098,33 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
40984098
/** Report an error message at the given position */
40994099
def error(msg: String, pos: Position): Unit
41004100

4101-
/** Report an error at the position of the macro expansion and throws a StopMacroExpansion */
4101+
/** Report an error at the position of the macro expansion and throw a StopMacroExpansion */
41024102
def throwError(msg: String): Nothing
41034103

41044104
/** Report an error at the position of `expr` */
41054105
def throwError(msg: String, expr: Expr[Any]): Nothing
41064106

4107-
/** Report an error message at the given position and throws a StopMacroExpansion */
4107+
/** Report an error message at the given position and throw a StopMacroExpansion */
41084108
def throwError(msg: String, pos: Position): Nothing
41094109

41104110
/** Report a warning at the position of the macro expansion */
41114111
def warning(msg: String): Unit
41124112

4113-
/** Report a warning at the on the position of `expr` */
4113+
/** Report a warning at the position of `expr` */
41144114
def warning(msg: String, expr: Expr[Any]): Unit
41154115

4116-
/** Report an warning message at the given position */
4116+
/** Report a warning message at the given position */
41174117
def warning(msg: String, pos: Position): Unit
41184118

4119+
/** Report an info at the position of the macro expansion */
4120+
def info(msg: String): Unit
4121+
4122+
/** Report an info message at the position of `expr` */
4123+
def info(msg: String, expr: Expr[Any]): Unit
4124+
4125+
/** Report an info message at the given position */
4126+
def info(msg: String, pos: Position): Unit
4127+
41194128
}
41204129

41214130

0 commit comments

Comments
 (0)