Skip to content

Make QuoteContext a trait #8941

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
May 11, 2020
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
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/quoted/QuoteContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dotty.tools.dotc.tastyreflect.ReflectionImpl
object QuoteContext {

def apply()(using Context): scala.quoted.QuoteContext =
new scala.quoted.QuoteContext(ReflectionImpl(summon[Context]))
new QuoteContext(ReflectionImpl(summon[Context]))

type ScopeId = Int

Expand All @@ -19,3 +19,5 @@ object QuoteContext {
private[dotty] def scopeId(using Context): ScopeId =
summon[Context].outersIterator.toList.last.hashCode()
}

class QuoteContext(val tasty: scala.tasty.Reflection) extends scala.quoted.QuoteContext
7 changes: 6 additions & 1 deletion library/src/scala/quoted/QuoteContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import scala.quoted.show.SyntaxHighlight
*
* @param tasty Typed AST API. Usage: `def f(qctx: QuoteContext) = { import qctx.tasty._; ... }`.
*/
class QuoteContext(val tasty: scala.tasty.Reflection) { self =>
trait QuoteContext { self =>

/** Low-level Typed AST API `tasty` meta-programming API.
* This API does not have the static type guarantiees that `Expr` and `Type` provide.
*/
val tasty: scala.tasty.Reflection

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