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
1128
1128
case _ => None
1129
1129
}
1130
1130
1131
- def Type_apply (clazz : Class [? ])(using Context ): Type =
1131
+ def Type_ofErasedClass (clazz : Class [? ])(using Context ): Type =
1132
1132
if (clazz.isPrimitive)
1133
1133
if (clazz == classOf [Boolean ]) defn.BooleanType
1134
1134
else if (clazz == classOf [Byte ]) defn.ByteType
@@ -1140,10 +1140,10 @@ class ReflectionCompilerInterface(val rootContext: Context) extends CompilerInte
1140
1140
else if (clazz == classOf [Double ]) defn.DoubleType
1141
1141
else defn.UnitType
1142
1142
else if (clazz.isArray)
1143
- defn.ArrayType .appliedTo(Type_apply (clazz.getComponentType))
1143
+ defn.ArrayType .appliedTo(Type_ofErasedClass (clazz.getComponentType))
1144
1144
else if (clazz.isMemberClass) {
1145
1145
val name = clazz.getSimpleName.toTypeName
1146
- val enclosing = Type_apply (clazz.getEnclosingClass)
1146
+ val enclosing = Type_ofErasedClass (clazz.getEnclosingClass)
1147
1147
if (enclosing.member(name).exists) enclosing.select(name)
1148
1148
else
1149
1149
enclosing.classSymbol.companionModule.termRef.select(name)
Original file line number Diff line number Diff line change @@ -58,9 +58,11 @@ object Liftable {
58
58
59
59
/** Default liftable for Class[T] */
60
60
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 ]]]
64
66
}
65
67
}
66
68
Original file line number Diff line number Diff line change @@ -512,7 +512,11 @@ trait CompilerInterface extends scala.tasty.reflect.Types {
512
512
513
513
def Type_TypeTest (using ctx : Context ): TypeTest [Type , Type ]
514
514
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
516
520
517
521
/** Is `self` type the same as `that` type?
518
522
* 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 =>
1353
1353
def of [T <: AnyKind ](using qtype : scala.quoted.Type [T ], ctx : Context ): Type =
1354
1354
qtype.asInstanceOf [scala.internal.quoted.Type [TypeTree ]].typeTree.tpe
1355
1355
1356
- def apply (clazz : Class [_])(using ctx : Context ): Type =
1357
- reflectSelf.Type_apply (clazz)
1358
1356
end Type
1359
1357
1360
1358
given TypeOps as AnyRef :
You can’t perform that action at this time.
0 commit comments