Skip to content

Commit 5125c8e

Browse files
committed
Add quoted.Type.apply
This is intended as a stub. Calls to this method will be replaced by implicit type tag searches. Also, rework definition of quote and splice methods. This could also have contributed in the slowdown we were seeing in #3721.
1 parent 6a60743 commit 5125c8e

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,20 @@ class Definitions {
615615
lazy val QuotedExprType = ctx.requiredClassRef("scala.quoted.Expr")
616616
def QuotedExprClass(implicit ctx: Context) = QuotedExprType.symbol.asClass
617617

618-
def QuotedExpr_~(implicit ctx: Context) = QuotedExprClass.requiredMethod(nme.UNARY_~)
619-
def QuotedExpr_run(implicit ctx: Context) = QuotedExprClass.requiredMethod(nme.run)
618+
lazy val QuotedExpr_spliceR = QuotedExprClass.requiredMethod(nme.UNARY_~)
619+
def QuotedExpr_~(implicit ctx: Context) = QuotedExpr_spliceR.symbol
620+
lazy val QuotedExpr_runR = QuotedExprClass.requiredMethodRef(nme.run)
621+
def QuotedExpr_run(implicit ctx: Context) = QuotedExpr_runR.symbol
620622

621623
lazy val QuotedTypeType = ctx.requiredClassRef("scala.quoted.Type")
622624
def QuotedTypeClass(implicit ctx: Context) = QuotedTypeType.symbol.asClass
623625

624-
def QuotedType_~(implicit ctx: Context) =
625-
QuotedTypeClass.info.member(tpnme.UNARY_~).symbol.asType
626+
lazy val QuotedType_spliceR = QuotedTypeClass.requiredType(tpnme.UNARY_~).typeRef
627+
def QuotedType_~ = QuotedType_spliceR.symbol
628+
629+
lazy val QuotedTypeModule = QuotedTypeClass.companionModule
630+
lazy val QuotedType_applyR = QuotedTypeModule.requiredMethodRef(nme.apply)
631+
def QuotedType_apply(implicit ctx: Context) = QuotedType_applyR.symbol
626632

627633
def Unpickler_unpickleExpr = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleExpr")
628634
def Unpickler_unpickleType = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleType")

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ object Denotations {
313313
def requiredClass(name: PreName)(implicit ctx: Context): ClassSymbol =
314314
info.member(name.toTypeName).requiredSymbol(_.isClass).asClass
315315

316+
def requiredType(name: PreName)(implicit ctx: Context): TypeSymbol =
317+
info.member(name.toTypeName).requiredSymbol(_.isType).asType
318+
316319
/** The alternative of this denotation that has a type matching `targetType` when seen
317320
* as a member of type `site`, `NoDenotation` if none exists.
318321
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import dotty.tools.dotc.core.quoted._
2222
/** Translates quoted terms and types to `unpickle` method calls.
2323
* Checks that the phase consistency principle (PCP) holds.
2424
*/
25-
class ReifyQuotes extends MacroTransform {
25+
class ReifyQuotes extends MacroTransformWithImplicits {
2626
import ast.tpd._
2727

2828
override def phaseName: String = "reifyQuotes"

0 commit comments

Comments
 (0)