Skip to content

Commit 2065a38

Browse files
committed
Fix compiling quote in file with no splices
1 parent b1cc305 commit 2065a38

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

compiler/src/dotty/tools/dotc/CompilationUnit.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import dotty.tools.dotc.ast.tpd.{ Tree, TreeTraverser }
88
import dotty.tools.dotc.core.Contexts.Context
99
import dotty.tools.dotc.core.SymDenotations.ClassDenotation
1010
import dotty.tools.dotc.core.Symbols._
11+
import dotty.tools.dotc.transform.SymUtils._
1112

1213
class CompilationUnit(val source: SourceFile) {
1314

@@ -39,13 +40,21 @@ object CompilationUnit {
3940
assert(!unpickled.isEmpty, unpickled)
4041
val unit1 = new CompilationUnit(source)
4142
unit1.tpdTree = unpickled
42-
if (forceTrees)
43+
if (forceTrees) {
44+
val force = new Force
4345
force.traverse(unit1.tpdTree)
46+
unit1.containsQuotesOrSplices = force.containsQuotes
47+
}
4448
unit1
4549
}
4650

4751
/** Force the tree to be loaded */
48-
private object force extends TreeTraverser {
49-
def traverse(tree: Tree)(implicit ctx: Context): Unit = traverseChildren(tree)
52+
private class Force extends TreeTraverser {
53+
var containsQuotes = false
54+
def traverse(tree: Tree)(implicit ctx: Context): Unit = {
55+
if (tree.symbol.isQuote)
56+
containsQuotes = true
57+
traverseChildren(tree)
58+
}
5059
}
5160
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
180180
override def transform(tree: Tree)(implicit ctx: Context): Tree =
181181
try tree match {
182182
case tree: Ident if !tree.isType =>
183+
handleMeta(tree.symbol)
183184
tree.tpe match {
184185
case tpe: ThisType => This(tpe.cls).withPos(tree.pos)
185186
case _ => tree
@@ -203,9 +204,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
203204
// might be a type constructor.
204205
Checking.checkInstantiable(tree.tpe, nu.pos)
205206
withNoCheckNews(nu :: Nil)(super.transform(tree))
206-
case meth =>
207-
if (meth.symbol.isQuote)
208-
ctx.compilationUnit.containsQuotesOrSplices = true
207+
case _ =>
209208
super.transform(tree)
210209
}
211210
case tree: TypeApply =>

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ class FromTastyTests extends ParallelTesting {
3838
"i3000.scala",
3939
"i536.scala",
4040
"i974.scala",
41-
"quote-liftable.scala",
42-
"quote-0.scala",
43-
"quote-1.scala",
44-
"quote-stagedInterpreter.scala",
4541
"superacc.scala",
4642
"t0231.scala",
4743
"t1203a.scala",
@@ -52,7 +48,6 @@ class FromTastyTests extends ParallelTesting {
5248
"t8023.scala",
5349
"tcpoly_ticket2096.scala",
5450
"t247.scala",
55-
"quote-no-splices.scala",
5651
)
5752
)
5853
step1.checkCompile() // Compile all files to generate the class files with tasty

0 commit comments

Comments
 (0)