@@ -1555,19 +1555,9 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
15551555 Type &openedType, Type baseObjTy, ValueDecl *value, DeclContext *outerDC,
15561556 ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup,
15571557 ArrayRef<OpenedType> replacements) {
1558- Type type = openedType;
1559-
1560- // Cope with dynamic 'Self'.
15611558 if (outerDC->getSelfClassDecl ()) {
15621559 if (isa<ConstructorDecl>(value)) {
1563- type = type->withCovariantResultType ();
1564- }
1565-
1566- if (type->hasDynamicSelfType ()) {
1567- auto replacementTy = getDynamicSelfReplacementType (
1568- baseObjTy, value, locator);
1569-
1570- type = type->replaceDynamicSelfType (replacementTy);
1560+ openedType = openedType->withCovariantResultType ();
15711561 }
15721562 }
15731563
@@ -1593,13 +1583,19 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
15931583 fnTy->getExtInfo ());
15941584 };
15951585
1596- // FIXME: Refactor 'replaceCovariantResultType' not to rely on the passed
1597- // uncurry level.
1598- //
1599- // This is done after handling dynamic 'Self' to make
1600- // 'replaceCovariantResultType' work, so we have to transform both types.
16011586 openedType = applyOptionality (openedType->castTo <FunctionType>());
1602- type = applyOptionality (type->castTo <FunctionType>());
1587+ }
1588+ }
1589+
1590+ Type type = openedType;
1591+
1592+ // Cope with dynamic 'Self'.
1593+ if (outerDC->getSelfClassDecl ()) {
1594+ if (type->hasDynamicSelfType ()) {
1595+ auto replacementTy = getDynamicSelfReplacementType (
1596+ baseObjTy, value, locator);
1597+
1598+ type = type->replaceDynamicSelfType (replacementTy);
16031599 }
16041600 }
16051601
0 commit comments