This PR adds a missing access level diagnostic when type checking
named patterns by walking the interface type to find the importing
decl to emit the diagnostic for.
Access-level on imports limit where decls from the target module can
be referenced. This is reported by the typical error about and a note
on the import. However, when using an IDE and editing a large file,
the note on the import is easy to miss. Address this by duplicating
the information on the error line as well so it's never out of the
current viewport.
rdar://119438201
Stop relying on a separate access-level from the access-scope to show
and prioritize diagnostics. This change should be NFC but it does break some
tests. This only affects the prioritization of which of many offending type
is the worst and should be pointed to, the logic remains sound.
Using an access-level on an import downgrades imported decl from public
to the import's access-level. When we can identify which decl is
problematic, name it in the note displayed on the import. This should
help understanding the effect of the import's access level on the decl
causing an error further down in the source file.
Check the API of decls to ensure that imported types are only used in
decls with compatible access-level. For example, error on using a type
import as internal in a public function, but allow it in internal
functions and lower.
This change raises errors on wrongful use of types limited by an import
and offers a note pointing to the import that did limit the imported
type.