Skip to content

Commit 7d2c1cc

Browse files
committed
Detect all quotes in postyper
* Explicit * Synthesized implicits * Inlined
1 parent 1c19629 commit 7d2c1cc

File tree

4 files changed

+4
-12
lines changed

4 files changed

+4
-12
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
269269
val patterns1 = transform(patterns)
270270
cpy.UnApply(tree)(transform(fun), transform(implicits), patterns1)
271271
case tree: TypeApply =>
272+
if tree.symbol.isQuote then
273+
ctx.compilationUnit.needsStaging = true
272274
val tree1 @ TypeApply(fn, args) = normalizeTypeArgs(tree)
273275
args.foreach(checkInferredWellFormed)
274276
if (fn.symbol != defn.ChildAnnot.primaryConstructor)

compiler/src/dotty/tools/dotc/typer/Inliner.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
11921192
}
11931193

11941194
override def typedIdent(tree: untpd.Ident, pt: Type)(using Context): Tree =
1195-
checkStaging(tryInline(tree.asInstanceOf[tpd.Tree]) `orElse` super.typedIdent(tree, pt))
1195+
tryInline(tree.asInstanceOf[tpd.Tree]) `orElse` super.typedIdent(tree, pt)
11961196

11971197
override def typedSelect(tree: untpd.Select, pt: Type)(using Context): Tree = {
11981198
assert(tree.hasType, tree)
@@ -1204,14 +1204,9 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(using Context) {
12041204
else
12051205
val res = resMaybeReduced
12061206
ensureAccessible(res.tpe, tree.qualifier.isInstanceOf[untpd.Super], tree.sourcePos)
1207-
checkStaging(res)
1207+
res
12081208
}
12091209

1210-
private def checkStaging(tree: Tree): tree.type =
1211-
if tree.symbol.isQuote then
1212-
ctx.compilationUnit.needsStaging = true
1213-
tree
1214-
12151210
override def typedIf(tree: untpd.If, pt: Type)(using Context): Tree =
12161211
typed(tree.cond, defn.BooleanType) match {
12171212
case cond1 @ ConstantValue(b: Boolean) =>

compiler/src/dotty/tools/dotc/typer/QuotesAndSplices.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ trait QuotesAndSplices {
4040
*/
4141
def typedQuote(tree: untpd.Quote, pt: Type)(using Context): Tree = {
4242
record("typedQuote")
43-
ctx.compilationUnit.needsStaging = true
4443
tree.quoted match {
4544
case untpd.Splice(innerExpr) if tree.isTerm =>
4645
report.warning("Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ.", tree.sourcePos)
@@ -68,7 +67,6 @@ trait QuotesAndSplices {
6867
/** Translate `${ t: Expr[T] }` into expression `t.splice` while tracking the quotation level in the context */
6968
def typedSplice(tree: untpd.Splice, pt: Type)(using Context): Tree = {
7069
record("typedSplice")
71-
ctx.compilationUnit.needsStaging = true
7270
checkSpliceOutsideQuote(tree)
7371
tree.expr match {
7472
case untpd.Quote(innerExpr) if innerExpr.isTerm =>
@@ -147,7 +145,6 @@ trait QuotesAndSplices {
147145
/** Translate ${ t: Type[T] }` into type `t.splice` while tracking the quotation level in the context */
148146
def typedTypSplice(tree: untpd.TypSplice, pt: Type)(using Context): Tree = {
149147
record("typedTypSplice")
150-
ctx.compilationUnit.needsStaging = true
151148
checkSpliceOutsideQuote(tree)
152149
tree.expr match {
153150
case untpd.Quote(innerType) if innerType.isType =>

compiler/src/dotty/tools/dotc/typer/Synthesizer.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
5353
*/
5454
val synthesizedTypeTag: SpecialHandler = (formal, span) =>
5555
def quotedType(t: Type) =
56-
if StagingContext.level == 0 then
57-
ctx.compilationUnit.needsStaging = true // We will need to run ReifyQuotes
5856
val qctx = ctx.typer.inferImplicitArg(defn.QuoteContextClass.typeRef, span)
5957
qctx.tpe match
6058
case tpe: Implicits.SearchFailureType => report.error(tpe.msg, ctx.source.atSpan(span))

0 commit comments

Comments
 (0)