Skip to content

Commit 775bd8f

Browse files
committed
Rename meta -> quoted
1 parent 21e4a27 commit 775bd8f

File tree

9 files changed

+43
-26
lines changed

9 files changed

+43
-26
lines changed

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package core
55
import Types._, Contexts._, Symbols._, Denotations._, SymDenotations._, StdNames._, Names._
66
import Flags._, Scopes._, Decorators._, NameOps._, util.Positions._, Periods._
77
import unpickleScala2.Scala2Unpickler.ensureConstructor
8-
import scala.annotation.{ switch, meta }
98
import scala.collection.{ mutable, immutable }
109
import PartialFunction._
1110
import collection.mutable
@@ -299,11 +298,11 @@ class Definitions {
299298

300299
/** Method representing a term quote */
301300
lazy val quoteMethod = enterPolyMethod(OpsPackageClass, nme.QUOTE, 1,
302-
pt => MethodType(pt.paramRefs(0) :: Nil, MetaExprType.appliedTo(pt.paramRefs(0) :: Nil)))
301+
pt => MethodType(pt.paramRefs(0) :: Nil, QuotedExprType.appliedTo(pt.paramRefs(0) :: Nil)))
303302

304303
/** Method representing a type quote */
305304
lazy val typeQuoteMethod = enterPolyMethod(OpsPackageClass, nme.QUOTE, 1,
306-
pt => MetaTypeType.appliedTo(pt.paramRefs(0) :: Nil))
305+
pt => QuotedTypeType.appliedTo(pt.paramRefs(0) :: Nil))
307306

