@@ -1555,19 +1555,9 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
1555
1555
Type &openedType, Type baseObjTy, ValueDecl *value, DeclContext *outerDC,
1556
1556
ConstraintLocator *locator, bool hasAppliedSelf, bool isDynamicLookup,
1557
1557
ArrayRef<OpenedType> replacements) {
1558
- Type type = openedType;
1559
-
1560
- // Cope with dynamic 'Self'.
1561
1558
if (outerDC->getSelfClassDecl ()) {
1562
1559
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 ();
1571
1561
}
1572
1562
}
1573
1563
@@ -1593,13 +1583,19 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
1593
1583
fnTy->getExtInfo ());
1594
1584
};
1595
1585
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.
1601
1586
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);
1603
1599
}
1604
1600
}
1605
1601
0 commit comments