Skip to content

Commit dd41eeb

Browse files
committed
AST: Clean up TypeBase::adjustSuperclassMemberDeclType()
1 parent 8007295 commit dd41eeb

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -867,33 +867,26 @@ Type TypeBase::getTypeOfMember(const ValueDecl *member,
867867

868868
Type TypeBase::adjustSuperclassMemberDeclType(const ValueDecl *baseDecl,
869869
const ValueDecl *derivedDecl,
870-
Type memberType) {
870+
Type type) {
871871
auto subs = SubstitutionMap::getOverrideSubstitutions(
872872
baseDecl, derivedDecl);
873873

874-
if (auto *genericMemberType = memberType->getAs<GenericFunctionType>()) {
875-
memberType = FunctionType::get(genericMemberType->getParams(),
876-
genericMemberType->getResult(),
877-
genericMemberType->getExtInfo());
874+
if (auto *genericMemberType = type->getAs<GenericFunctionType>()) {
875+
type = genericMemberType->substGenericArgs(subs);
876+
} else {
877+
type = type.subst(subs);
878878
}
879879

880-
auto type = memberType.subst(subs);
881880
if (baseDecl->getDeclContext()->getSelfProtocolDecl())
882881
return type;
883882

884883
if (auto *afd = dyn_cast<AbstractFunctionDecl>(baseDecl)) {
885884
type = type->replaceSelfParameterType(this);
886-
if (afd->hasDynamicSelfResult())
887-
type = type->replaceCovariantResultType(this, /*uncurryLevel=*/2);
888-
} else if (auto *sd = dyn_cast<SubscriptDecl>(baseDecl)) {
889-
if (sd->getElementInterfaceType()->hasDynamicSelfType())
890-
type = type->replaceCovariantResultType(this, /*uncurryLevel=*/1);
891-
} else if (auto *vd = dyn_cast<VarDecl>(baseDecl)) {
892-
if (vd->getValueInterfaceType()->hasDynamicSelfType())
893-
type = type->replaceCovariantResultType(this, /*uncurryLevel=*/0);
885+
if (isa<ConstructorDecl>(afd))
886+
return type->replaceCovariantResultType(this, /*uncurryLevel=*/2);
894887
}
895888

896-
return type;
889+
return type->replaceDynamicSelfType(this);
897890
}
898891

899892
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)