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
Fix the note pointing to the import when using a package type in a
public declaration or inlinable code. We want a note on the import only
when it actually lowers the access level of the imported decl.
The note about a `package import` was simply be superfluous, while the
same note about a `public import` would trigger an assert later on.
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.