File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -501,9 +501,8 @@ class CheckCaptures extends Recheck, SymTransformer:
501
501
override def recheckBlock (block : Block , pt : Type )(using Context ): Type =
502
502
block match
503
503
case closureDef(mdef) =>
504
- pt.dealias match
505
- case defn.FunctionOf (ptformals, _, _)
506
- if ptformals.nonEmpty && ptformals.forall(_.captureSet.isAlwaysEmpty) =>
504
+ def recheckFunction (ptformals : List [Type ]) =
505
+ if ptformals.nonEmpty && ptformals.forall(_.captureSet.isAlwaysEmpty) then
507
506
// Redo setup of the anonymous function so that formal parameters don't
508
507
// get capture sets. This is important to avoid false widenings to `cap`
509
508
// when taking the base type of the actual closures's dependent function
@@ -531,6 +530,9 @@ class CheckCaptures extends Recheck, SymTransformer:
531
530
.showing(i " simplify info of $meth to $result" , capt)
532
531
recheckDef(mdef, meth)
533
532
meth.updateInfoBetween(preRecheckPhase, thisPhase, completer)
533
+ pt.dealias match
534
+ case defn.FunctionOf (ptformals, _, _) => recheckFunction(ptformals)
535
+ case defn.DependentFunctionRefinementOf (_, mt) => recheckFunction(mt.paramInfos)
534
536
case _ =>
535
537
mdef.rhs match
536
538
case rhs @ closure(_, _, _) =>
Original file line number Diff line number Diff line change @@ -1122,10 +1122,11 @@ class Definitions {
1122
1122
1123
1123
/** Matches a (possibly aliased) `FunctionN[...]`, `ContextFunctionN[...]` or refined `PolyFunction`.
1124
1124
* Extracts the list of function argument types, the result type and whether function is contextual.
1125
+ * It only matches a `PolyFunction` if the function type is not result dependent.
1125
1126
*/
1126
1127
def unapply (ft : Type )(using Context ): Option [(List [Type ], Type , Boolean )] = {
1127
1128
ft.dealias match
1128
- case PolyFunctionOf (mt : MethodType ) =>
1129
+ case PolyFunctionOf (mt : MethodType ) if ! mt.isResultDependent =>
1129
1130
Some (mt.paramInfos, mt.resType, mt.isContextualMethod)
1130
1131
case FunctionNOf (targs, resType, isContextual) =>
1131
1132
Some (targs, resType, isContextual)
You can’t perform that action at this time.
0 commit comments