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 @@ -698,7 +698,7 @@ object TreeChecker {
698
698
// Check that we only add the captured type `T` instead of a more complex type like `List[T]`.
699
699
// If we have `F[T]` with captured `F` and `T`, we should list `F` and `T` separately in the args.
700
700
for arg <- args do
701
- assert(arg.isTerm || arg.tpe.isInstanceOf [TypeRef ], " Expected TypeRef in Hole type args but got : " + arg.tpe)
701
+ assert(arg.isTerm || arg.tpe.isInstanceOf [TypeRef | TermRef | ThisType ], " Unexpected type arg in Hole : " + arg.tpe)
702
702
703
703
// Check result type of the hole
704
704
if isTerm then assert(tree1.typeOpt <:< pt)
@@ -714,7 +714,7 @@ object TreeChecker {
714
714
defn.AnyType
715
715
case tpe => tpe
716
716
defn.QuotedExprClass .typeRef.appliedTo(tpe)
717
- else defn.QuotedTypeClass .typeRef.appliedTo(arg.typeOpt.widenTermRefExpr )
717
+ else defn.QuotedTypeClass .typeRef.appliedTo(arg.typeOpt)
718
718
}
719
719
val expectedResultType =
720
720
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