Skip to content

Commit d35a5d7

Browse files
committed
Use Lambda constuctor
1 parent 87411b5 commit d35a5d7

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,9 @@ class ReifyQuotes extends MacroTransform {
155155
*/
156156
def pickleAsLiteral(lit: Literal) = {
157157
val exprType = defn.QuotedExprClass.typeRef.appliedTo(body.tpe)
158-
val tpe = MethodType(defn.QuoteContextClass.typeRef :: Nil, exprType)
159-
val meth = newSymbol(ctx.owner, UniqueName.fresh(nme.ANON_FUN), Synthetic | Method, tpe)
160-
def mkConst(tss: List[List[Tree]]) = {
161-
val reflect = tss.head.head.select("reflect".toTermName)
158+
val lambdaTpe = MethodType(defn.QuoteContextClass.typeRef :: Nil, exprType)
159+
def mkConst(ts: List[Tree]) = {
160+
val reflect = ts.head.select("reflect".toTermName)
162161
val typeName = body.tpe.typeSymbol.name
163162
val literalValue =
164163
if lit.const.tag == Constants.NullTag || lit.const.tag == Constants.UnitTag then Nil
@@ -167,7 +166,7 @@ class ReifyQuotes extends MacroTransform {
167166
val literal = reflect.select("Literal".toTermName).select(nme.apply).appliedTo(constant)
168167
reflect.select("TreeMethods".toTermName).select("asExpr".toTermName).appliedTo(literal).asInstance(exprType)
169168
}
170-
Closure(meth, mkConst).withSpan(body.span)
169+
Lambda(lambdaTpe, mkConst).withSpan(body.span)
171170
}
172171

173172
def pickleAsValue(lit: Literal) = {
@@ -229,14 +228,13 @@ class ReifyQuotes extends MacroTransform {
229228
def taggedType() =
230229
val typeType = defn.QuotedTypeClass.typeRef.appliedTo(body.tpe)
231230
val classTree = TypeApply(ref(defn.Predef_classOf.termRef), body :: Nil)
232-
val tpe = MethodType(defn.QuoteContextClass.typeRef :: Nil, typeType)
233-
val meth = newSymbol(ctx.owner, UniqueName.fresh(nme.ANON_FUN), Synthetic | Method, tpe)
234-
def mkConst(tss: List[List[Tree]]) = {
235-
val reflect = tss.head.head.select("reflect".toTermName)
231+
val lambdaTpe = MethodType(defn.QuoteContextClass.typeRef :: Nil, typeType)
232+
def callTypeConstructorOf(ts: List[Tree]) = {
233+
val reflect = ts.head.select("reflect".toTermName)
236234
val typeRepr = reflect.select("TypeRepr".toTermName).select("typeConstructorOf".toTermName).appliedTo(classTree)
237235
reflect.select("TypeReprMethods".toTermName).select("asType".toTermName).appliedTo(typeRepr).asInstance(typeType)
238236
}
239-
Closure(meth, mkConst).withSpan(body.span)
237+
Lambda(lambdaTpe, callTypeConstructorOf).withSpan(body.span)
240238

241239
if (isType) {
242240
if (splices.isEmpty && body.symbol.isPrimitiveValueClass) taggedType()

0 commit comments

Comments
 (0)