Skip to content

Commit 6b2e598

Browse files
committed
Sema: Small cleanup in getMemberReferenceTypeFromOpenedType()
1 parent ab4e754 commit 6b2e598

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/Sema/TypeOfReference.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,18 +1558,17 @@ Type ConstraintSystem::getMemberReferenceTypeFromOpenedType(
15581558
Type type = openedType;
15591559

15601560
// Cope with dynamic 'Self'.
1561-
if (!outerDC->getSelfProtocolDecl()) {
1562-
const auto replacementTy =
1563-
getDynamicSelfReplacementType(baseObjTy, value, locator);
1564-
1565-
if (auto func = dyn_cast<AbstractFunctionDecl>(value)) {
1566-
if (isa<ConstructorDecl>(func) &&
1567-
func->getDeclContext()->getSelfClassDecl()) {
1568-
type = type->withCovariantResultType();
1569-
}
1561+
if (outerDC->getSelfClassDecl()) {
1562+
if (isa<ConstructorDecl>(value)) {
1563+
type = type->withCovariantResultType();
15701564
}
15711565

1572-
type = type->replaceDynamicSelfType(replacementTy);
1566+
if (type->hasDynamicSelfType()) {
1567+
auto replacementTy = getDynamicSelfReplacementType(
1568+
baseObjTy, value, locator);
1569+
1570+
type = type->replaceDynamicSelfType(replacementTy);
1571+
}
15731572
}
15741573

15751574
// Check if we need to apply a layer of optionality to the uncurried type.

0 commit comments

Comments
 (0)