File tree 3 files changed +44
-5
lines changed
compiler/src/dotty/tools/dotc/transform
3 files changed +44
-5
lines changed Original file line number Diff line number Diff line change @@ -66,8 +66,14 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
66
66
checkAnnotations(tree)
67
67
super .transform(tree)
68
68
else tree match {
69
-
70
- case _ : TypeTree | _ : RefTree if tree.isType =>
69
+ case tree : TypeTree =>
70
+ val tree1 = treeify(tree)
71
+ if tree ne tree1 then transform(tree1.withSpan(tree.span))
72
+ else
73
+ val healedType = healType(tree.srcPos)(tree.tpe)
74
+ if healedType == tree.tpe then tree
75
+ else TypeTree (healedType).withSpan(tree.span)
76
+ case _ : RefTree if tree.isType =>
71
77
val healedType = healType(tree.srcPos)(tree.tpe)
72
78
if healedType == tree.tpe then tree
73
79
else TypeTree (healedType).withSpan(tree.span)
@@ -275,6 +281,18 @@ class PCPCheckAndHeal(@constructorOnly ictx: Context) extends TreeMapWithStages(
275
281
tp
276
282
}
277
283
284
+ /** Transform a TypeTree into a tree that contains the structure of the type */
285
+ private def treeify (tree : TypeTree )(using Context ): Tree =
286
+ tree.tpe.stripTypeVar.dealias match
287
+ case tpe @ TypeRef (path : TermRef , _) =>
288
+ // Expand TypeTree(`x.T`) to Select(`x`, `T`)
289
+ // Needed in PickleQuotes in case x refers to a captured reference.
290
+ ref(path).select(tpe)
291
+ case AppliedType (tycon, args) =>
292
+ AppliedTypeTree (treeify(TypeTree (tycon)), args.map(TypeTree ))
293
+ case _ =>
294
+ tree
295
+
278
296
}
279
297
280
298
object PCPCheckAndHeal {
Original file line number Diff line number Diff line change
1
+ import scala .quoted .*
2
+
3
+ trait Mirror :
4
+ type ElemTypes <: Tuple
5
+
6
+ class Eq :
7
+
8
+ def test1 (using Quotes ): Unit = ' {
9
+ val m : Mirror = ???
10
+ $ { summonType[m.ElemTypes ]; ??? }
11
+ $ { summonType[List [m.ElemTypes ]]; ??? }
12
+ }
13
+
14
+ def test2 (using Quotes ): Unit = ' {
15
+ val m : Mirror = ???
16
+ type ET = m.ElemTypes
17
+ $ { summonType[ET ]; ??? }
18
+ $ { summonType[List [ET ]]; ??? }
19
+ }
20
+
21
+ def summonType [X ](using Type [X ]) = ???
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ def f[T: Type](using Quotes) =
14
14
$ { g[m.E ](using Type .of[ME ]) }
15
15
$ { g[ME ](using Type .of[m.E ]) }
16
16
$ { g[m.E ](using Type .of[m.E ]) }
17
- // ${ g[ME] } // FIXME: issue seems to be in PickleQuotes
18
- // ${ g[m.E] } // FIXME: issue seems to be in PickleQuotes
17
+ $ { g[ME ] }
18
+ $ { g[m.E ] }
19
19
}
20
20
21
- def g [T ](using Type [T ]) = ???
21
+ def g [T ](using Type [T ]) = ???
You can’t perform that action at this time.
0 commit comments