@@ -110,7 +110,7 @@ object root:
110110 " "
111111
112112 enum Kind :
113- case Result (binder : MethodType )
113+ case Result (binder : MethodicType )
114114 case Fresh (hidden : CaptureSet .HiddenSet )(val origin : Origin )
115115 case Global
116116
@@ -134,14 +134,14 @@ object root:
134134 ccs.rootId += 1
135135 ccs.rootId
136136
137- // assert(id != 4)
137+ // assert(id != 4, kind )
138138
139139 override def symbol (using Context ) = defn.RootCapabilityAnnot
140140 override def tree (using Context ) = New (symbol.typeRef, Nil )
141141 override def derivedAnnotation (tree : Tree )(using Context ): Annotation = this
142142
143143 private var myOriginalKind = kind
144- def originalBinder : MethodType = myOriginalKind.asInstanceOf [Kind .Result ].binder
144+ def originalBinder : MethodicType = myOriginalKind.asInstanceOf [Kind .Result ].binder
145145
146146 def derivedAnnotation (binder : MethodType )(using Context ): Annotation = kind match
147147 case Kind .Result (b) if b ne binder =>
@@ -198,13 +198,13 @@ object root:
198198 type Result = AnnotatedType
199199
200200 object Result :
201- def apply (binder : MethodType )(using Context ): Result =
201+ def apply (binder : MethodicType )(using Context ): Result =
202202 val hiddenSet = CaptureSet .HiddenSet (NoSymbol )
203203 val res = AnnotatedType (cap, Annot (Kind .Result (binder)))
204204 hiddenSet.owningCap = res
205205 res
206206
207- def unapply (tp : Result )(using Context ): Option [MethodType ] = tp.annot match
207+ def unapply (tp : Result )(using Context ): Option [MethodicType ] = tp.annot match
208208 case Annot (Kind .Result (binder)) => Some (binder)
209209 case _ => None
210210 end Result
@@ -298,7 +298,7 @@ object root:
298298 * variable bound by `mt`.
299299 * Stop at function or method types since these have been mapped before.
300300 */
301- def toResult (tp : Type , mt : MethodType , fail : Message => Unit )(using Context ): Type =
301+ def toResult (tp : Type , mt : MethodicType , fail : Message => Unit )(using Context ): Type =
302302
303303 abstract class CapMap extends BiTypeMap :
304304 override def mapOver (t : Type ): Type = t match
@@ -356,7 +356,7 @@ object root:
356356 end toResult
357357
358358 /** Map global roots in function results to result roots */
359- def toResultInResults (fail : Message => Unit , keepAliases : Boolean = false )(using Context ): TypeMap = new TypeMap with FollowAliasesMap :
359+ def toResultInResults (sym : Symbol , fail : Message => Unit , keepAliases : Boolean = false )(using Context ): TypeMap = new TypeMap with FollowAliasesMap :
360360 def apply (t : Type ): Type = t match
361361 case defn.RefinedFunctionOf (mt) =>
362362 val mt1 = apply(mt)
@@ -369,6 +369,8 @@ object root:
369369 t.derivedCapturingType(this (parent), refs)
370370 case t : (LazyRef | TypeVar ) =>
371371 mapConserveSuper(t)
372+ case t : ExprType if sym.is(Method , butNot = Accessor ) =>
373+ t.derivedExprType(toResult(t.resType, t, fail))
372374 case _ =>
373375 try
374376 if keepAliases then mapOver(t)
0 commit comments