Skip to content

Commit 1180aba

Browse files
Merge pull request #10283 from dotty-staging/rename-type-apply-to-type-of
Align `quoted.Type` with `reflect.TypeRepr` and `reflect.TypeTree`
2 parents c3ac180 + bd19b84 commit 1180aba

Some content is hidden

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

54 files changed

+92
-91
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
395395
case New(_) | Closure(_, _, _) =>
396396
Pure
397397
case TypeApply(fn, _) =>
398-
if (fn.symbol.is(Erased) || fn.symbol == defn.QuotedTypeModule_apply || fn.symbol == defn.Predef_classOf) Pure else exprPurity(fn)
398+
if (fn.symbol.is(Erased) || fn.symbol == defn.QuotedTypeModule_of || fn.symbol == defn.Predef_classOf) Pure else exprPurity(fn)
399399
case Apply(fn, args) =>
400400
def isKnownPureOp(sym: Symbol) =
401401
sym.owner.isPrimitiveValueClass

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ class Definitions {
833833
@tu lazy val QuotedType_splice: Symbol = QuotedTypeClass.requiredType(tpnme.Underlying)
834834

835835
@tu lazy val QuotedTypeModule: Symbol = QuotedTypeClass.companionModule
836-
@tu lazy val QuotedTypeModule_apply: Symbol = QuotedTypeModule.requiredMethod("apply")
836+
@tu lazy val QuotedTypeModule_of: Symbol = QuotedTypeModule.requiredMethod("of")
837837

838838
@tu lazy val TastyReflectionClass: ClassSymbol = requiredClass("scala.tasty.Reflection")
839839

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ final class TypeImpl(val typeTree: tpd.Tree, val scopeId: Int) extends scala.quo
2424
throw new ScopeException("Cannot call `scala.quoted.staging.run(...)` within a macro or another `run(...)`")
2525

2626
override def hashCode: Int = typeTree.hashCode
27-
override def toString: String = "'[ ... ]"
27+
override def toString: String = "Type.of[...]"
2828
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class PickleQuotes extends MacroTransform {
128128
* core and splices as arguments.
129129
*/
130130
override protected def transformQuotation(body: Tree, quote: Tree)(using Context): Tree = {
131-
val isType = quote.symbol eq defn.QuotedTypeModule_apply
131+
val isType = quote.symbol eq defn.QuotedTypeModule_of
132132
if (level > 0) {
133133
val body1 = nested(isQuote = true).transform(body)(using quoteContext)
134134
super.transformQuotation(body1, quote)
@@ -472,7 +472,7 @@ class PickleQuotes extends MacroTransform {
472472
transform(tree)(using ctx.withSource(tree.source))
473473
else reporting.trace(i"Reifier.transform $tree at $level", show = true) {
474474
tree match {
475-
case Apply(Select(TypeApply(fn, (body: RefTree) :: Nil), _), _) if fn.symbol == defn.QuotedTypeModule_apply && isCaptured(body.symbol, level + 1) =>
475+
case Apply(Select(TypeApply(fn, (body: RefTree) :: Nil), _), _) if fn.symbol == defn.QuotedTypeModule_of && isCaptured(body.symbol, level + 1) =>
476476
// Optimization: avoid the full conversion when capturing `x`
477477
// in '{ x } to '{ ${x$1} } and go directly to `x$1`
478478
capturers(body.symbol)(body)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ object Splicer {
146146
case Apply(Select(Apply(fn, quoted :: Nil), nme.apply), _) if fn.symbol == defn.InternalQuoted_exprQuote =>
147147
// OK
148148

149-
case Apply(Select(TypeApply(fn, List(quoted)), nme.apply), _)if fn.symbol == defn.QuotedTypeModule_apply =>
149+
case Apply(Select(TypeApply(fn, List(quoted)), nme.apply), _)if fn.symbol == defn.QuotedTypeModule_of =>
150150
// OK
151151

152152
case Literal(Constant(value)) =>
@@ -230,7 +230,7 @@ object Splicer {
230230
}
231231
interpretQuote(quoted1)
232232

233-
case Apply(Select(TypeApply(fn, quoted :: Nil), _), _) if fn.symbol == defn.QuotedTypeModule_apply =>
233+
case Apply(Select(TypeApply(fn, quoted :: Nil), _), _) if fn.symbol == defn.QuotedTypeModule_of =>
234234
interpretTypeQuote(quoted)
235235

236236
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
@@ -223,7 +223,7 @@ object SymUtils:
223223

224224
/** Is symbol a quote operation? */
225225
def isQuote(using Context): Boolean =
226-
self == defn.InternalQuoted_exprQuote || self == defn.QuotedTypeModule_apply
226+
self == defn.InternalQuoted_exprQuote || self == defn.QuotedTypeModule_of
227227

228228
/** Is symbol a term splice operation? */
229229
def isExprSplice(using Context): Boolean =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
524524
case New(_) | Closure(_, _, _) =>
525525
true
526526
case TypeApply(fn, _) =>
527-
if (fn.symbol.is(Erased) || fn.symbol == defn.QuotedTypeModule_apply) true else apply(fn)
527+
if (fn.symbol.is(Erased) || fn.symbol == defn.QuotedTypeModule_of) true else apply(fn)
528528
case Apply(fn, args) =>
529529
def isKnownPureOp(sym: Symbol) =
530530
sym.owner.isPrimitiveValueClass

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ trait QuotesAndSplices {
6363
val msg = em"Consider using canonical type constructor scala.quoted.Type[${tree.quoted}] instead"
6464
if sourceVersion.isAtLeast(`3.1-migration`) then report.error(msg, tree.srcPos)
6565
else report.warning(msg, tree.srcPos)
66-
typedTypeApply(untpd.TypeApply(untpd.ref(defn.QuotedTypeModule_apply.termRef), tree.quoted :: Nil), pt)(using quoteContext).select(nme.apply).appliedTo(qctx)
66+
typedTypeApply(untpd.TypeApply(untpd.ref(defn.QuotedTypeModule_of.termRef), tree.quoted :: Nil), pt)(using quoteContext).select(nme.apply).appliedTo(qctx)
6767
else
6868
typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuote.termRef), tree.quoted), pt)(using pushQuoteContext(qctx)).select(nme.apply).appliedTo(qctx)
6969
tree1.withSpan(tree.span)
@@ -461,7 +461,7 @@ trait QuotesAndSplices {
461461
val quoteClass = if (tree.quoted.isTerm) defn.QuotedExprClass else defn.QuotedTypeClass
462462
val quotedPattern =
463463
if (tree.quoted.isTerm) ref(defn.InternalQuoted_exprQuote.termRef).appliedToType(defn.AnyType).appliedTo(shape).select(nme.apply).appliedTo(qctx)
464-
else ref(defn.QuotedTypeModule_apply.termRef).appliedToTypeTree(shape).select(nme.apply).appliedTo(qctx)
464+
else ref(defn.QuotedTypeModule_of.termRef).appliedToTypeTree(shape).select(nme.apply).appliedTo(qctx)
465465

466466
val matchModule = if tree.quoted.isTerm then defn.QuoteMatching_ExprMatch else defn.QuoteMatching_TypeMatch
467467
val unapplyFun = qctx.asInstance(defn.QuoteMatchingClass.typeRef).select(matchModule).select(nme.unapply)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object Type:
2020
qctx.reflect.TypeTree.of[T].showAnsiColored
2121

2222
/** Return a quoted.Type with the given type */
23-
@compileTimeOnly("Reference to `scala.quoted.Type.apply` was not handled by PickleQuotes")
24-
given apply[T <: AnyKind] as (QuoteContext ?=> Type[T]) = ???
23+
@compileTimeOnly("Reference to `scala.quoted.Type.of` was not handled by PickleQuotes")
24+
given of[T <: AnyKind] as (QuoteContext ?=> Type[T]) = ???
2525

2626
end Type

0 commit comments

Comments
 (0)