Commits

Jordan Rose committed 758cf642830
Rework access checking in terms of "access scopes". (in preparation for the private/fileprivate split) An "access scope" is the outermost DeclContext where a particular declaration may be referenced: for a 'fileprivate' declaration it's the enclosing file, and for an 'internal' declaration it's the module. 'public' corresponds to a scope of "everything", represented by a null DeclContext. This model extends naturally to the (not-yet-implemented) SE-0025 notion of 'private', where the access scope is a declaration's immediately enclosing DeclContext. Complicating this model is the revised rules that allow, e.g., a public declaration to be declared within an internal type. The access scope for this declaration is still just the module, not "everything". This commit reworks formal access control checking in terms of this model, including tightening up some of the handling for '@testable'. This implements the rule that you must be able to access a declaration's type everywhere you can reference the declaration. This was not intended to change compiler behavior, but in practice it has made cross-file dependency tracking a bit more conservative (unnecessarily), caught a mistake in diagnosing access violations, and fixed a fuzzer-based crasher (see test changes). Progress on SE-0025 ('private' and 'fileprivate')