Skip to content

Commit 40b8801

Browse files
committed
Fix handling of top level Type.Underlying references
1 parent bb96180 commit 40b8801

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ class ReifyQuotes extends MacroTransform {
7777
case tree: RefTree if !Inliner.inInlineMethod =>
7878
assert(!tree.symbol.isQuote)
7979
assert(!tree.symbol.isExprSplice)
80-
assert(!tree.symbol.isTypeSplice)
8180
case _ : TypeDef =>
8281
assert(!tree.symbol.hasAnnotation(defn.InternalQuoted_QuoteTypeTagAnnot),
8382
s"${tree.symbol} should have been removed by PickledQuotes because it has a @quoteTypeTag")
@@ -210,16 +209,15 @@ class ReifyQuotes extends MacroTransform {
210209
* are in the body of an inline method.
211210
*/
212211
protected def transformSpliceType(body: Tree, splice: Select)(using Context): Tree =
213-
if (level > 1) {
212+
if level > 1 then
214213
val body1 = nested(isQuote = false).transform(body)(using spliceContext)
215214
cpy.Select(splice)(body1, splice.name)
216-
}
217-
else {
218-
assert(level == 1, "unexpected top splice outside quote")
215+
else if level == 1 then
219216
val (body1, quotes) = nested(isQuote = false).splitSplice(body)(using spliceContext)
220217
val tpe = outer.embedded.getHoleType(body, splice)
221218
makeHole(splice.isTerm, body1, quotes, tpe).withSpan(splice.span)
222-
}
219+
else
220+
splice
223221

224222
/** Transforms the contents of a nested splice
225223
* Assuming

tests/neg-macros/i4774b.scala renamed to tests/pos-macros/i4774b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.quoted._
44
object Test {
55
def loop[T](x: Expr[T])(implicit t: Type[T], qctx: QuoteContext): Expr[T] = '{
66
val y: t.Underlying = $x;
7-
${loop[t.Underlying]( // error
7+
${loop[t.Underlying](
88
'y
99
)}
1010
}

0 commit comments

Comments
 (0)