Skip to content

Commit e6664ed

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 4e67e2d commit e6664ed

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-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
@@ -609,14 +609,20 @@ class Definitions {
609609
lazy val QuotedExprType = ctx.requiredClassRef("scala.quoted.Expr")
610610
def QuotedExprClass(implicit ctx: Context) = QuotedExprType.symbol.asClass
611611

612-
def QuotedExpr_~(implicit ctx: Context) = QuotedExprClass.requiredMethod(nme.UNARY_~)
613-
def QuotedExpr_run(implicit ctx: Context) = QuotedExprClass.requiredMethod(nme.run)
612+
lazy val QuotedExpr_spliceR = QuotedExprClass.requiredMethod(nme.UNARY_~)
613+
def QuotedExpr_~(implicit ctx: Context) = QuotedExpr_spliceR.symbol
614+
lazy val QuotedExpr_runR = QuotedExprClass.requiredMethodRef(nme.run)
615+
def QuotedExpr_run(implicit ctx: Context) = QuotedExpr_runR.symbol
614616

615617
lazy val QuotedTypeType = ctx.requiredClassRef("scala.quoted.Type")
616618
def QuotedTypeClass(implicit ctx: Context) = QuotedTypeType.symbol.asClass
617619

618-
def QuotedType_~(implicit ctx: Context) =
619-
QuotedTypeClass.info.member(tpnme.UNARY_~).symbol.asType
620+
lazy val QuotedType_spliceR = QuotedTypeClass.requiredType(tpnme.UNARY_~).typeRef
621+
def QuotedType_~ = QuotedType_spliceR.symbol
622+
623+
lazy val QuotedTypeModule = QuotedTypeClass.companionModule
624+
lazy val QuotedType_applyR = QuotedTypeModule.requiredMethodRef(nme.apply)
625+
def QuotedType_apply(implicit ctx: Context) = QuotedType_applyR.symbol
620626

621627
def Unpickler_unpickleExpr = ctx.requiredMethod("scala.runtime.quoted.Unpickler.unpickleExpr")
622628
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"

library/src/scala/quoted/Type.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ abstract class Type[T] extends Quoted {
99
/** Some basic type tags, currently incomplete */
1010
object Type {
1111

12+
implicit def apply[T]: Type[T] = ???
13+
1214
class TaggedPrimitive[T] private[Type] (implicit val ct: ClassTag[T]) extends Type[T]
1315

1416
implicit def UnitTag: Type[Unit] = new TaggedPrimitive[Unit]

0 commit comments

Comments
 (0)