File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -3999,14 +3999,25 @@ CanType ProtocolCompositionType::getMinimalCanonicalType(
39993999 // represent the minimal composition.
40004000 auto sig = useDC->getGenericSignatureOfContext ();
40014001 const auto Sig = Ctx.getOpenedExistentialSignature (CanTy, sig);
4002- const auto &Reqs = Sig.getRequirements ();
4002+ SmallVector<Requirement, 2 > Reqs;
4003+ SmallVector<InverseRequirement, 2 > Inverses;
4004+ Sig->getRequirementsWithInverses (Reqs, Inverses);
4005+
40034006 if (Reqs.size () == 1 ) {
40044007 return Reqs.front ().getSecondType ()->getCanonicalType ();
40054008 }
40064009
40074010 // The set of inverses is already minimal.
40084011 auto MinimalInverses = Composition->getInverses ();
40094012
4013+ #ifndef NDEBUG
4014+ // Check that the generic signature's inverses matches.
4015+ InvertibleProtocolSet genSigInverses;
4016+ for (InverseRequirement ireq : Inverses)
4017+ genSigInverses.insert (ireq.getKind ());
4018+ assert (genSigInverses == MinimalInverses);
4019+ #endif
4020+
40104021 llvm::SmallVector<Type, 2 > MinimalMembers;
40114022 bool MinimalHasExplicitAnyObject = false ;
40124023 auto ifaceTy = Sig.getGenericParams ().back ();
Original file line number Diff line number Diff line change @@ -100,4 +100,4 @@ typealias Z5 = (~Int) -> Void // expected-error {{type 'Int' is not invertible}}
100100typealias Z6 = ~ ( ) -> ( ) // expected-error {{single argument function types require parentheses}}
101101 // expected-error@-1 {{type '()' is not invertible}}
102102typealias Z7 = ~ ( Copyable & Hashable ) // expected-error {{type 'Hashable' is not invertible}}
103- typealias Z8 = ~ Copyable & Hashable
103+ typealias Z8 = ~ Copyable & Hashable // expected-error {{composition cannot contain '~Copyable' when another member requires 'Copyable'}}
Original file line number Diff line number Diff line change 77sil_stage canonical
88
99import Builtin
10+ import Swift
1011
1112typealias AnyObject = Builtin.AnyObject
1213
You can’t perform that action at this time.
0 commit comments