@@ -43,8 +43,6 @@ using namespace inference;
4343
4444#define DEBUG_TYPE " ConstraintSystem"
4545
46-
47-
4846Type ConstraintSystem::openUnboundGenericType (GenericTypeDecl *decl,
4947 Type parentTy,
5048 ConstraintLocatorBuilder locator,
@@ -1235,38 +1233,37 @@ ConstraintSystem::getTypeOfReferencePost(OverloadChoice choice,
12351233 auto *value = choice.getDecl ();
12361234
12371235 if (value->getDeclContext ()->isTypeContext () && isa<FuncDecl>(value)) {
1238- auto *openedFnType = openedType->castTo <FunctionType>();
1239-
12401236 // Unqualified lookup can find operator names within nominal types.
12411237 auto func = cast<FuncDecl>(value);
12421238 assert (func->isOperator () && " Lookup should only find operators" );
12431239
12441240 auto functionRefInfo = choice.getFunctionRefInfo ();
12451241
1246- auto origOpenedType = openedFnType ;
1242+ auto origOpenedType = openedType ;
12471243 if (!isRequirementOrWitness (locator)) {
12481244 unsigned numApplies = getNumApplications (/* hasAppliedSelf*/ false ,
12491245 functionRefInfo);
1250- openedFnType = adjustFunctionTypeForConcurrency (
1251- origOpenedType, /* baseType=*/ Type (), func, useDC, numApplies,
1252- /* isMainDispatchQueue=*/ false , /* openGlobalActorType=*/ true , locator);
1246+ openedType = adjustFunctionTypeForConcurrency (
1247+ origOpenedType->castTo <FunctionType>(), /* baseType=*/ Type (),
1248+ func, useDC, numApplies, /* isMainDispatchQueue=*/ false ,
1249+ /* openGlobalActorType=*/ true , locator);
12531250 }
12541251
12551252 // If this is a method whose result type is dynamic Self, replace
12561253 // DynamicSelf with the actual object type. Repeat the adjustment
12571254 // for the original and adjusted types.
1258- auto type = openedFnType ;
1259- if (openedFnType ->hasDynamicSelfType ()) {
1260- auto params = openedFnType ->getParams ();
1255+ auto type = openedType ;
1256+ if (openedType ->hasDynamicSelfType ()) {
1257+ auto params = openedType-> castTo <FunctionType>() ->getParams ();
12611258 assert (params.size () == 1 );
12621259 Type selfTy = params.front ().getPlainType ()->getMetatypeInstanceType ();
1263- type = openedFnType ->replaceDynamicSelfType (selfTy)
1260+ type = openedType ->replaceDynamicSelfType (selfTy)
12641261 ->castTo <FunctionType>();
12651262 }
12661263
12671264 auto origType = origOpenedType;
12681265 if (origOpenedType->hasDynamicSelfType ()) {
1269- auto params = origOpenedType->getParams ();
1266+ auto params = origOpenedType->castTo <FunctionType>()-> getParams ();
12701267 assert (params.size () == 1 );
12711268 Type selfTy = params.front ().getPlainType ()->getMetatypeInstanceType ();
12721269 origType = origOpenedType->replaceDynamicSelfType (selfTy)
@@ -1275,7 +1272,8 @@ ConstraintSystem::getTypeOfReferencePost(OverloadChoice choice,
12751272
12761273 // The reference implicitly binds 'self'.
12771274 return {origOpenedType, openedType,
1278- origType->getResult (), type->getResult (), Type ()};
1275+ origType->castTo <FunctionType>()->getResult (),
1276+ type->castTo <FunctionType>()->getResult (), Type ()};
12791277 }
12801278
12811279 // Unqualified reference to a local or global function.
0 commit comments