File tree 4 files changed +21
-7
lines changed
compiler/src/dotty/tools/dotc/transform
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:
209
209
// Dealias references to captured types
210
210
TypeTree (tree.tpe.dealias)
211
211
else super .transform(tree)
212
- case tree : TypeTree =>
212
+ case _ : TypeTree | _ : SingletonTypeTree =>
213
213
if containsCapturedType(tree.tpe) && level >= 1 then getTagRefFor(tree)
214
214
else tree
215
215
case tree @ Assign (lhs : RefTree , rhs) =>
@@ -314,10 +314,7 @@ class Splicing extends MacroTransform:
314
314
)
315
315
316
316
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
321
318
322
319
private def capturedPartTypes (quote : Quote )(using Context ): Tree =
323
320
val (tags, body1) = inContextWithQuoteTypeTags {
Original file line number Diff line number Diff line change @@ -727,7 +727,7 @@ object TreeChecker {
727
727
// Check that we only add the captured type `T` instead of a more complex type like `List[T]`.
728
728
// If we have `F[T]` with captured `F` and `T`, we should list `F` and `T` separately in the args.
729
729
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 ] || arg.tpe. isInstanceOf [ TermRef ] || arg.tpe. isInstanceOf [ ThisType ] , " Expected TypeRef in Hole type args but got: " + arg.tpe)
731
731
732
732
// Check result type of the hole
733
733
if isTerm then assert(tree1.typeOpt <:< pt)
@@ -743,7 +743,7 @@ object TreeChecker {
743
743
defn.AnyType
744
744
case tpe => tpe
745
745
defn.QuotedExprClass .typeRef.appliedTo(tpe)
746
- else defn.QuotedTypeClass .typeRef.appliedTo(arg.typeOpt.widenTermRefExpr )
746
+ else defn.QuotedTypeClass .typeRef.appliedTo(arg.typeOpt)
747
747
}
748
748
val expectedResultType =
749
749
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