@@ -52,25 +52,24 @@ static void addConformanceFixIt(const NominalTypeDecl *nominal,
52
52
// a conformance to KP.
53
53
static void emitAdviceToApplyInverseAfter (InFlightDiagnostic &&diag,
54
54
InvertibleProtocolKind ip,
55
- InverseMarking marking ,
55
+ InverseMarking::Mark inverseMarking ,
56
56
NominalTypeDecl *nominal) {
57
57
auto kp = getKnownProtocolKind (ip);
58
58
59
59
// Immediately flush, then emit notes, so they're associated.
60
60
diag.flush ();
61
61
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
-
66
62
// Have no advice for situations where the KP conformance is explicit.
63
+ auto marking = nominal->getMarking (ip);
67
64
if (marking.getPositive ().isPresent ())
68
65
return ;
69
66
70
- switch (marking.getInverse ().getKind ()) {
67
+ auto &ctx = nominal->getASTContext ();
68
+
69
+ switch (inverseMarking.getKind ()) {
71
70
case InverseMarking::Kind::Inferred:
72
71
// Note that the enclosing type is conditionally conforming to KP first.
73
- ctx.Diags .diagnose (marking. getInverse () .getLoc (),
72
+ ctx.Diags .diagnose (inverseMarking .getLoc (),
74
73
diag::note_inverse_preventing_conformance_implicit,
75
74
nominal, getProtocolName (kp));
76
75
LLVM_FALLTHROUGH;
@@ -104,7 +103,7 @@ static void tryEmitContainmentFixits(InFlightDiagnostic &&diag,
104
103
auto kp = getKnownProtocolKind (ip);
105
104
106
105
// Check the enclosing type's markings to see what to suggest.
107
- auto enclosingMarking = enclosingNom->getMarking (ip);
106
+ auto enclosingMarking = enclosingNom->hasInverseMarking (ip);
108
107
109
108
// First, the generic advice.
110
109
emitAdviceToApplyInverseAfter (std::move (diag), ip,
@@ -131,7 +130,7 @@ static void tryEmitContainmentFixits(InFlightDiagnostic &&diag,
131
130
// not IP.
132
131
if (auto nominal = nonConformingTy->getAnyNominal ()) {
133
132
if (nominal->getLoc (/* SerializedOK=*/ false )) {
134
- auto inverse = nominal->getMarking (ip). getInverse ( );
133
+ auto inverse = nominal->hasInverseMarking (ip);
135
134
auto loc = inverse.getLoc ();
136
135
137
136
switch (inverse.getKind ()) {
@@ -176,10 +175,10 @@ static bool checkInvertibleConformanceCommon(ProtocolConformance *conformance,
176
175
//
177
176
// So, if the nominal has `~Copyable` but this conformance is
178
177
// 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 ()) {
181
180
if (conformance->getDeclContext () == nom) {
182
- ctx.Diags .diagnose (marking. getInverse () .getLoc (),
181
+ ctx.Diags .diagnose (inverseMarking .getLoc (),
183
182
diag::inverse_but_also_conforms,
184
183
nom, getProtocolName (kp));
185
184
conforms &= false ;
@@ -200,7 +199,7 @@ static bool checkInvertibleConformanceCommon(ProtocolConformance *conformance,
200
199
auto diag = deinit->diagnose (diag::copyable_illegal_deinit, nom);
201
200
emitAdviceToApplyInverseAfter (std::move (diag),
202
201
ip,
203
- nom-> getMarking (ip) ,
202
+ inverseMarking ,
204
203
nom);
205
204
conforms &= false ;
206
205
}
@@ -398,14 +397,9 @@ ProtocolConformance *deriveConformanceForInvertible(Evaluator &evaluator,
398
397
return generateConformance (ext);
399
398
};
400
399
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
-
406
400
// Check what kind of inverse-marking we have to determine whether to generate
407
401
// a conformance for IP.
408
- switch (marking. getInverse ( ).getKind ()) {
402
+ switch (nominal-> hasInverseMarking (*ip ).getKind ()) {
409
403
case InverseMarking::Kind::LegacyExplicit:
410
404
case InverseMarking::Kind::Explicit:
411
405
return nullptr ; // No positive IP conformance will be inferred.
0 commit comments