File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -310,7 +310,12 @@ Type RequirementFailure::getOwnerType() const {
310
310
const GenericContext *RequirementFailure::getGenericContext () const {
311
311
if (auto *genericCtx = AffectedDecl->getAsGenericContext ())
312
312
return genericCtx;
313
- return AffectedDecl->getDeclContext ()->getAsDecl ()->getAsGenericContext ();
313
+
314
+ auto parentDecl = AffectedDecl->getDeclContext ()->getAsDecl ();
315
+ if (!parentDecl)
316
+ return nullptr ;
317
+
318
+ return parentDecl->getAsGenericContext ();
314
319
}
315
320
316
321
const Requirement &RequirementFailure::getRequirement () const {
Original file line number Diff line number Diff line change @@ -236,6 +236,10 @@ class RequirementFailure : public FailureDiagnostic {
236
236
assert (locator);
237
237
assert (isConditional () || Signature);
238
238
assert (AffectedDecl);
239
+ assert (getRequirementDC () &&
240
+ " Couldn't find where the requirement came from?" );
241
+ assert (getGenericContext () &&
242
+ " Affected decl not within a generic context?" );
239
243
240
244
auto reqElt = locator->castLastElementTo <LocatorPathElt::AnyRequirement>();
241
245
assert (reqElt.getRequirementKind () == kind);
You can’t perform that action at this time.
0 commit comments