@@ -155,8 +155,14 @@ abstract class Recheck extends Phase, SymTransformer:
155
155
*/
156
156
def keepType (tree : Tree ): Boolean = keepAllTypes
157
157
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
+ */
158
161
private val prevSelDenots = util.HashMap [NamedType , Denotation ]()
159
162
163
+ /** Reset all references in `prevSelDenots` to the denotations they had
164
+ * before this phase.
165
+ */
160
166
def reset ()(using Context ): Unit =
161
167
for (ref, mbr) <- prevSelDenots.iterator do
162
168
ref.withDenot(mbr)
@@ -203,14 +209,14 @@ abstract class Recheck extends Phase, SymTransformer:
203
209
val prevDenot = prevType.denot
204
210
val newType = qualType.select(name, mbr)
205
211
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
206
213
prevSelDenots(prevType) = prevDenot
207
214
newType
208
215
case _ =>
209
216
qualType.select(name, mbr)
210
217
constFold(tree, newType)
211
218
// .showing(i"recheck select $qualType . $name : ${mbr.info} = $result")
212
219
213
-
214
220
/** Keep the symbol of the `select` but re-infer its type */
215
221
def recheckSelection (tree : Select , qualType : Type , name : Name , pt : Type )(using Context ): Type =
216
222
recheckSelection(tree, qualType, name, sharpen = identity[Denotation ])
0 commit comments