File tree 3 files changed +17
-0
lines changed
compiler/src/dotty/tools/dotc/staging
3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,10 @@ class CrossStageSafety extends TreeMapWithStages {
228
228
" \n\n " +
229
229
" Hint: Staged references to inline definition in quotes are only inlined after the quote is spliced into level 0 code by a macro. " +
230
230
" Try moving this inline definition in a statically accessible location such as an object (this definition can be private)."
231
+ else if level > 0 && sym.info.derivesFrom(defn.QuotesClass ) then
232
+ s """ \n
233
+ |Hint: Nested quote needs a local context defined at level $level.
234
+ |One way to introduce this context is to give the outer quote the type `Expr[Quotes ?=> Expr[T]]`. """ .stripMargin
231
235
else " "
232
236
report.error(
233
237
em """ access to $symStr from wrong staging level:
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg-macros/i17338.scala:4:5 ----------------------------------------------------------------------------
2
+ 4 | '{ '{ 1 } } // error
3
+ | ^
4
+ | access to parameter quotes from wrong staging level:
5
+ | - the definition is at level 0,
6
+ | - but the access is at level 1.
7
+ |
8
+ | Hint: Nested quote needs a local context defined at level 1.
9
+ | One way to introduce this context is to give the outer quote the type `Expr[Quotes ?=> Expr[T]]`.
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ def test (using quotes : Quotes ): Expr [Expr [Int ]] =
4
+ ' { ' { 1 } } // error
You can’t perform that action at this time.
0 commit comments