Skip to content

Commit 564980d

Browse files
committed
fix: update the correct unit when building a new unit
1 parent d5fec8f commit 564980d

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

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

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,8 @@ object CompilationUnit {
148148
assert(!unpickled.isEmpty, unpickled)
149149
val unit1 = new CompilationUnit(source, info)
150150
unit1.tpdTree = unpickled
151-
if (forceTrees) {
152-
val force = new Force
153-
force.traverse(unit1.tpdTree)
154-
unit1.needsStaging = force.containsQuote
155-
unit1.needsInlining = force.containsInline
156-
unit1.hasMacroAnnotations = force.containsMacroAnnotation
157-
}
151+
if forceTrees then
152+
Force.traverse(unit1.tpdTree)(using ctx.fresh.setCompilationUnit(unit1))
158153
unit1
159154
}
160155

@@ -187,19 +182,15 @@ object CompilationUnit {
187182
}
188183

189184
/** Force the tree to be loaded */
190-
private class Force extends TreeTraverser {
191-
var containsQuote = false
192-
var containsInline = false
193-
var containsCaptureChecking = false
194-
var containsMacroAnnotation = false
185+
private object Force extends TreeTraverser {
195186
def traverse(tree: Tree)(using Context): Unit = {
196187
if tree.symbol.is(Flags.Inline) then
197-
containsInline = true
188+
ctx.compilationUnit.needsStaging = true
198189
tree match
199190
case _: tpd.Quote =>
200-
containsQuote = true
191+
ctx.compilationUnit.needsStaging = true
201192
case tree: tpd.Apply if tree.symbol == defn.QuotedTypeModule_of =>
202-
containsQuote = true
193+
ctx.compilationUnit.needsStaging = true
203194
case Import(qual, selectors) =>
204195
tpd.languageImport(qual) match
205196
case Some(prefix) =>

tests/pos/i24519.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.language.experimental.captureChecking
2+
3+
trait File extends caps.SharedCapability
4+
5+
class Foo:
6+
def f(file: File^): Iterator[File]^{file} =
7+
Iterator.from(List(file))

0 commit comments

Comments
 (0)