@@ -21,6 +21,7 @@ import util.Property
2121import StdNames .nme
2222import reporting .trace
2323import annotation .constructorOnly
24+ import cc .CaptureSet .IdempotentCaptRefMap
2425
2526object Recheck :
2627 import tpd .*
@@ -144,9 +145,9 @@ abstract class Recheck extends Phase, SymTransformer:
144145 def recheckIdent (tree : Ident )(using Context ): Type =
145146 tree.tpe
146147
147- def recheckSelect (tree : Select )(using Context ): Type =
148+ def recheckSelect (tree : Select , pt : Type )(using Context ): Type =
148149 val Select (qual, name) = tree
149- recheckSelection(tree, recheck(qual).widenIfUnstable, name)
150+ recheckSelection(tree, recheck(qual).widenIfUnstable, name, pt )
150151
151152 def recheckSelection (tree : Select , qualType : Type , name : Name ,
152153 sharpen : Denotation => Denotation )(using Context ): Type =
@@ -162,8 +163,8 @@ abstract class Recheck extends Phase, SymTransformer:
162163
163164
164165 /** Keep the symbol of the `select` but re-infer its type */
165- def recheckSelection (tree : Select , qualType : Type , name : Name )(using Context ): Type =
166- recheckSelection(tree, qualType, name, sharpen = identity)
166+ def recheckSelection (tree : Select , qualType : Type , name : Name , pt : Type )(using Context ): Type =
167+ recheckSelection(tree, qualType, name, sharpen = identity[ Denotation ] )
167168
168169 def recheckBind (tree : Bind , pt : Type )(using Context ): Type = tree match
169170 case Bind (name, body) =>
@@ -200,7 +201,7 @@ abstract class Recheck extends Phase, SymTransformer:
200201 * to FromJavaObject since it got lost in ElimRepeated
201202 */
202203 private def mapJavaArgs (formals : List [Type ])(using Context ): List [Type ] =
203- val tm = new TypeMap :
204+ val tm = new TypeMap with IdempotentCaptRefMap :
204205 def apply (t : Type ) = t match
205206 case t : TypeRef if t.symbol == defn.ObjectClass => defn.FromJavaObjectType
206207 case _ => mapOver(t)
@@ -357,7 +358,7 @@ abstract class Recheck extends Phase, SymTransformer:
357358 val sym = tree.symbol
358359 tree match
359360 case tree : Ident => recheckIdent(tree)
360- case tree : Select => recheckSelect(tree)
361+ case tree : Select => recheckSelect(tree, pt )
361362 case tree : Bind => recheckBind(tree, pt)
362363 case tree : ValOrDefDef =>
363364 if tree.isEmpty then NoType
0 commit comments