Skip to content

Commit 5d5a3dd

Browse files
Merge pull request #8941 from dotty-staging/make-quotecontext-a-trait
Make QuoteContext a trait
2 parents 3b8a756 + d808fe4 commit 5d5a3dd

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import dotty.tools.dotc.tastyreflect.ReflectionImpl
66
object QuoteContext {
77

88
def apply()(using Context): scala.quoted.QuoteContext =
9-
new scala.quoted.QuoteContext(ReflectionImpl(summon[Context]))
9+
new QuoteContext(ReflectionImpl(summon[Context]))
1010

1111
type ScopeId = Int
1212

@@ -19,3 +19,5 @@ object QuoteContext {
1919
private[dotty] def scopeId(using Context): ScopeId =
2020
summon[Context].outersIterator.toList.last.hashCode()
2121
}
22+
23+
class QuoteContext(val tasty: scala.tasty.Reflection) extends scala.quoted.QuoteContext

library/src/scala/quoted/QuoteContext.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import scala.quoted.show.SyntaxHighlight
1010
*
1111
* @param tasty Typed AST API. Usage: `def f(qctx: QuoteContext) = { import qctx.tasty._; ... }`.
1212
*/
13-
class QuoteContext(val tasty: scala.tasty.Reflection) { self =>
13+
trait QuoteContext { self =>
14+
15+
/** Low-level Typed AST API `tasty` meta-programming API.
16+
* This API does not have the static type guarantiees that `Expr` and `Type` provide.
17+
*/
18+
val tasty: scala.tasty.Reflection
1419

1520
/** Type of a QuoteContext provided by a splice within a quote that took this context.
1621
* It is only required if working with the reflection API.

0 commit comments

Comments
 (0)