@@ -52,25 +52,24 @@ static void addConformanceFixIt(const NominalTypeDecl *nominal,
5252// a conformance to KP.
5353static void emitAdviceToApplyInverseAfter (InFlightDiagnostic &&diag,
5454 InvertibleProtocolKind ip,
55- InverseMarking marking ,
55+ InverseMarking::Mark inverseMarking ,
5656 NominalTypeDecl *nominal) {
5757 auto kp = getKnownProtocolKind (ip);
5858
5959 // Immediately flush, then emit notes, so they're associated.
6060 diag.flush ();
6161
62- auto &ctx = nominal->getASTContext ();
63- // Not expecting the positive KP constraint to be classified as "Inferred".
64- assert (marking.getPositive ().getKind () != InverseMarking::Kind::Inferred);
65-
6662 // Have no advice for situations where the KP conformance is explicit.
63+ auto marking = nominal->getMarking (ip);
6764 if (marking.getPositive ().isPresent ())
6865 return ;
6966
70- switch (marking.getInverse ().getKind ()) {
67+ auto &ctx = nominal->getASTContext ();
68+
69+ switch (inverseMarking.getKind ()) {
7170 case InverseMarking::Kind::Inferred:
7271 // Note that the enclosing type is conditionally conforming to KP first.
73- ctx.Diags .diagnose (marking. getInverse () .getLoc (),
72+ ctx.Diags .diagnose (inverseMarking .getLoc (),
7473 diag::note_inverse_preventing_conformance_implicit,
7574 nominal, getProtocolName (kp));
7675 LLVM_FALLTHROUGH;
@@ -104,7 +103,7 @@ static void tryEmitContainmentFixits(InFlightDiagnostic &&diag,
104103 auto kp = getKnownProtocolKind (ip);
105104
106105 // Check the enclosing type's markings to see what to suggest.
107- auto enclosingMarking = enclosingNom->getMarking (ip);
106+ auto enclosingMarking = enclosingNom->hasInverseMarking (ip);
108107
109108 // First, the generic advice.
110109 emitAdviceToApplyInverseAfter (std::move (diag), ip,
@@ -131,7 +130,7 @@ static void tryEmitContainmentFixits(InFlightDiagnostic &&diag,
131130 // not IP.
132131 if (auto nominal = nonConformingTy->getAnyNominal ()) {
133132 if (nominal->getLoc (/* SerializedOK=*/ false )) {
134- auto inverse = nominal->getMarking (ip). getInverse ( );
133+ auto inverse = nominal->hasInverseMarking (ip);
135134 auto loc = inverse.getLoc ();
136135
137136 switch (inverse.getKind ()) {
@@ -176,10 +175,10 @@ static bool checkInvertibleConformanceCommon(ProtocolConformance *conformance,
176175 //
177176 // So, if the nominal has `~Copyable` but this conformance is
178177 // written in an extension, then we do not raise an error.
179- auto marking = nom->getMarking (ip);
180- if (marking. getInverse () .isAnyExplicit ()) {
178+ auto inverseMarking = nom->hasInverseMarking (ip);
179+ if (inverseMarking .isAnyExplicit ()) {
181180 if (conformance->getDeclContext () == nom) {
182- ctx.Diags .diagnose (marking. getInverse () .getLoc (),
181+ ctx.Diags .diagnose (inverseMarking .getLoc (),
183182 diag::inverse_but_also_conforms,
184183 nom, getProtocolName (kp));
185184 conforms &= false ;
@@ -200,7 +199,7 @@ static bool checkInvertibleConformanceCommon(ProtocolConformance *conformance,
200199 auto diag = deinit->diagnose (diag::copyable_illegal_deinit, nom);
201200 emitAdviceToApplyInverseAfter (std::move (diag),
202201 ip,
203- nom-> getMarking (ip) ,
202+ inverseMarking ,
204203 nom);
205204 conforms &= false ;
206205 }
@@ -398,14 +397,9 @@ ProtocolConformance *deriveConformanceForInvertible(Evaluator &evaluator,
398397 return generateConformance (ext);
399398 };
400399
401- auto marking = nominal->getMarking (*ip);
402-
403- // Unexpected to have any positive marking for IP if we're deriving it.
404- assert (!marking.getPositive ().isPresent ());
405-
406400 // Check what kind of inverse-marking we have to determine whether to generate
407401 // a conformance for IP.
408- switch (marking. getInverse ( ).getKind ()) {
402+ switch (nominal-> hasInverseMarking (*ip ).getKind ()) {
409403 case InverseMarking::Kind::LegacyExplicit:
410404 case InverseMarking::Kind::Explicit:
411405 return nullptr ; // No positive IP conformance will be inferred.
0 commit comments