Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,9 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
case Quoted(quotedTree) =>
quotation(quotedTree, tree)
case tree: TypeTree if tree.tpe.typeSymbol.isSplice =>
val splicedType = tree.tpe.asInstanceOf[TypeRef].prefix.termSymbol
splice(ref(splicedType).select(tpnme.UNARY_~))
val splicedType = tree.tpe.stripTypeVar.asInstanceOf[TypeRef].prefix.termSymbol
if (levelOf.get(splicedType).contains(level)) tree
else splice(ref(splicedType).select(tpnme.UNARY_~))
case tree: Select if tree.symbol.isSplice =>
splice(tree)
case tree: RefTree if isCaptured(tree.symbol, level) =>
Expand Down
11 changes: 11 additions & 0 deletions tests/neg/i4774b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import scala.quoted._

object Test {
def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] = '{
val y: ~t = ~x;
~loop[~t]( // error
'(y)
)
}
}
7 changes: 7 additions & 0 deletions tests/pos/i4774.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

import scala.quoted._

object Test {
def loop[T](x: Expr[T])(implicit t: Type[T]): Expr[T] =
'{ val y: ~t = ~x; ~loop('(y)) }
}