@@ -1836,8 +1836,9 @@ CanType TypeBase::getReducedType(GenericSignature sig) {
18361836 return sig.getReducedType (this );
18371837}
18381838
1839- CanType TypeBase::getMinimalCanonicalType (const DeclContext *useDC) const {
1840- const auto MinimalTy = getCanonicalType ().transformRec ([useDC](TypeBase *Ty) -> std::optional<Type> {
1839+ CanType TypeBase::getMinimalCanonicalType () const {
1840+ const auto MinimalTy = getCanonicalType ().transformRec (
1841+ [](TypeBase *Ty) -> std::optional<Type> {
18411842 const CanType CanTy = CanType (Ty);
18421843
18431844 if (const auto ET = dyn_cast<ExistentialType>(CanTy)) {
@@ -1847,7 +1848,7 @@ CanType TypeBase::getMinimalCanonicalType(const DeclContext *useDC) const {
18471848 return CanTy;
18481849 }
18491850
1850- const auto MinimalTy = PCT->getMinimalCanonicalType (useDC );
1851+ const auto MinimalTy = PCT->getMinimalCanonicalType ();
18511852 if (MinimalTy->getClassOrBoundGenericClass ()) {
18521853 return MinimalTy;
18531854 }
@@ -1861,7 +1862,7 @@ CanType TypeBase::getMinimalCanonicalType(const DeclContext *useDC) const {
18611862 return CanTy;
18621863 }
18631864
1864- const auto MinimalTy = PCT->getMinimalCanonicalType (useDC );
1865+ const auto MinimalTy = PCT->getMinimalCanonicalType ();
18651866 if (MinimalTy->getClassOrBoundGenericClass ()) {
18661867 return MetatypeType::get (MinimalTy);
18671868 }
@@ -1870,7 +1871,7 @@ CanType TypeBase::getMinimalCanonicalType(const DeclContext *useDC) const {
18701871 }
18711872
18721873 if (const auto Composition = dyn_cast<ProtocolCompositionType>(CanTy)) {
1873- return Composition->getMinimalCanonicalType (useDC );
1874+ return Composition->getMinimalCanonicalType ();
18741875 }
18751876
18761877 return std::nullopt ;
@@ -3795,21 +3796,15 @@ Type ProtocolCompositionType::get(const ASTContext &C,
37953796 return build (C, CanTypes, Inverses, HasExplicitAnyObject);
37963797}
37973798
3798- CanType ProtocolCompositionType::getMinimalCanonicalType (
3799- const DeclContext *useDC) const {
3799+ CanType ProtocolCompositionType::getMinimalCanonicalType () const {
38003800 auto &Ctx = getASTContext ();
38013801
3802- // Use generic signature minimization: the requirements of the signature will
3803- // represent the minimal composition.
3804- auto parentSig = useDC->getGenericSignatureOfContext ();
3805- auto existentialSig =
3806- Ctx.getOpenedExistentialSignature (getCanonicalType (), parentSig);
3807- auto selfTy =
3808- OpenedArchetypeType::getSelfInterfaceTypeFromContext (parentSig, Ctx);
3809- return existentialSig->getUpperBound (selfTy,
3810- /* forExistentialSelf=*/ true ,
3811- /* includeParameterizedProtocols=*/ true )
3812- ->getCanonicalType ();
3802+ auto existentialSig = Ctx.getOpenedExistentialSignature (getCanonicalType ());
3803+ auto result = existentialSig.OpenedSig ->getUpperBound (
3804+ existentialSig.SelfType ,
3805+ /* forExistentialSelf=*/ true ,
3806+ /* includeParameterizedProtocols=*/ true );
3807+ return result.subst (existentialSig.Generalization )->getCanonicalType ();
38133808}
38143809
38153810ClangTypeInfo AnyFunctionType::getClangTypeInfo () const {
0 commit comments