Skip to content

Add .info methods to quotes API #11626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,15 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
def warning(msg: String, pos: Position): Unit =
dotc.report.warning(msg, pos)

def info(msg: String): Unit =
dotc.report.echo(msg, Position.ofMacroExpansion)

def info(msg: String, expr: Expr[Any]): Unit =
dotc.report.echo(msg, asTerm(expr).pos)

def info(msg: String, pos: Position): Unit =
dotc.report.echo(msg, pos)

end report

private def optional[T <: dotc.ast.Trees.Tree[?]](tree: T): Option[tree.type] =
Expand Down
17 changes: 13 additions & 4 deletions library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4098,24 +4098,33 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
/** Report an error message at the given position */
def error(msg: String, pos: Position): Unit

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

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

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

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

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

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

/** Report an info at the position of the macro expansion */
def info(msg: String): Unit

/** Report an info message at the position of `expr` */
def info(msg: String, expr: Expr[Any]): Unit

/** Report an info message at the given position */
def info(msg: String, pos: Position): Unit

}


Expand Down