@@ -21,6 +21,7 @@ import util.Property
21
21
import StdNames .nme
22
22
import reporting .trace
23
23
import annotation .constructorOnly
24
+ import cc .CaptureSet .IdempotentCaptRefMap
24
25
25
26
object Recheck :
26
27
import tpd .*
@@ -144,9 +145,9 @@ abstract class Recheck extends Phase, SymTransformer:
144
145
def recheckIdent (tree : Ident )(using Context ): Type =
145
146
tree.tpe
146
147
147
- def recheckSelect (tree : Select )(using Context ): Type =
148
+ def recheckSelect (tree : Select , pt : Type )(using Context ): Type =
148
149
val Select (qual, name) = tree
149
- recheckSelection(tree, recheck(qual).widenIfUnstable, name)
150
+ recheckSelection(tree, recheck(qual).widenIfUnstable, name, pt )
150
151
151
152
def recheckSelection (tree : Select , qualType : Type , name : Name ,
152
153
sharpen : Denotation => Denotation )(using Context ): Type =
@@ -162,8 +163,8 @@ abstract class Recheck extends Phase, SymTransformer:
162
163
163
164
164
165
/** 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 ] )
167
168
168
169
def recheckBind (tree : Bind , pt : Type )(using Context ): Type = tree match
169
170
case Bind (name, body) =>
@@ -200,7 +201,7 @@ abstract class Recheck extends Phase, SymTransformer:
200
201
* to FromJavaObject since it got lost in ElimRepeated
201
202
*/
202
203
private def mapJavaArgs (formals : List [Type ])(using Context ): List [Type ] =
203
- val tm = new TypeMap :
204
+ val tm = new TypeMap with IdempotentCaptRefMap :
204
205
def apply (t : Type ) = t match
205
206
case t : TypeRef if t.symbol == defn.ObjectClass => defn.FromJavaObjectType
206
207
case _ => mapOver(t)
@@ -357,7 +358,7 @@ abstract class Recheck extends Phase, SymTransformer:
357
358
val sym = tree.symbol
358
359
tree match
359
360
case tree : Ident => recheckIdent(tree)
360
- case tree : Select => recheckSelect(tree)
361
+ case tree : Select => recheckSelect(tree, pt )
361
362
case tree : Bind => recheckBind(tree, pt)
362
363
case tree : ValOrDefDef =>
363
364
if tree.isEmpty then NoType
0 commit comments