@@ -141,30 +141,31 @@ object SymDenotations {
141141 }
142142
143143 final def completeFrom (completer : LazyType )(using Context ): Unit =
144- if (Config .showCompletions) {
145- println(i " ${" " * indent}completing ${if (isType) " type" else " val" } $name" )
146- indent += 1
147-
148- if (myFlags.is(Touched )) throw CyclicReference (this )
149- myFlags |= Touched
150-
151- // completions.println(s"completing ${this.debugString}")
152- try atPhase(validFor.firstPhaseId)(completer.complete(this ))
153- catch {
154- case ex : CyclicReference =>
155- println(s " error while completing ${this .debugString}" )
156- throw ex
144+ if completer.needsCompletion(this ) then
145+ if (Config .showCompletions) {
146+ println(i " ${" " * indent}completing ${if (isType) " type" else " val" } $name" )
147+ indent += 1
148+
149+ if (myFlags.is(Touched )) throw CyclicReference (this )
150+ myFlags |= Touched
151+
152+ // completions.println(s"completing ${this.debugString}")
153+ try atPhase(validFor.firstPhaseId)(completer.complete(this ))
154+ catch {
155+ case ex : CyclicReference =>
156+ println(s " error while completing ${this .debugString}" )
157+ throw ex
158+ }
159+ finally {
160+ indent -= 1
161+ println(i " ${" " * indent}completed $name in $owner" )
162+ }
157163 }
158- finally {
159- indent -= 1
160- println(i " ${" " * indent}completed $name in $owner" )
164+ else {
165+ if (myFlags.is(Touched )) throw CyclicReference (this )
166+ myFlags |= Touched
167+ atPhase(validFor.firstPhaseId)(completer.complete(this ))
161168 }
162- }
163- else {
164- if (myFlags.is(Touched )) throw CyclicReference (this )
165- myFlags |= Touched
166- atPhase(validFor.firstPhaseId)(completer.complete(this ))
167- }
168169
169170 protected [dotc] def info_= (tp : Type ): Unit = {
170171 /* // DEBUG
@@ -2517,6 +2518,13 @@ object SymDenotations {
25172518 def withModuleClass (moduleClassFn : Context ?=> Symbol ): this .type = { myModuleClassFn = moduleClassFn; this }
25182519
25192520 override def toString : String = getClass.toString
2521+
2522+ /** A hook that is called before trying to complete a symbol with its
2523+ * associated cycle detection via the Touched flag. This is overridden
2524+ * for Type definitions in Namer, where we make sure that owners are
2525+ * completed before nested types.
2526+ */
2527+ def needsCompletion (symd : SymDenotation )(using Context ): Boolean = true
25202528 }
25212529
25222530 object LazyType :
0 commit comments