308307
lazy val NothingClass: ClassSymbol = enterCompleteClassSymbol(
309308
ScalaPackageClass, tpnme.Nothing, AbstractFinal, List(AnyClass.typeRef))
@@ -591,22 +590,22 @@ class Definitions {
591590
def ClassTagClass(implicit ctx: Context) = ClassTagType.symbol.asClass
592591
def ClassTagModule(implicit ctx: Context) = ClassTagClass.companionModule
593592

594-
lazy val MetaQuotedType = ctx.requiredClassRef("scala.meta.Quoted")
595-
def MetaQuotedClass(implicit ctx: Context) = MetaQuotedType.symbol.asClass
593+
lazy val QuotedType = ctx.requiredClassRef("scala.quoted.Quoted")
594+
def QuotedClass(implicit ctx: Context) = QuotedType.symbol.asClass
596595

597-
lazy val MetaExprType = ctx.requiredClassRef("scala.meta.Expr")
598-
def MetaExprClass(implicit ctx: Context) = MetaExprType.symbol.asClass
596+
lazy val QuotedExprType = ctx.requiredClassRef("scala.quoted.Expr")
597+
def QuotedExprClass(implicit ctx: Context) = QuotedExprType.symbol.asClass
599598

600-
def MetaExpr_~(implicit ctx: Context) = MetaExprClass.requiredMethod(nme.UNARY_~)
599+
def QuotedExpr_~(implicit ctx: Context) = QuotedExprClass.requiredMethod(nme.UNARY_~)
601600

602-
lazy val MetaTypeType = ctx.requiredClassRef("scala.meta.Type")
603-
def MetaTypeClass(implicit ctx: Context) = MetaTypeType.symbol.asClass
601+
lazy val QuotedTypeType = ctx.requiredClassRef("scala.quoted.Type")
602+
def QuotedTypeClass(implicit ctx: Context) = QuotedTypeType.symbol.asClass
604603

605-
def MetaType_~(implicit ctx: Context) =
606-
MetaTypeClass.info.member(tpnme.UNARY_~).symbol.asType
604+
def QuotedType_~(implicit ctx: Context) =
605+
QuotedTypeClass.info.member(tpnme.UNARY_~).symbol.asType
607606

608-
def Unpickler_unpickleExpr = ctx.requiredMethod("scala.meta.Unpickler.unpickleExpr")
609-
def Unpickler_unpickleType = ctx.requiredMethod("scala.meta.Unpickler.unpickleType")
607+
def Unpickler_unpickleExpr = ctx.requiredMethod("scala.quoted.Unpickler.unpickleExpr")
608+
def Unpickler_unpickleType = ctx.requiredMethod("scala.quoted.Unpickler.unpickleType")
610609

611610
lazy val EqType = ctx.requiredClassRef("scala.Eq")
612611
def EqClass(implicit ctx: Context) = EqType.symbol.asClass

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ReifyQuotes extends MacroTransform {
2525
*
2626
* Select(qual, sym)
2727
*
28-
* where `sym` is either `defn.MetaExpr_~` or `defn.MetaType_~`. For any splice,
28+
* where `sym` is either `defn.QuotedExpr_~` or `defn.QuotedType_~`. For any splice,
2929
* the `qual` part should not be pickled, since it will be added separately later
3030
* as a splice.
3131
*/
@@ -76,8 +76,8 @@ class ReifyQuotes extends MacroTransform {
7676
else check(sym, _.show)
7777
}
7878

79-
/** Turn `body` of quote into a call of `scala.meta.Unpickler.unpickleType` or
80-
* `scala.meta.Unpickler.unpickleExpr` depending onwhether `isType` is true or not.
79+
/** Turn `body` of quote into a call of `scala.quoted.Unpickler.unpickleType` or
80+
* `scala.quoted.Unpickler.unpickleExpr` depending onwhether `isType` is true or not.
8181
* The arguments to the method are:
8282
*
8383
* - the serialized `body`, as returned from `pickleTree`
@@ -88,7 +88,7 @@ class ReifyQuotes extends MacroTransform {
8888
.appliedToType(if (isType) body.tpe else body.tpe.widen)
8989
.appliedTo(
9090
Literal(Constant(pickleTree(body, isType))),
91-
SeqLiteral(splicesAtLevel(currentLevel).toList, TypeTree(defn.MetaQuotedType)))
91+
SeqLiteral(splicesAtLevel(currentLevel).toList, TypeTree(defn.QuotedType)))
9292

9393
/** Perform operation `op` in quoted context */
9494
private def inQuote(op: => Tree)(implicit ctx: Context) = {
@@ -109,7 +109,7 @@ class ReifyQuotes extends MacroTransform {
109109
case TypeApply(fn, arg :: Nil) if fn.symbol == defn.typeQuoteMethod =>
110110
inQuote(reifyCall(transform(arg), isType = true))
111111
case Select(body, name)
112-
if tree.symbol == defn.MetaExpr_~ || tree.symbol == defn.MetaType_~ =>
112+
if tree.symbol == defn.QuotedExpr_~ || tree.symbol == defn.QuotedType_~ =>
113113
currentLevel -= 1
114114
val body1 = try transform(body) finally currentLevel += 1
115115
if (currentLevel > 0) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
10761076
ctx.compilationUnit.containsQuotes = true
10771077
val untpd.Quote(body) = tree
10781078
val isType = body.isType
1079-
val resultClass = if (isType) defn.MetaTypeClass else defn.MetaExprClass
1079+
val resultClass = if (isType) defn.QuotedTypeClass else defn.QuotedExprClass
10801080
val proto1 = pt.baseType(resultClass) match {
10811081
case AppliedType(_, argType :: Nil) => argType
10821082
case _ => WildcardType
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package scala.meta
1+
package scala.quoted
22

33
class Expr[T] extends Quoted {
44
def unary_~ : T = ???
5+
def run: T = ???
56
}

library/src/scala/meta/Quoted.scala renamed to library/src/scala/quoted/Quoted.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package scala.meta
1+
package scala.quoted
22

33
/** Common superclass of Expr and Type */
44
class Quoted
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package scala.meta
1+
package scala.quoted
22

33
class Type[T] extends Quoted {
44
type unary_~ = T
55
}
6+

library/src/scala/meta/Unpickler.scala renamed to library/src/scala/quoted/Unpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package scala.meta
1+
package scala.quoted
22

33
/** Provides methods to unpickle `Expr` and `Type` trees. */
44
object Unpickler {

tests/neg/quoteTest.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import scala.quoted._
2+
3+
class Test {
4+
5+
val x: Int = 0
6+
7+
'{ '(x + 1) // error: wrong staging level
8+
9+
'((y: Expr[Int]) => ~y ) // error: wrong staging level
10+
11+
}
12+
13+
'(x + 1) // error: wrong staging level
14+
15+
'((y: Expr[Int]) => ~y ) // error: wrong staging level
16+
}

tests/pos/quoteTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import scala.meta._
1+
import scala.quoted._
22

33
object Test {
44

5-
def f[T](t: Type[T], x: Expr[T]) = {
5+
def f[T](t: Type[T], x: Expr[T]) = '{
66
val y: t.unary_~ = x.unary_~
77
val z: ~t = ~x
88
}

0 commit comments

Comments
 (0)