File tree Expand file tree Collapse file tree 4 files changed +13
-9
lines changed
compiler/src/dotty/tools/dotc/quoted/reflect
src-bootstrapped/scala/quoted Expand file tree Collapse file tree 4 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -1128,7 +1128,7 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte
11281128 case _ => None
11291129 }
11301130
1131- def Type_apply (clazz : Class [? ])(using Context ): Type =
1131+ def Type_ofErasedClass (clazz : Class [? ])(using Context ): Type =
11321132 if (clazz.isPrimitive)
11331133 if (clazz == classOf [Boolean ]) defn.BooleanType
11341134 else if (clazz == classOf [Byte ]) defn.ByteType
@@ -1140,10 +1140,10 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte
11401140 else if (clazz == classOf [Double ]) defn.DoubleType
11411141 else defn.UnitType
11421142 else if (clazz.isArray)
1143- defn.ArrayType .appliedTo(Type_apply (clazz.getComponentType))
1143+ defn.ArrayType .appliedTo(Type_ofErasedClass (clazz.getComponentType))
11441144 else if (clazz.isMemberClass) {
11451145 val name = clazz.getSimpleName.toTypeName
1146- val enclosing = Type_apply (clazz.getEnclosingClass)
1146+ val enclosing = Type_ofErasedClass (clazz.getEnclosingClass)
11471147 if (enclosing.member(name).exists) enclosing.select(name)
11481148 else
11491149 enclosing.classSymbol.companionModule.termRef.select(name)
Original file line number Diff line number Diff line change @@ -58,9 +58,11 @@ object Liftable {
5858
5959 /** Default liftable for Class[T] */
6060 given ClassLiftable [T ] as Liftable [Class [T ]] = new Liftable [Class [T ]] {
61- def toExpr (x : Class [T ]) = qctx ?=> {
62- import qctx .tasty ._
63- Ref (defn.Predef_classOf ).appliedToType(Type (x)).seal.asInstanceOf [Expr [Class [T ]]]
61+ def toExpr (x : Class [T ]) = {
62+ val qctx1 = scala.internal.tasty.CompilerInterface .quoteContextWithCompilerInterface(qctx)
63+ import qctx1 .tasty ._
64+ val tpe = qctx1.tasty.Type_ofErasedClass (x)
65+ Ref (defn.Predef_classOf ).appliedToType(tpe).seal.asInstanceOf [Expr [Class [T ]]]
6466 }
6567 }
6668
Original file line number Diff line number Diff line change @@ -512,7 +512,11 @@ trait CompilerInterface extends scala.tasty.reflect.Types {
512512
513513 def Type_TypeTest (using ctx : Context ): TypeTest [Type , Type ]
514514
515- def Type_apply (clazz : Class [_])(using ctx : Context ): Type
515+ /** Returns the type of the runtime class. This type is the erased representation
516+ * that of the type that is used by arrays.
517+ *
518+ */
519+ def Type_ofErasedClass (clazz : Class [_])(using ctx : Context ): Type
516520
517521 /** Is `self` type the same as `that` type?
518522 * This is the case iff `Type_isSubType(self, that)` and `Type_isSubType(that, self)`.
Original file line number Diff line number Diff line change @@ -1353,8 +1353,6 @@ trait Reflection extends reflect.Types { reflectSelf: CompilerInterface =>
13531353 def of [T <: AnyKind ](using qtype : scala.quoted.Type [T ], ctx : Context ): Type =
13541354 qtype.asInstanceOf [scala.internal.quoted.Type [TypeTree ]].typeTree.tpe
13551355
1356- def apply (clazz : Class [_])(using ctx : Context ): Type =
1357- reflectSelf.Type_apply (clazz)
13581356 end Type
13591357
13601358 given TypeOps as AnyRef :
You can’t perform that action at this time.
0 commit comments