Skip to content

Commit 758782a

Browse files
authored
Merge pull request #11626 from kubukoz/info-logs-macros
Add .info methods to quotes API
2 parents 0b70fff + 8984cf8 commit 758782a

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
@@ -4110,24 +4110,33 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
41104110
/** Report an error message at the given position */
41114111
def error(msg: String, pos: Position): Unit
41124112

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

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

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

41224122
/** Report a warning at the position of the macro expansion */
41234123
def warning(msg: String): Unit
41244124

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

4128-
/** Report an warning message at the given position */
4128+
/** Report a warning message at the given position */
41294129
def warning(msg: String, pos: Position): Unit
41304130

4131+
/** Report an info at the position of the macro expansion */
4132+
def info(msg: String): Unit
4133+
4134+
/** Report an info message at the position of `expr` */
4135+
def info(msg: String, expr: Expr[Any]): Unit
4136+
4137+
/** Report an info message at the given position */
4138+
def info(msg: String, pos: Position): Unit
4139+
41314140
}
41324141

41334142

0 commit comments

Comments
 (0)