-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Compiler option -Yretain-trees has a drastic impact on compiler plugins capabilities, and also on macros based on dotc.
Being able at least to check whether this is set would be useful, e.g.
def foo(using q: Quotes) = {
import q.reflect.{ report, CompilationInfo }
if (!CompilationInfo.retainTrees) {
report.errorAndAbort("Option -Yretain-trees must be set")
}
// ...
}Draft:
diff --git a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
index 3de7f0bfc6..716ef64fb4 100644
--- a/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
+++ b/compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala
@@ -78,6 +78,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
object CompilationInfo extends CompilationInfoModule:
def isWhileTyping: Boolean = !ctx.isAfterTyper
+ def retainTrees: Boolean = ctx.settings.YretainTrees.value
end CompilationInfo
extension (expr: Expr[Any])
diff --git a/library/src/scala/quoted/Quotes.scala b/library/src/scala/quoted/Quotes.scala
index a375709844..2f2439d2dd 100644
--- a/library/src/scala/quoted/Quotes.scala
+++ b/library/src/scala/quoted/Quotes.scala
@@ -238,6 +238,9 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
* This will be true when the macro is used in a transparent inline.
*/
def isWhileTyping: Boolean
+
+ /** Are trees retains for symbol? (see `-Yretain-trees`) */
+ def retainTrees: Boolean
}
Metadata
Metadata
Assignees
Labels
No labels