Skip to content

Commit 4a511b4

Browse files
committed
Move internal.quoted.CompileTime into scala.quoted.internal
1 parent d3bafb1 commit 4a511b4

File tree

9 files changed

+49
-47
lines changed

9 files changed

+49
-47
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,11 +812,12 @@ class Definitions {
812812
@tu lazy val LiftableModule_CharLiftable: Symbol = LiftableModule.requiredMethod("CharLiftable")
813813
@tu lazy val LiftableModule_StringLiftable: Symbol = LiftableModule.requiredMethod("StringLiftable")
814814

815-
@tu lazy val InternalQuotedModule: Symbol = requiredModule("scala.internal.quoted.CompileTime")
816-
@tu lazy val InternalQuoted_exprQuote : Symbol = InternalQuotedModule.requiredMethod("exprQuote")
817-
@tu lazy val InternalQuoted_exprSplice : Symbol = InternalQuotedModule.requiredMethod("exprSplice")
818-
@tu lazy val InternalQuoted_exprNestedSplice : Symbol = InternalQuotedModule.requiredMethod("exprNestedSplice")
819-
@tu lazy val InternalQuoted_QuoteTypeTagAnnot: ClassSymbol = InternalQuotedModule.requiredClass("quoteTypeTag")
815+
@tu lazy val InternalQuotedModule: Symbol = requiredModule("scala.quoted.internal.Expr")
816+
@tu lazy val InternalQuoted_exprQuote : Symbol = InternalQuotedModule.requiredMethod("quote")
817+
@tu lazy val InternalQuoted_exprSplice : Symbol = InternalQuotedModule.requiredMethod("splice")
818+
@tu lazy val InternalQuoted_exprNestedSplice : Symbol = InternalQuotedModule.requiredMethod("nestedSplice")
819+
820+
@tu lazy val InternalQuoted_SplicedTypeAnnot: ClassSymbol = requiredClass("scala.quoted.internal.SplicedType")
820821

821822
@tu lazy val InternalQuotedPatterns: Symbol = requiredModule("scala.quoted.internal.Patterns")
822823
@tu lazy val InternalQuotedPatterns_patternHole: Symbol = InternalQuotedPatterns.requiredMethod("patternHole")

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ object PickledQuotes {
123123
/** Replace all type holes generated with the spliced types */
124124
private def spliceTypes(tree: Tree, typeHole: (Int, Seq[Any]) => scala.quoted.Type[?], termHole: (Int, Seq[Int], scala.quoted.QuoteContext) => Any)(using Context): Tree = {
125125
tree match
126-
case Block(stat :: rest, expr1) if stat.symbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot) =>
126+
case Block(stat :: rest, expr1) if stat.symbol.hasAnnotation(defn.InternalQuoted_SplicedTypeAnnot) =>
127127
val typeSpliceMap = (stat :: rest).iterator.map {
128128
case tdef: TypeDef =>
129-
assert(tdef.symbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot))
129+
assert(tdef.symbol.hasAnnotation(defn.InternalQuoted_SplicedTypeAnnot))
130130
val tree = tdef.rhs match
131131
case TypeBoundsTree(_, Hole(_, idx, args), _) =>
132132
val quotedType = typeHole(idx, args)
@@ -141,7 +141,7 @@ object PickledQuotes {
141141
tp.derivedClassInfo(classParents = tp.classParents.map(apply))
142142
case tp: TypeRef =>
143143
typeSpliceMap.get(tp.symbol) match
144-
case Some(t) if tp.typeSymbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot) => mapOver(t)
144+
case Some(t) if tp.typeSymbol.hasAnnotation(defn.InternalQuoted_SplicedTypeAnnot) => mapOver(t)
145145
case _ => mapOver(tp)
146146
case _ =>
147147
mapOver(tp)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
174174
tp match
175175
case tp: TypeRef =>
176176
tp.prefix match
177-
case NoPrefix if level > levelOf(tp.symbol) && !tp.typeSymbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot) =>
177+
case NoPrefix if level > levelOf(tp.symbol) && !tp.typeSymbol.hasAnnotation(defn.InternalQuoted_SplicedTypeAnnot) =>
178178
val tp1 = tp.dealias
179179
if tp1 != tp then apply(tp1)
180180
else tryHeal(tp.symbol, tp, pos)
@@ -279,7 +279,7 @@ object PCPCheckAndHeal {
279279
flags = Synthetic,
280280
info = TypeAlias(splicedTree.tpe.select(tpnme.Underlying)),
281281
coord = span).asType
282-
local.addAnnotation(Annotation(defn.InternalQuoted_QuoteTypeTagAnnot))
282+
local.addAnnotation(Annotation(defn.InternalQuoted_SplicedTypeAnnot))
283283
ctx.typeAssigner.assignType(untpd.TypeDef(local.name, alias), local)
284284
}
285285

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class PickleQuotes extends MacroTransform {
8282
assert(!tree.symbol.isQuote)
8383
assert(!tree.symbol.isExprSplice)
8484
case _ : TypeDef =>
85-
assert(!tree.symbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot),
85+
assert(!tree.symbol.hasAnnotation(defn.InternalQuoted_SplicedTypeAnnot),
8686
s"${tree.symbol} should have been removed by PickledQuotes because it has a @quoteTypeTag")
8787
case _ =>
8888
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Staging extends MacroTransform {
4949
else i"${sym.name}.this"
5050
val errMsg = s"\nin ${ctx.owner.fullName}"
5151
assert(
52-
ctx.owner.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot) ||
52+
ctx.owner.hasAnnotation(defn.InternalQuoted_SplicedTypeAnnot) ||
5353
(sym.isType && levelOf(sym) > 0),
5454
em"""access to $symStr from wrong staging level:
5555
| - the definition is at level ${levelOf(sym)},

library/src-bootstrapped/scala/internal/quoted/CompileTime.scala

Lines changed: 0 additions & 34 deletions
This file was deleted.
Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
package scala.quoted.internal
1+
package scala.quoted
2+
package internal
3+
4+
import scala.annotation.{Annotation, compileTimeOnly}
25

36
/** Implementation of scala.quoted.Expr that sould only be extended by the implementation of `QuoteContext` */
47
abstract class Expr[+T] extends scala.quoted.Expr[T]
8+
9+
@compileTimeOnly("Illegal reference to `scala.quoted.internal.Expr`")
10+
object Expr:
11+
12+
/** A term quote is desugared by the compiler into a call to this method */
13+
@compileTimeOnly("Illegal reference to `scala.quoted.internal.Expr.quote`")
14+
def quote[T](x: T): QuoteContext ?=> scala.quoted.Expr[T] = ???
15+
16+
/** A term splice is desugared by the compiler into a call to this method */
17+
@compileTimeOnly("Illegal reference to `scala.quoted.internal.Expr.splice`")
18+
def splice[T](x: QuoteContext ?=> scala.quoted.Expr[T]): T = ???
19+
20+
/** A term splice nested within a quote is desugared by the compiler into a call to this method.
21+
* `ctx` is the `QuoteContext` that the quote of this splice uses.
22+
*/
23+
@compileTimeOnly("Illegal reference to `scala.quoted.internal.Expr.nestedSplice`")
24+
def nestedSplice[T](ctx: QuoteContext)(x: ctx.Nested ?=> scala.quoted.Expr[T]): T = ???

library/src/scala/quoted/internal/Patterns.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scala.quoted.internal
22

33
import scala.annotation.{Annotation, compileTimeOnly}
44

5+
@compileTimeOnly("Illegal reference to `scala.quoted.internal.Patterns`")
56
object Patterns {
67

78
/** A splice in a quoted pattern is desugared by the compiler into a call to this method */
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package scala.quoted.internal
2+
3+
import scala.annotation.{Annotation, compileTimeOnly}
4+
5+
/** Artifact of pickled type splices
6+
*
7+
* During quote reification a quote `'{ ... F[t.Underlying] ... }` will be transformed into
8+
* `'{ @SplicedType type T$1 = t.Underlying ... F[T$1] ... }` to have a tree for `t.Underlying`.
9+
* This artifact is removed during quote unpickling.
10+
*
11+
* See PickleQuotes.scala and PickledQuotes.scala
12+
*/
13+
@compileTimeOnly("Illegal reference to `scala.quoted.internal.SplicedType`")
14+
class SplicedType extends Annotation

0 commit comments

Comments
 (0)