Skip to content

Commit 082edca

Browse files
Merge pull request #7408 from lampepfl/revert-7404-disambiguate-quoted-type-and-reflection-type
Revert "Disambiguate quoted and tasty Type"
2 parents 4719e7b + bf349b3 commit 082edca

File tree

157 files changed

+464
-672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

157 files changed

+464
-672
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ object desugar {
292292
}
293293
}
294294

295-
/** Transforms a definition with a name starting with a `$` in a quoted pattern into a `scala.quoted.binding.Binding` splice.
295+
/** Transforms a definition with a name starting with a `$` in a quoted pattern into a `quoted.binding.Binding` splice.
296296
*
297297
* The desugaring consists in adding the `@patternBindHole` annotation. This annotation is used during typing to perform the full transformation.
298298
*

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
12071207
/** An extractor for typed splices */
12081208
object Splice {
12091209
def apply(tree: Tree)(implicit ctx: Context): Tree = {
1210-
val baseType = tree.tpe.baseType(defn.QuotedExprClass).orElse(tree.tpe.baseType(defn.QuotedTypeTagClass))
1210+
val baseType = tree.tpe.baseType(defn.QuotedExprClass).orElse(tree.tpe.baseType(defn.QuotedTypeClass))
12111211
val argType =
12121212
if (baseType != NoType) baseType.argTypesHi.head
12131213
else defn.NothingType

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -659,13 +659,13 @@ class Definitions {
659659
@tu lazy val InternalQuotedExprModule: Symbol = ctx.requiredModule("scala.internal.quoted.Expr")
660660
@tu lazy val InternalQuotedExpr_unapply: Symbol = InternalQuotedExprModule.requiredMethod(nme.unapply)
661661

662-
@tu lazy val InternalQuotedTypeTagModule: Symbol = ctx.requiredModule("scala.internal.quoted.TypeTag")
663-
@tu lazy val InternalQuotedTypeTag_unapply: Symbol = InternalQuotedTypeTagModule.requiredMethod(nme.unapply)
662+
@tu lazy val InternalQuotedTypeModule: Symbol = ctx.requiredModule("scala.internal.quoted.Type")
663+
@tu lazy val InternalQuotedType_unapply: Symbol = InternalQuotedTypeModule.requiredMethod(nme.unapply)
664664

665-
@tu lazy val QuotedTypeTagClass: ClassSymbol = ctx.requiredClass("scala.quoted.TypeTag")
666-
@tu lazy val QuotedTypeTag_splice: Symbol = QuotedTypeTagClass.requiredType(tpnme.splice)
665+
@tu lazy val QuotedTypeClass: ClassSymbol = ctx.requiredClass("scala.quoted.Type")
666+
@tu lazy val QuotedType_splice: Symbol = QuotedTypeClass.requiredType(tpnme.splice)
667667

668-
@tu lazy val QuotedTypeTagModule: Symbol = QuotedTypeTagClass.companionModule
668+
@tu lazy val QuotedTypeModule: Symbol = QuotedTypeClass.companionModule
669669

670670
@tu lazy val QuotedMatchingSymClass: ClassSymbol = ctx.requiredClass("scala.quoted.matching.Sym")
671671
@tu lazy val TastyReflectionClass: ClassSymbol = ctx.requiredClass("scala.tasty.Reflection")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ object PickledQuotes {
3535
}
3636

3737
/** Transform the expression into its fully spliced Tree */
38-
def quotedExprToTree[T](expr: scala.quoted.Expr[T])(implicit ctx: Context): Tree = {
38+
def quotedExprToTree[T](expr: quoted.Expr[T])(implicit ctx: Context): Tree = {
3939
val expr1 = expr.asInstanceOf[TastyTreeExpr[Tree]]
4040
QuoteContext.checkScopeId(expr1.scopeId)
4141
healOwner(expr1.tree)
4242
}
4343

4444
/** Transform the expression into its fully spliced TypeTree */
45-
def quotedTypeToTree(tpe: scala.quoted.TypeTag[?])(implicit ctx: Context): Tree = {
45+
def quotedTypeToTree(tpe: quoted.Type[?])(implicit ctx: Context): Tree = {
4646
val tpe1 = tpe.asInstanceOf[TreeType[Tree]]
4747
QuoteContext.checkScopeId(tpe1.scopeId)
4848
healOwner(tpe1.typeTree)

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ class TreeUnpickler(reader: TastyReader,
12751275
else new TreeType(arg, QuoteContext.scopeId)
12761276
val reifiedArgs = args.map(wrap)
12771277
val filled = if (isType) {
1278-
val quotedType = splice.asInstanceOf[Seq[Any] => scala.quoted.TypeTag[?]](reifiedArgs)
1278+
val quotedType = splice.asInstanceOf[Seq[Any] => quoted.Type[?]](reifiedArgs)
12791279
PickledQuotes.quotedTypeToTree(quotedType)
12801280
}
12811281
else {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
374374
else if (name.isTypeName) typeText(txt)
375375
else txt
376376
case tree @ Select(qual, name) =>
377-
if (!printDebug && tree.hasType && tree.symbol == defn.QuotedTypeTag_splice) typeText("${") ~ toTextLocal(qual) ~ typeText("}")
377+
if (!printDebug && tree.hasType && tree.symbol == defn.QuotedType_splice) typeText("${") ~ toTextLocal(qual) ~ typeText("}")
378378
else if (qual.isType) toTextLocal(qual) ~ "#" ~ typeText(toText(name))
379379
else toTextLocal(qual) ~ ("." ~ nameIdText(tree) provided (name != nme.CONSTRUCTOR || printDebug))
380380
case tree: This =>
@@ -499,7 +499,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
499499
if (lo eq hi) optText(lo)(" = " ~ _)
500500
else optText(lo)(" >: " ~ _) ~ optText(hi)(" <: " ~ _)
501501
case Bind(name, body) =>
502-
keywordText("given ").provided(tree.symbol.isOneOf(GivenOrImplicit) && !homogenizedView) ~ // Used for scala.quoted.TypeTag in quote patterns (not pickled)
502+
keywordText("given ").provided(tree.symbol.isOneOf(GivenOrImplicit) && !homogenizedView) ~ // Used for scala.quoted.Type in quote patterns (not pickled)
503503
changePrec(InfixPrec) { toText(name) ~ " @ " ~ toText(body) }
504504
case Alternative(trees) =>
505505
changePrec(OrPrec) { toText(trees, " | ") }

compiler/src/dotty/tools/dotc/tastyreflect/ReflectionCompilerInterface.scala

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import dotty.tools.dotc.util.{SourceFile, SourcePosition, Spans}
1818
import scala.runtime.quoted.Unpickler
1919
import scala.tasty.reflect.CompilerInterface
2020

21-
import scala.quoted.{Expr, TypeTag}
22-
2321
class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extends CompilerInterface {
2422
import tpd._
2523

@@ -34,10 +32,10 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
3432
// QUOTE UNPICKLING
3533
//
3634

37-
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): Expr[?] =
35+
def unpickleExpr(repr: Unpickler.PickledQuote, args: Unpickler.PickledExprArgs): scala.quoted.Expr[?] =
3836
new scala.internal.quoted.TastyTreeExpr(PickledQuotes.unpickleExpr(repr, args), compilerId)
3937

40-
def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): TypeTag[?] =
38+
def unpickleType(repr: Unpickler.PickledQuote, args: Unpickler.PickledTypeArgs): scala.quoted.Type[?] =
4139
new scala.internal.quoted.TreeType(PickledQuotes.unpickleType(repr, args), compilerId)
4240

4341
//
@@ -1582,16 +1580,16 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
15821580
// QUOTED SEAL/UNSEAL
15831581
//
15841582

1585-
/** View this expression `scala.quoted.Expr[?]` as a `Term` */
1586-
def QuotedExpr_unseal(self: Expr[?])(given Context): Term =
1583+
/** View this expression `quoted.Expr[?]` as a `Term` */
1584+
def QuotedExpr_unseal(self: scala.quoted.Expr[?])(given Context): Term =
15871585
PickledQuotes.quotedExprToTree(self)
15881586

1589-
/** View this expression `scala.quoted.TypeTag[?]` as a `TypeTree` */
1590-
def QuotedType_unseal(self: TypeTag[?])(given Context): TypeTree =
1587+
/** View this expression `quoted.Type[?]` as a `TypeTree` */
1588+
def QuotedType_unseal(self: scala.quoted.Type[?])(given Context): TypeTree =
15911589
PickledQuotes.quotedTypeToTree(self)
15921590

1593-
/** Convert `Term` to an `scala.quoted.Expr[Any]` */
1594-
def QuotedExpr_seal(self: Term)(given ctx: Context): Expr[Any] = {
1591+
/** Convert `Term` to an `quoted.Expr[Any]` */
1592+
def QuotedExpr_seal(self: Term)(given ctx: Context): scala.quoted.Expr[Any] = {
15951593
def etaExpand(term: Term): Term = term.tpe.widen match {
15961594
case mtpe: Types.MethodType if !mtpe.isParamDependent =>
15971595
val closureResType = mtpe.resType match {
@@ -1606,12 +1604,12 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
16061604
new scala.internal.quoted.TastyTreeExpr(etaExpand(self), compilerId)
16071605
}
16081606

1609-
/** Checked cast to a `scala.quoted.Expr[U]` */
1610-
def QuotedExpr_cast[U](self: Expr[?])(given tp: TypeTag[U], ctx: Context): Expr[U] = {
1607+
/** Checked cast to a `quoted.Expr[U]` */
1608+
def QuotedExpr_cast[U](self: scala.quoted.Expr[?])(given tp: scala.quoted.Type[U], ctx: Context): scala.quoted.Expr[U] = {
16111609
val tree = QuotedExpr_unseal(self)
1612-
val expectedType = QuotedType_unseal(tp.asInstanceOf[TypeTag[U]]).tpe
1610+
val expectedType = QuotedType_unseal(tp).tpe
16131611
if (tree.tpe <:< expectedType)
1614-
self.asInstanceOf[Expr[U]]
1612+
self.asInstanceOf[scala.quoted.Expr[U]]
16151613
else
16161614
throw new scala.tasty.reflect.ExprCastError(
16171615
s"""Expr: ${tree.show}
@@ -1620,8 +1618,8 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
16201618
)
16211619
}
16221620

1623-
/** Convert `Type` to an `scala.quoted.TypeTag[?]` */
1624-
def QuotedType_seal(self: Type)(given ctx: Context): TypeTag[?] = {
1621+
/** Convert `Type` to an `quoted.Type[?]` */
1622+
def QuotedType_seal(self: Type)(given ctx: Context): scala.quoted.Type[?] = {
16251623
val dummySpan = ctx.owner.span // FIXME
16261624
new scala.internal.quoted.TreeType(tpd.TypeTree(self).withSpan(dummySpan), compilerId)
16271625
}

0 commit comments

Comments
 (0)