Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 6 additions & 15 deletions compiler/src/dotty/tools/dotc/CompilationUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,8 @@ object CompilationUnit {
assert(!unpickled.isEmpty, unpickled)
val unit1 = new CompilationUnit(source, info)
unit1.tpdTree = unpickled
if (forceTrees) {
val force = new Force
force.traverse(unit1.tpdTree)
unit1.needsStaging = force.containsQuote
unit1.needsInlining = force.containsInline
unit1.hasMacroAnnotations = force.containsMacroAnnotation
}
if forceTrees then
Force.traverse(unit1.tpdTree)(using ctx.fresh.setCompilationUnit(unit1))
unit1
}

Expand Down Expand Up @@ -187,19 +182,15 @@ object CompilationUnit {
}

/** Force the tree to be loaded */
private class Force extends TreeTraverser {
var containsQuote = false
var containsInline = false
var containsCaptureChecking = false
var containsMacroAnnotation = false
private object Force extends TreeTraverser {
def traverse(tree: Tree)(using Context): Unit = {
if tree.symbol.is(Flags.Inline) then
containsInline = true
ctx.compilationUnit.needsInlining = true
tree match
case _: tpd.Quote =>
containsQuote = true
ctx.compilationUnit.needsStaging = true
case tree: tpd.Apply if tree.symbol == defn.QuotedTypeModule_of =>
containsQuote = true
ctx.compilationUnit.needsStaging = true
case Import(qual, selectors) =>
tpd.languageImport(qual) match
case Some(prefix) =>
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i24519.scala
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dotty.tools.dotc.FromTastyTests will run this test too.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.language.experimental.captureChecking

trait File extends caps.SharedCapability

class Foo:
def f(file: File^): Iterator[File]^{file} =
Iterator.from(List(file))
Loading