From 0949d5e33cf8f64da43433549f8a7b7e69cd6c45 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Fri, 14 Jun 2024 09:48:38 +0100 Subject: [PATCH] Give DerivedFromParamTree#ensureCompletions an example --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index b1b771bc7512..5dbeafd352e9 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -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 _ => }