Skip to content

Commit 3097f49

Browse files
committed
Simplify quoted type transformation in CrossStageSafety
1 parent 10cbc60 commit 3097f49

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ class CrossStageSafety extends TreeMapWithStages {
5252
transform(tree)(using ctx.withSource(tree.source))
5353
else if !inQuoteOrSpliceScope then
5454
checkAnnotations(tree)
55-
super.transform(tree)
55+
tree match
56+
case tree @ QuotedTypeOf(quotedTree) =>
57+
transformQuotedType(quotedTree, tree)
58+
case _ => super.transform(tree)
5659
else tree match {
5760
case _: TypeTree =>
5861
val tp1 = transformTypeAnnotationSplices(tree.tpe)
@@ -92,6 +95,8 @@ class CrossStageSafety extends TreeMapWithStages {
9295
case tree: TypeDef if tree.symbol.is(Case) && level > 0 =>
9396
report.error(reporting.CaseClassInInlinedCode(tree), tree)
9497
super.transform(tree)
98+
case tree @ QuotedTypeOf(quotedTree) =>
99+
transformQuotedType(quotedTree, tree)
95100
case tree @ SplicedType(splicedTree) =>
96101
transformSpliceType(splicedTree, tree)
97102
case _ =>
@@ -109,7 +114,7 @@ class CrossStageSafety extends TreeMapWithStages {
109114
cpy.Quote(quote)(transformedBody).withBodyType(bodyType1)
110115
}
111116

112-
override protected def transformQuotedType(body: Tree, quote: Apply)(using Context): Tree = {
117+
private def transformQuotedType(body: Tree, quote: Apply)(using Context): Tree = {
113118
if (ctx.property(InAnnotation).isDefined)
114119
report.error("Cannot have a quote in an annotation", quote.srcPos)
115120
body.tpe match

compiler/src/dotty/tools/dotc/staging/TreeMapWithStages.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ abstract class TreeMapWithStages extends TreeMapWithImplicits {
2222
protected def transformQuote(body: Tree, quote: Quote)(using Context): Tree =
2323
cpy.Quote(quote)(body)
2424

25-
/** Transform the quote `quote` which contains the quoted `body`.
26-
*
27-
* - `quoted.Type.of[<body0>](quotes)` --> `quoted.Type.of[<body>](quotes)`
28-
*/
29-
protected def transformQuotedType(body: Tree, quote: Apply)(using Context): Tree =
30-
val TypeApply(fun, _) = quote.fun: @unchecked
31-
cpy.Apply(quote)(cpy.TypeApply(quote.fun)(fun, body :: Nil), quote.args)
32-
3325
/** Transform the expression splice `splice` which contains the spliced `body`. */
3426
protected def transformSplice(body: Tree, splice: Splice)(using Context): Tree
3527

@@ -43,8 +35,6 @@ abstract class TreeMapWithStages extends TreeMapWithImplicits {
4335
}
4436

4537
tree match {
46-
case tree @ QuotedTypeOf(quotedTree) =>
47-
transformQuotedType(quotedTree, tree)
4838
case tree @ Quote(quotedTree) =>
4939
dropEmptyBlocks(quotedTree) match {
5040
case Splice(t) =>

0 commit comments

Comments
 (0)