Skip to content

Commit 9b6aa30

Browse files
committed
Relax an assert in witness access diagnostics
#22235 added an assert that was a little overzealous about the structure of access control attributes in the AST. It used to always expect that we reached diagnoseWitnessFixAccessLevel when there was an explicit mismatch in user-written access markers. But declarations may also have their access levels rewritten and their access attributes stripped if they are invalid. If you can get all of these to occur by the time you diagnose the witness, you see no attribute for a witness with insufficient ACLs for a requirement and crash. Relax the assert by using the formal access level and resolve rdar://56818960
1 parent d53c015 commit 9b6aa30

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2388,11 +2388,8 @@ static void diagnoseWitnessFixAccessLevel(DiagnosticEngine &diags,
23882388
if (extAccess < requiredAccess) {
23892389
shouldMoveToAnotherExtension = true;
23902390
} else if (extAccess == requiredAccess) {
2391-
auto declAttr = decl->getAttrs().getAttribute<AccessControlAttr>();
2392-
assert(declAttr && declAttr->getAccess() < requiredAccess &&
2393-
"expect an explicitly specified access control level which is "
2394-
"less accessible than required.");
2395-
(void)declAttr;
2391+
assert(decl->getFormalAccess() < requiredAccess &&
2392+
"witness is accessible?");
23962393
shouldUseDefaultAccess = true;
23972394
}
23982395
}

0 commit comments

Comments
 (0)