File tree Expand file tree Collapse file tree 4 files changed +21
-7
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 4 files changed +21
-7
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ class Splicing extends MacroTransform:
209209 // Dealias references to captured types
210210 TypeTree (tree.tpe.dealias)
211211 else super .transform(tree)
212- case tree : TypeTree =>
212+ case _ : TypeTree | _ : SingletonTypeTree =>
213213 if containsCapturedType(tree.tpe) && level >= 1 then getTagRefFor(tree)
214214 else tree
215215 case tree @ Assign (lhs : RefTree , rhs) =>
@@ -314,10 +314,7 @@ class Splicing extends MacroTransform:
314314 )
315315
316316 private def capturedType (tree : Tree )(using Context ): Symbol =
317- val tpe = tree.tpe.widenTermRefExpr
318- val bindingSym = refBindingMap
319- .getOrElseUpdate(tree.symbol, (TypeTree (tree.tpe), newQuotedTypeClassBinding(tpe)))._2
320- bindingSym
317+ refBindingMap.getOrElseUpdate(tree.symbol, (TypeTree (tree.tpe), newQuotedTypeClassBinding(tree.tpe)))._2
321318
322319 private def capturedPartTypes (quote : Quote )(using Context ): Tree =
323320 val (tags, body1) = inContextWithQuoteTypeTags {
Original file line number Diff line number Diff line change @@ -727,7 +727,7 @@ object TreeChecker {
727727 // Check that we only add the captured type `T` instead of a more complex type like `List[T]`.
728728 // If we have `F[T]` with captured `F` and `T`, we should list `F` and `T` separately in the args.
729729 for arg <- args do
730- assert(arg.isTerm || arg.tpe.isInstanceOf [TypeRef ], " Expected TypeRef in Hole type args but got : " + arg.tpe)
730+ assert(arg.isTerm || arg.tpe.isInstanceOf [TypeRef | TermRef | ThisType ], " Unexpected type arg in Hole : " + arg.tpe)
731731
732732 // Check result type of the hole
733733 if isTerm then assert(tree1.typeOpt <:< pt)
@@ -743,7 +743,7 @@ object TreeChecker {
743743 defn.AnyType
744744 case tpe => tpe
745745 defn.QuotedExprClass .typeRef.appliedTo(tpe)
746- else defn.QuotedTypeClass .typeRef.appliedTo(arg.typeOpt.widenTermRefExpr )
746+ else defn.QuotedTypeClass .typeRef.appliedTo(arg.typeOpt)
747747 }
748748 val expectedResultType =
749749 if isTerm then defn.QuotedExprClass .typeRef.appliedTo(tree1.typeOpt)
Original file line number Diff line number Diff line change 1+ import scala .quoted .*
2+
3+ inline def test = $ { testExpr }
4+
5+ def testExpr (using Quotes ): Expr [Unit ] =
6+ ' {
7+ trait C
8+ val c : C = ???
9+ $ {
10+ val expr = ' {
11+ val cRef : c.type = ???
12+ ()
13+ }
14+ expr
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ def Test = test
You can’t perform that action at this time.
0 commit comments