@@ -651,8 +651,7 @@ ClosureIsolatedByPreconcurrency::operator()(const ClosureExpr *expr) const {
651651
652652Type ConstraintSystem::getUnopenedTypeOfReference (
653653 VarDecl *value, Type baseType, DeclContext *UseDC,
654- ConstraintLocator *locator, bool wantInterfaceType,
655- bool adjustForPreconcurrency) {
654+ ConstraintLocator *locator, bool wantInterfaceType) {
656655 Type requestedType;
657656 if (Type type = getTypeIfAvailable (value)) {
658657 requestedType = type;
@@ -671,14 +670,6 @@ Type ConstraintSystem::getUnopenedTypeOfReference(
671670 if (auto *expansion = requestedType->getAs <PackExpansionType>())
672671 requestedType = expansion->getPatternType ();
673672
674- // Adjust the type for concurrency if requested.
675- if (adjustForPreconcurrency) {
676- requestedType = adjustVarTypeForConcurrency (
677- requestedType, value, UseDC,
678- GetClosureType{*this },
679- ClosureIsolatedByPreconcurrency{*this });
680- }
681-
682673 // If we're dealing with contextual types, and we referenced this type from
683674 // a different context, map the type.
684675 if (!wantInterfaceType && requestedType->hasArchetype ()) {
@@ -1019,11 +1010,11 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
10191010
10201011 // If this is a method whose result type is dynamic Self, replace
10211012 // DynamicSelf with the actual object type.
1022- if (func-> getResultInterfaceType () ->hasDynamicSelfType ()) {
1013+ if (openedType ->hasDynamicSelfType ()) {
10231014 auto params = openedType->getParams ();
10241015 assert (params.size () == 1 );
10251016 Type selfTy = params.front ().getPlainType ()->getMetatypeInstanceType ();
1026- openedType = openedType->replaceCovariantResultType (selfTy, 2 )
1017+ openedType = openedType->replaceDynamicSelfType (selfTy)
10271018 ->castTo <FunctionType>();
10281019 }
10291020
@@ -1057,15 +1048,6 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
10571048 *this , funcDecl, functionRefInfo, openedType->castTo <FunctionType>(),
10581049 locator, preparedOverload);
10591050
1060- auto origOpenedType = openedType;
1061- if (!isRequirementOrWitness (locator)) {
1062- unsigned numApplies = getNumApplications (/* hasAppliedSelf*/ false ,
1063- functionRefInfo);
1064- openedType = adjustFunctionTypeForConcurrency (
1065- origOpenedType->castTo <FunctionType>(), /* baseType=*/ Type (), funcDecl,
1066- useDC, numApplies, false , replacements, locator, preparedOverload);
1067- }
1068-
10691051 if (isForCodeCompletion () && openedType->hasError ()) {
10701052 // In code completion, replace error types by placeholder types so we can
10711053 // match the types we know instead of bailing out completely.
@@ -1076,6 +1058,15 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
10761058 // If we opened up any type variables, record the replacements.
10771059 recordOpenedTypes (locator, replacements, preparedOverload);
10781060
1061+ auto origOpenedType = openedType;
1062+ if (!isRequirementOrWitness (locator)) {
1063+ unsigned numApplies = getNumApplications (/* hasAppliedSelf*/ false ,
1064+ functionRefInfo);
1065+ openedType = adjustFunctionTypeForConcurrency (
1066+ origOpenedType->castTo <FunctionType>(), /* baseType=*/ Type (), funcDecl,
1067+ useDC, numApplies, false , replacements, locator, preparedOverload);
1068+ }
1069+
10791070 return { origOpenedType, openedType, origOpenedType, openedType, Type () };
10801071 }
10811072
@@ -1128,12 +1119,16 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
11281119 auto *varDecl = cast<VarDecl>(value);
11291120
11301121 // Determine the type of the value, opening up that type if necessary.
1131- // FIXME: @preconcurrency
11321122 bool wantInterfaceType = !varDecl->getDeclContext ()->isLocalContext ();
11331123 Type valueType =
11341124 getUnopenedTypeOfReference (varDecl, Type (), useDC,
11351125 getConstraintLocator (locator),
11361126 wantInterfaceType);
1127+ // FIXME: Adjust the type for concurrency if requested.
1128+ valueType = adjustVarTypeForConcurrency (
1129+ valueType, varDecl, useDC,
1130+ GetClosureType{*this },
1131+ ClosureIsolatedByPreconcurrency{*this });
11371132
11381133 Type thrownErrorType;
11391134 if (auto accessor = varDecl->getEffectfulGetAccessor ()) {
@@ -1476,19 +1471,13 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
14761471 getDynamicSelfReplacementType (baseObjTy, value, locator);
14771472
14781473 if (auto func = dyn_cast<AbstractFunctionDecl>(value)) {
1479- if (func-> hasDynamicSelfResult ( ) &&
1474+ if (isa<ConstructorDecl>(func ) &&
14801475 !baseObjTy->getOptionalObjectType ()) {
14811476 type = type->replaceCovariantResultType (replacementTy, 2 );
14821477 }
1483- } else if (auto *decl = dyn_cast<SubscriptDecl>(value)) {
1484- if (decl->getElementInterfaceType ()->hasDynamicSelfType ()) {
1485- type = type->replaceCovariantResultType (replacementTy, 2 );
1486- }
1487- } else if (auto *decl = dyn_cast<VarDecl>(value)) {
1488- if (decl->getValueInterfaceType ()->hasDynamicSelfType ()) {
1489- type = type->replaceCovariantResultType (replacementTy, 1 );
1490- }
14911478 }
1479+
1480+ type = type->replaceDynamicSelfType (replacementTy);
14921481 }
14931482
14941483 // Check if we need to apply a layer of optionality to the uncurried type.
@@ -1724,8 +1713,7 @@ DeclReferenceType ConstraintSystem::getTypeOfMemberReference(
17241713
17251714 refType = getUnopenedTypeOfReference (cast<VarDecl>(value), baseTy, useDC,
17261715 locator,
1727- /* wantInterfaceType=*/ true ,
1728- /* adjustForPreconcurrency=*/ false );
1716+ /* wantInterfaceType=*/ true );
17291717 }
17301718
17311719 auto selfTy = outerDC->getSelfInterfaceType ();
0 commit comments