@@ -867,33 +867,26 @@ Type TypeBase::getTypeOfMember(const ValueDecl *member,
867867
868868Type 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