Skip to content

Commit 858b53b

Browse files
committed
Workaround #4987
1 parent 62c41a2 commit 858b53b

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ class ReifyQuotes extends MacroTransform {
167167
def pickleAsTasty() = {
168168
val meth =
169169
if (isType) ref(defn.Unpickler_unpickleType).appliedToType(originalTp)
170-
else ref(defn.Unpickler_unpickleExpr).appliedToType(originalTp.widen.dealias)
170+
else
171+
val tpe =
172+
if originalTp =:= defn.NilModule.termRef then originalTp // Workaround #4987
173+
else originalTp.widen.dealias
174+
ref(defn.Unpickler_unpickleExpr).appliedToType(tpe)
171175
val pickledQuoteStrings = liftList(PickledQuotes.pickleQuote(body).map(x => Literal(Constant(x))), defn.StringType)
172176
val splicesList = liftList(splices, defn.FunctionType(1).appliedTo(defn.SeqType.appliedTo(defn.AnyType), defn.AnyType))
173177
meth.appliedTo(pickledQuoteStrings, splicesList)

tests/pos-macros/nil-liftable.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted._
2+
3+
class Test:
4+
given NilIsLiftable as Liftable[Nil.type] = new Liftable[Nil.type] {
5+
def toExpr(xs: Nil.type): QuoteContext ?=> Expr[Nil.type] =
6+
'{ Nil }
7+
}

0 commit comments

Comments
 (0)