@@ -1836,8 +1836,9 @@ CanType TypeBase::getReducedType(GenericSignature sig) {
1836
1836
return sig.getReducedType (this );
1837
1837
}
1838
1838
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> {
1841
1842
const CanType CanTy = CanType (Ty);
1842
1843
1843
1844
if (const auto ET = dyn_cast<ExistentialType>(CanTy)) {
@@ -1847,7 +1848,7 @@ CanType TypeBase::getMinimalCanonicalType(const DeclContext *useDC) const {
1847
1848
return CanTy;
1848
1849
}
1849
1850
1850
- const auto MinimalTy = PCT->getMinimalCanonicalType (useDC );
1851
+ const auto MinimalTy = PCT->getMinimalCanonicalType ();
1851
1852
if (MinimalTy->getClassOrBoundGenericClass ()) {
1852
1853
return MinimalTy;
1853
1854
}
@@ -1861,7 +1862,7 @@ CanType TypeBase::getMinimalCanonicalType(const DeclContext *useDC) const {
1861
1862
return CanTy;
1862
1863
}
1863
1864
1864
- const auto MinimalTy = PCT->getMinimalCanonicalType (useDC );
1865
+ const auto MinimalTy = PCT->getMinimalCanonicalType ();
1865
1866
if (MinimalTy->getClassOrBoundGenericClass ()) {
1866
1867
return MetatypeType::get (MinimalTy);
1867
1868
}
@@ -1870,7 +1871,7 @@ CanType TypeBase::getMinimalCanonicalType(const DeclContext *useDC) const {
1870
1871
}
1871
1872
1872
1873
if (const auto Composition = dyn_cast<ProtocolCompositionType>(CanTy)) {
1873
- return Composition->getMinimalCanonicalType (useDC );
1874
+ return Composition->getMinimalCanonicalType ();
1874
1875
}
1875
1876
1876
1877
return std::nullopt;
@@ -3795,21 +3796,15 @@ Type ProtocolCompositionType::get(const ASTContext &C,
3795
3796
return build (C, CanTypes, Inverses, HasExplicitAnyObject);
3796
3797
}
3797
3798
3798
- CanType ProtocolCompositionType::getMinimalCanonicalType (
3799
- const DeclContext *useDC) const {
3799
+ CanType ProtocolCompositionType::getMinimalCanonicalType () const {
3800
3800
auto &Ctx = getASTContext ();
3801
3801
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 ();
3813
3808
}
3814
3809
3815
3810
ClangTypeInfo AnyFunctionType::getClangTypeInfo () const {
0 commit comments