@@ -149,7 +149,8 @@ static void tryEmitContainmentFixits(InFlightDiagnostic &&diag,
149
149
}
150
150
151
151
// / MARK: conformance checking
152
- static bool checkInvertibleConformanceCommon (ProtocolConformance *conformance,
152
+ static bool checkInvertibleConformanceCommon (DeclContext *dc,
153
+ ProtocolConformance *conformance,
153
154
InvertibleProtocolKind ip) {
154
155
const auto kp = getKnownProtocolKind (ip);
155
156
auto *proto = conformance->getProtocol ();
@@ -170,7 +171,7 @@ static bool checkInvertibleConformanceCommon(ProtocolConformance *conformance,
170
171
// written in an extension, then we do not raise an error.
171
172
auto inverseMarking = nom->hasInverseMarking (ip);
172
173
if (inverseMarking.isAnyExplicit ()) {
173
- if (conformance-> getDeclContext () == nom) {
174
+ if (dc == nom) {
174
175
ctx.Diags .diagnose (inverseMarking.getLoc (),
175
176
diag::inverse_but_also_conforms,
176
177
nom, getProtocolName (kp));
@@ -260,20 +261,21 @@ static bool checkInvertibleConformanceCommon(ProtocolConformance *conformance,
260
261
// This nominal cannot conform to IP if it contains storage that does not
261
262
// conform to IP.
262
263
bool lacksMatchingStorage =
263
- LacksMatchingStorage (nom, conformance->getDeclContext (),
264
- ip, /* diagnose=*/ true ).visit ();
264
+ LacksMatchingStorage (nom, dc, ip, /* diagnose=*/ true ).visit ();
265
265
conforms &= !lacksMatchingStorage;
266
266
267
267
return conforms;
268
268
}
269
269
270
- bool swift::checkEscapableConformance (ProtocolConformance *conformance) {
271
- return checkInvertibleConformanceCommon (conformance,
270
+ bool swift::checkEscapableConformance (DeclContext *dc,
271
+ ProtocolConformance *conformance) {
272
+ return checkInvertibleConformanceCommon (dc, conformance,
272
273
InvertibleProtocolKind::Escapable);
273
274
}
274
275
275
- bool swift::checkCopyableConformance (ProtocolConformance *conformance) {
276
- return checkInvertibleConformanceCommon (conformance,
276
+ bool swift::checkCopyableConformance (DeclContext *dc,
277
+ ProtocolConformance *conformance) {
278
+ return checkInvertibleConformanceCommon (dc, conformance,
277
279
InvertibleProtocolKind::Copyable);
278
280
}
279
281
0 commit comments