Skip to content

Commit 95090fd

Browse files
committed
Move quoted.{Expr|Type}.apply to quoted.internal.Compiletime
1 parent 6571053 commit 95090fd

File tree

17 files changed

+52
-31
lines changed

17 files changed

+52
-31
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,15 @@ class Definitions {
704704

705705
lazy val QuotedExprType: TypeRef = ctx.requiredClassRef("scala.quoted.Expr")
706706
def QuotedExprClass(implicit ctx: Context): ClassSymbol = QuotedExprType.symbol.asClass
707-
def QuotedExprModule(implicit ctx: Context): Symbol = QuotedExprClass.companionModule
708-
lazy val QuotedExpr_applyR: TermRef = QuotedExprModule.requiredMethodRef(nme.apply)
709-
def QuotedExpr_apply(implicit ctx: Context): Symbol = QuotedExpr_applyR.symbol
710707
lazy val QuotedExpr_splice : TermSymbol = QuotedExprClass.requiredMethod(nme.splice)
711708

709+
lazy val QuotedCompiletimeModule: TermRef = ctx.requiredModuleRef("scala.quoted.internal.Compiletime")
710+
def QuotedCompiletimeModuleClass: Symbol = QuotedCompiletimeModule.symbol
711+
lazy val QuotedCompiletime_exprQuoteR: TermRef = QuotedCompiletimeModuleClass.requiredMethodRef("exprQuote".toTermName)
712+
def QuotedCompiletime_exprQuote(implicit ctx: Context): Symbol = QuotedCompiletime_exprQuoteR.symbol
713+
lazy val QuotedCompiletime_typeQuoteR: TermRef = QuotedCompiletimeModuleClass.requiredMethodRef("typeQuote".toTermName)
714+
def QuotedCompiletime_typeQuote(implicit ctx: Context): Symbol = QuotedCompiletime_typeQuoteR.symbol
715+
712716
lazy val QuotedExprsModule: TermSymbol = ctx.requiredModule("scala.quoted.Exprs")
713717
def QuotedExprsClass(implicit ctx: Context): ClassSymbol = QuotedExprsModule.asClass
714718

@@ -720,8 +724,6 @@ class Definitions {
720724

721725
lazy val QuotedTypeModuleType: TermRef = ctx.requiredModuleRef("scala.quoted.Type")
722726
def QuotedTypeModule(implicit ctx: Context): Symbol = QuotedTypeModuleType.symbol
723-
lazy val QuotedType_applyR: TermRef = QuotedTypeModule.requiredMethodRef(nme.apply)
724-
def QuotedType_apply(implicit ctx: Context): Symbol = QuotedType_applyR.symbol
725727

726728
lazy val QuotedLiftableModule: TermSymbol = ctx.requiredModule("scala.quoted.Liftable")
727729
def QuotedLiftableModuleClass(implicit ctx: Context): ClassSymbol = QuotedLiftableModule.asClass

compiler/src/dotty/tools/dotc/printing/DecompilerPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class DecompilerPrinter(_ctx: Context) extends RefinedPrinter(_ctx) {
7474
}
7575

7676
override protected def typeApplyText[T >: Untyped](tree: TypeApply[T]): Text = {
77-
if (tree.symbol eq defn.QuotedExpr_apply) "'"
78-
else if (tree.symbol eq defn.QuotedType_apply) "'[" ~ toTextGlobal(tree.args, ", ") ~ "]"
77+
if (tree.symbol eq defn.QuotedCompiletime_exprQuote) "'"
78+
else if (tree.symbol eq defn.QuotedCompiletime_typeQuote) "'[" ~ toTextGlobal(tree.args, ", ") ~ "]"
7979
else super.typeApplyText(tree)
8080
}
8181
}

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
252252
("{" ~ toText(trees, "\n") ~ "}").close
253253

254254
protected def typeApplyText[T >: Untyped](tree: TypeApply[T]): Text = {
255-
val isQuote = tree.fun.hasType && tree.fun.symbol == defn.QuotedType_apply
255+
val isQuote = tree.fun.hasType && tree.fun.symbol == defn.QuotedCompiletime_typeQuote
256256
val (open, close) = if (isQuote) (keywordStr("'["), keywordStr("]")) else ("[", "]")
257257
toTextLocal(tree.fun).provided(!isQuote) ~ open ~ toTextGlobal(tree.args, ", ") ~ close
258258
}
@@ -341,7 +341,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
341341
changePrec (GlobalPrec) {
342342
keywordStr("throw ") ~ toText(args.head)
343343
}
344-
else if (fun.hasType && fun.symbol == defn.QuotedExpr_apply)
344+
else if (fun.hasType && fun.symbol == defn.QuotedCompiletime_exprQuote)
345345
keywordStr("'{") ~ toTextGlobal(args, ", ") ~ keywordStr("}")
346346
else
347347
toTextLocal(fun) ~ "(" ~ toTextGlobal(args, ", ") ~ ")"

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ class ReifyQuotes extends MacroTransform {
169169
* core and splices as arguments.
170170
*/
171171
override protected def transformQuotation(body: Tree, quote: Tree)(implicit ctx: Context): Tree = {
172-
val isType = quote.symbol eq defn.QuotedType_apply
172+
val isType = quote.symbol eq defn.QuotedCompiletime_typeQuote
173173
assert(!body.symbol.isSplice)
174174
if (level > 0) {
175175
val body1 = nested(isQuote = true).transform(body)(quoteContext)

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ object Splicer {
307307
protected def unexpectedTree(tree: Tree)(implicit env: Env): Result
308308

309309
protected final def interpretTree(tree: Tree)(implicit env: Env): Result = tree match {
310-
case Apply(TypeApply(fn, _), quoted :: Nil) if fn.symbol == defn.QuotedExpr_apply =>
310+
case Apply(TypeApply(fn, _), quoted :: Nil) if fn.symbol == defn.QuotedCompiletime_exprQuote =>
311311
val quoted1 = quoted match {
312312
case quoted: Ident if quoted.symbol.is(InlineByNameProxy) =>
313313
// inline proxy for by-name parameter
@@ -317,7 +317,7 @@ object Splicer {
317317
}
318318
interpretQuote(quoted1)
319319

320-
case TypeApply(fn, quoted :: Nil) if fn.symbol == defn.QuotedType_apply =>
320+
case TypeApply(fn, quoted :: Nil) if fn.symbol == defn.QuotedCompiletime_typeQuote =>
321321
interpretTypeQuote(quoted)
322322

323323
case Literal(Constant(value)) =>

compiler/src/dotty/tools/dotc/transform/SymUtils.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class SymUtils(val self: Symbol) extends AnyVal {
159159

160160
/** Is symbol a quote operation? */
161161
def isQuote(implicit ctx: Context): Boolean =
162-
self == defn.QuotedExpr_apply || self == defn.QuotedType_apply
162+
self == defn.QuotedCompiletime_exprQuote || self == defn.QuotedCompiletime_typeQuote
163163

164164
/** Is symbol a splice operation? */
165165
def isSplice(implicit ctx: Context): Boolean =

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,10 +678,10 @@ trait Implicits { self: Typer =>
678678
}
679679
}
680680
val tag = bindFreeVars(arg)
681-
if (bindFreeVars.ok) ref(defn.QuotedType_apply).appliedToType(tag)
681+
if (bindFreeVars.ok) ref(defn.QuotedCompiletime_typeQuote).appliedToType(tag)
682682
else EmptyTree
683683
case arg :: Nil if ctx.inInlineMethod =>
684-
ref(defn.QuotedType_apply).appliedToType(arg)
684+
ref(defn.QuotedCompiletime_typeQuote).appliedToType(arg)
685685
case _ =>
686686
EmptyTree
687687
}

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,9 +1935,9 @@ class Typer extends Namer
19351935
def typedQuote(tree: untpd.Quote, pt: Type)(implicit ctx: Context): Tree = track("typedQuote") {
19361936
val tree1 =
19371937
if (tree.t.isType)
1938-
typedTypeApply(untpd.TypeApply(untpd.ref(defn.QuotedType_applyR), List(tree.t)), pt)(quoteContext)
1938+
typedTypeApply(untpd.TypeApply(untpd.ref(defn.QuotedCompiletime_typeQuoteR), List(tree.t)), pt)(quoteContext)
19391939
else
1940-
typedApply(untpd.Apply(untpd.ref(defn.QuotedExpr_applyR), tree.t), pt)(quoteContext)
1940+
typedApply(untpd.Apply(untpd.ref(defn.QuotedCompiletime_exprQuoteR), tree.t), pt)(quoteContext)
19411941
tree1.withSpan(tree.span)
19421942
}
19431943

library/src-bootstrapped/scala/quoted/Type.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ sealed abstract class Type[T <: AnyKind] {
1010

1111
/** Some basic type tags, currently incomplete */
1212
object Type {
13-
/** A term quote is desugared by the compiler into a call to this method */
14-
def apply[T <: AnyKind]: Type[T] =
15-
throw new Error("Internal error: this method call should have been replaced by the compiler")
1613

1714
implicit def UnitTag: Type[Unit] = new TaggedType[Unit]
1815
implicit def BooleanTag: Type[Boolean] = new TaggedType[Boolean]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package scala.quoted
2+
package internal
3+
4+
object Compiletime {
5+
6+
/** A term quote is desugared by the compiler into a call to this method */
7+
def exprQuote[T](x: T): Expr[T] =
8+
throw new Error("Internal error: this method call should have been replaced by the compiler")
9+
10+
/** A type quote is desugared by the compiler into a call to this method */
11+
def typeQuote[T <: AnyKind]: Type[T] =
12+
throw new Error("Internal error: this method call should have been replaced by the compiler")
13+
14+
15+
}

library/src-non-bootstrapped/scala/quoted/Type.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ sealed abstract class Type[T] {
1010

1111
/** Some basic type tags, currently incomplete */
1212
object Type {
13-
/** A term quote is desugared by the compiler into a call to this method */
14-
def apply[T]: Type[T] =
15-
throw new Error("Internal error: this method call should have been replaced by the compiler")
16-
1713
implicit def UnitTag: Type[Unit] = new TaggedType[Unit]
1814
implicit def BooleanTag: Type[Boolean] = new TaggedType[Boolean]
1915
implicit def ByteTag: Type[Byte] = new TaggedType[Byte]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package scala.quoted
2+
package internal
3+
4+
object Compiletime {
5+
6+
/** A term quote is desugared by the compiler into a call to this method */
7+
def exprQuote[T](x: T): Expr[T] =
8+
throw new Error("Internal error: this method call should have been replaced by the compiler")
9+
10+
/** A type quote is desugared by the compiler into a call to this method */
11+
def typeQuote[T]: Type[T] =
12+
throw new Error("Internal error: this method call should have been replaced by the compiler")
13+
14+
}

library/src/scala/quoted/Expr.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ sealed abstract class Expr[+T] {
1818
}
1919

2020
object Expr {
21-
/** A term quote is desugared by the compiler into a call to this method */
22-
def apply[T](x: T): Expr[T] =
23-
throw new Error("Internal error: this method call should have been replaced by the compiler")
2421

2522
// TODO simplify using new extension methods
2623

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
scala.quoted.Expr.apply[scala.Int](3)
1+
quoted.internal.Compiletime.exprQuote[scala.Int](3)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
val a: scala.quoted.Expr[scala.Int] = scala.quoted.Expr.apply[scala.Int](4)
2+
val a: scala.quoted.Expr[scala.Int] = quoted.internal.Compiletime.exprQuote[scala.Int](4)
33
a
44
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
val t: scala.quoted.Type[scala.Predef.String] = scala.quoted.Type.apply[scala.Predef.String]
2+
val t: scala.quoted.Type[scala.Predef.String] = quoted.internal.Compiletime.typeQuote[scala.Predef.String]
33

44
(t: scala.quoted.Type[scala.Predef.String])
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
val a: scala.quoted.Expr[scala.Int] = scala.quoted.Expr.apply[scala.Int](4)
2+
val a: scala.quoted.Expr[scala.Int] = quoted.internal.Compiletime.exprQuote[scala.Int](4)
33
a
44
}

0 commit comments

Comments
 (0)