# dmd.access

Enforce visibility contrains such as `public` and `private`.

Specification: Visibility Attributes

#### Authors

Walter Bright

#### License

Boost License 1.0

Source: access.d

Documentation: https://dlang.org/phobos/dmd_access.html

Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/access.d

- `checkAccess`

  #### Declaration

  `bool `checkAccess`(AggregateDeclaration `ad`, Loc `loc`, Scope* `sc`, Dsymbol `smember`);`

  Do access check for member of this class, this class being the type of the 'this' pointer used to access `smember`. Returns `true` if the member is not accessible.

- `checkAccess`

  #### Declaration

  `bool `checkAccess`(Loc `loc`, Scope* `sc`, Expression `e`, Declaration `d`);`

  Check access to `d` for expression `e`.`d` Returns `true` if the declaration is not accessible.

- `checkAccess`

  #### Declaration

  `bool `checkAccess`(Scope* `sc`, Package `p`);`

  Check access to package/module ``p`` from scope ``sc``.

  #### Parameters

  `Scope* `sc`` | scope from which to access to a fully qualified package name
  `Package `p`` | the package/module to check access for

  #### Return Value

  `true` if the package is not accessible.
  Because a global symbol table tree is used for imported packages/modules, access to them needs to be checked based on the imports in the scope chain (see https://issues.dlang.org/show_bug.cgi?id=313).

- `symbolIsVisible`

  #### Declaration

  `bool `symbolIsVisible`(Module `mod`, Dsymbol `s`);`

  Check whether symbols ``s`` is visible in ``mod``.

  #### Parameters

  `Module `mod`` | lookup origin
  `Dsymbol `s`` | symbol to check for visibility

  #### Return Value

  `true` if `s` is visible in `mod`

- `symbolIsVisible`

  #### Declaration

  `bool `symbolIsVisible`(Dsymbol `origin`, Dsymbol `s`);`

  Same as above, but determines the lookup module from symbols ``origin``.

- `symbolIsVisible`

  #### Declaration

  `bool `symbolIsVisible`(Scope* `sc`, Dsymbol `s`);`

  Same as above but also checks for protected symbols visible from scope ``sc``. Used for qualified name lookup.

  #### Parameters

  `Scope* `sc`` | lookup scope
  `Dsymbol `s`` | symbol to check for visibility

  #### Return Value

  `true` if `s` is visible by origin

- `checkSymbolAccess`

  #### Declaration

  `bool `checkSymbolAccess`(Scope* `sc`, Dsymbol `s`);`

  Check if a symbol is visible from a given scope without taking into account the most visible overload.

  #### Parameters

  `Scope* `sc`` | lookup scope
  `Dsymbol `s`` | symbol to check for visibility

  #### Return Value

  `true` if `s` is visible by origin

- `mostVisibleOverload`

  #### Declaration

  `Dsymbol `mostVisibleOverload`(Dsymbol `s`, Module `mod` = null);`

  Use the most visible overload to check visibility. Later perform an access check on the resolved overload. This function is similar to overloadApply, but doesn't recurse nor resolve aliases because protection/visibility is an attribute of the alias not the aliasee.