@@ -707,19 +707,6 @@ class CheckCaptures extends Recheck, SymTransformer:
707
707
selType
708
708
}// .showing(i"recheck sel $tree, $qualType = $result")
709
709
710
- /** Hook for massaging a function before it is applied. Copies all @use and @consume
711
- * annotations on method parameter symbols to the corresponding paramInfo types.
712
- */
713
- override def prepareFunction (funtpe : MethodType , meth : Symbol )(using Context ): MethodType =
714
- val paramInfosWithUses =
715
- funtpe.paramInfos.zipWithConserve(funtpe.paramNames): (formal, pname) =>
716
- val param = meth.paramNamed(pname)
717
- def copyAnnot (tp : Type , cls : ClassSymbol ) = param.getAnnotation(cls) match
718
- case Some (ann) => AnnotatedType (tp, ann)
719
- case _ => tp
720
- copyAnnot(copyAnnot(formal, defn.UseAnnot ), defn.ConsumeAnnot )
721
- funtpe.derivedLambdaType(paramInfos = paramInfosWithUses)
722
-
723
710
/** Recheck applications, with special handling of unsafeAssumePure.
724
711
* More work is done in `recheckApplication`, `recheckArg` and `instantiate` below.
725
712
*/
@@ -747,7 +734,8 @@ class CheckCaptures extends Recheck, SymTransformer:
747
734
val argType = recheck(arg, freshenedFormal)
748
735
.showing(i " recheck arg $arg vs $freshenedFormal = $result" , capt)
749
736
if formal.hasAnnotation(defn.UseAnnot ) || formal.hasAnnotation(defn.ConsumeAnnot ) then
750
- // The @use and/or @consume annotation is added to `formal` by `prepareFunction`
737
+ // The @use and/or @consume annotation is added to `formal` when creating methods types.
738
+ // See [[MethodTypeCompanion.adaptParamInfo]].
751
739
capt.println(i " charging deep capture set of $arg: ${argType} = ${argType.deepCaptureSet}" )
752
740
markFree(argType.deepCaptureSet, arg)
753
741
if formal.containsCap then
@@ -1615,7 +1603,10 @@ class CheckCaptures extends Recheck, SymTransformer:
1615
1603
if noWiden(actual, expected) then
1616
1604
actual
1617
1605
else
1618
- val improvedVAR = improveCaptures(actual.widen.dealiasKeepAnnots, actual)
1606
+ // Compute the widened type. Drop `@use` and `@consume` annotations from the type,
1607
+ // since they obscures the capturing type.
1608
+ val widened = actual.widen.dealiasKeepAnnots.dropUseAndConsumeAnnots
1609
+ val improvedVAR = improveCaptures(widened, actual)
1619
1610
val improved = improveReadOnly(improvedVAR, expected)
1620
1611
val adapted = adaptBoxed(
1621
1612
improved.withReachCaptures(actual), expected, tree,
0 commit comments