Commit Graph

9 Commits

Author SHA1 Message Date
Alexis Laferrière
56095cf745 Sema: duplicate the note about which import limits access-level
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
2024-04-22 12:07:31 -07:00
Alexis Laferrière
8b098ab487 [Tests] Remove the flag AccessLevelOnImport from all tests but one 2023-10-10 09:09:22 -07:00
Alexis Laferrière
a0b848ea96 [Sema] Report imports marked as public that are not used in API 2023-09-28 13:00:04 -07:00
Alexis Laferrière
af478fd819 [Sema] Only complain about the import when it does restrict the access level
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.
2023-09-19 16:18:33 -07:00
Alexis Laferrière
1a1df7e9ec [Sema] Apply import restriction in TypeAccessScopeChecker's AccessScope
This cleans up the logic and allows using `private` imported
declarations in `fileprivate` declarations.
2023-09-13 15:40:33 -07:00
Alexis Laferrière
ea2465dea6 [Sema] Report uses of package import without a package name 2023-09-05 17:33:49 -07:00
Becca Royal-Gordon
3732c75e97 Adopt %kind for certain access control diagnostics
These particular changes slightly alter some diagnostics.
2023-07-19 13:06:51 -07:00
Alexis Laferrière
a26fbd2849 [Sema] Improve note on access-level downgrade from import
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.
2023-03-09 09:08:42 -08:00
Alexis Laferrière
75255d153c [Sema] Diagnose exportability of decls limited by a non-public import
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.
2023-03-01 18:35:41 -08:00