Skip to content

Commit d49b293

Browse files
Fix #7046: Literal types don't work with quotes
1 parent ff43160 commit d49b293

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ class ReifyQuotes extends MacroTransform {
230230
def pickleAsTasty() = {
231231
val meth =
232232
if (isType) ref(defn.Unpickler_unpickleType).appliedToType(originalTp)
233-
else ref(defn.Unpickler_unpickleExpr).appliedToType(originalTp.widen)
233+
else ref(defn.Unpickler_unpickleExpr).appliedToType(originalTp)
234234
val spliceResType =
235235
if (isType) defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)
236236
else defn.FunctionType(1, isContextual = true).appliedTo(defn.QuoteContextClass.typeRef, defn.QuotedExprClass.typeRef.appliedTo(defn.AnyType)) | defn.QuotedTypeClass.typeRef.appliedTo(WildcardType)
@@ -244,10 +244,7 @@ class ReifyQuotes extends MacroTransform {
244244
if (splices.isEmpty && body.symbol.isPrimitiveValueClass) tag(s"${body.symbol.name}Tag")
245245
else pickleAsTasty().select(nme.apply).appliedTo(qctx)
246246
}
247-
else toValue(body) match {
248-
case Some(value) => pickleAsValue(value)
249-
case _ => pickleAsTasty()
250-
}
247+
else pickleAsTasty()
251248
}
252249

253250
/** If inside a quote, split the body of the splice into a core and a list of embedded quotes

tests/pos/i7046.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+
inline def mcr: Any = ${mcrImpl}
4+
def mcrImpl given (ctx: QuoteContext): Expr[Any] = {
5+
val tpl: Expr[1] = '{1}
6+
'{()}
7+
}

0 commit comments

Comments
 (0)