@@ -612,10 +612,10 @@ class CheckCaptures extends Recheck, SymTransformer:
612
612
mdef.rhs.putAttachment(ClosureBodyValue , ())
613
613
case _ =>
614
614
615
- // Constrain closure's parameters and result from the expected type before
616
- // rechecking the body.
617
615
openClosures = (mdef.symbol, pt) :: openClosures
618
616
try
617
+ // Constrain closure's parameters and result from the expected type before
618
+ // rechecking the body.
619
619
val res = recheckClosure(expr, pt, forceDependent = true )
620
620
if ! isEtaExpansion(mdef) then
621
621
// If closure is an eta expanded method reference it's better to not constrain
@@ -699,7 +699,7 @@ class CheckCaptures extends Recheck, SymTransformer:
699
699
val localSet = capturedVars(sym)
700
700
if ! localSet.isAlwaysEmpty then
701
701
curEnv = Env (sym, EnvKind .Regular , localSet, curEnv)
702
- inNestedLevel :
702
+ inNestedLevel : // TODO: needed here?
703
703
try checkInferredResult(super .recheckDefDef(tree, sym), tree)
704
704
finally
705
705
if ! sym.isAnonymousFunction then
@@ -920,8 +920,7 @@ class CheckCaptures extends Recheck, SymTransformer:
920
920
case expected @ defn.FunctionOf (args, resultType, isContextual)
921
921
if defn.isNonRefinedFunction(expected) =>
922
922
actual match
923
- case RefinedType (parent, nme.apply, rinfo : MethodType )
924
- if defn.isFunctionNType(actual) =>
923
+ case defn.RefinedFunctionOf (rinfo : MethodType ) =>
925
924
depFun(args, resultType, isContextual, rinfo.paramNames)
926
925
case _ => expected
927
926
case _ => expected
@@ -1132,12 +1131,12 @@ class CheckCaptures extends Recheck, SymTransformer:
1132
1131
* @param sym symbol of the field definition that is being checked
1133
1132
*/
1134
1133
override def checkSubType (actual : Type , expected : Type )(using Context ): Boolean =
1135
- val expected1 = alignDependentFunction(addOuterRefs(expected, actual), actual.stripCapturing)
1134
+ val expected1 = alignDependentFunction(addOuterRefs(/* Existential.strip */ ( expected) , actual), actual.stripCapturing)
1136
1135
val actual1 =
1137
1136
val saved = curEnv
1138
1137
try
1139
1138
curEnv = Env (clazz, EnvKind .NestedInOwner , capturedVars(clazz), outer0 = curEnv)
1140
- val adapted = adaptBoxed(actual, expected1, srcPos, covariant = true , alwaysConst = true )
1139
+ val adapted = adaptBoxed(/* Existential.strip */ ( actual) , expected1, srcPos, covariant = true , alwaysConst = true )
1141
1140
actual match
1142
1141
case _ : MethodType =>
1143
1142
// We remove the capture set resulted from box adaptation for method types,
0 commit comments