Skip to content

Commit

Permalink
Give DerivedFromParamTree#ensureCompletions an example
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Jun 14, 2024
1 parent 7bdeb0b commit 0949d5e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,18 @@ object desugar {
def completeConstructor(sym: Symbol) =
sym.infoOrCompleter match {
case completer: Namer#ClassCompleter =>
// An example, derived from tests/run/t6385.scala
//
// class Test():
// def t1: Foo = Foo(1)
// final case class Foo(value: Int)
//
// Here's the sequence of events:
// * The symbol for Foo.apply is forced to complete
// * The symbol for the `value` parameter of the apply method is forced to complete
// * Completing that value parameter requires typing its type, which is a DerivedTypeTrees,
// which only types if it has an OriginalSymbol.
// * So if the case class hasn't been completed, we need (at least) its constructor to be completed
completer.completeConstructor(sym)
case _ =>
}
Expand Down

0 comments on commit 0949d5e

Please sign in to comment.