@@ -155,8 +155,14 @@ abstract class Recheck extends Phase, SymTransformer:
155155 */
156156 def keepType (tree : Tree ): Boolean = keepAllTypes
157157
158+ /** A map from NamedTypes to the denotations they had before this phase.
159+ * Needed so that we can `reset` them after this phase.
160+ */
158161 private val prevSelDenots = util.HashMap [NamedType , Denotation ]()
159162
163+ /** Reset all references in `prevSelDenots` to the denotations they had
164+ * before this phase.
165+ */
160166 def reset ()(using Context ): Unit =
161167 for (ref, mbr) <- prevSelDenots.iterator do
162168 ref.withDenot(mbr)
@@ -203,14 +209,14 @@ abstract class Recheck extends Phase, SymTransformer:
203209 val prevDenot = prevType.denot
204210 val newType = qualType.select(name, mbr)
205211 if (newType eq prevType) && (mbr.info ne prevDenot.info) && ! prevSelDenots.contains(prevType) then
212+ // remember previous denot of NamedType, so that it can be reset after this phase
206213 prevSelDenots(prevType) = prevDenot
207214 newType
208215 case _ =>
209216 qualType.select(name, mbr)
210217 constFold(tree, newType)
211218 // .showing(i"recheck select $qualType . $name : ${mbr.info} = $result")
212219
213-
214220 /** Keep the symbol of the `select` but re-infer its type */
215221 def recheckSelection (tree : Select , qualType : Type , name : Name , pt : Type )(using Context ): Type =
216222 recheckSelection(tree, qualType, name, sharpen = identity[Denotation ])
0 commit comments