Commit Graph

5 Commits

Author SHA1 Message Date
Alexis Laferrière
f9fe643e48 Sema: Don't report ambiguities on an explicit public import
Silence errors on ambiguous implicitly public imports when a different import
is explicitly public. In this case all imports are public so the ambiguity is
not dangerous and this configuration can happen during adoption of
access-levels on imports. Keep the error when an explicit import is package,
internal or below.

rdar://129037503
2024-06-05 10:34:26 -07:00
Alexis Laferrière
134b34728b Sema: Reference InternalImportsByDefault as being an upcoming feature 2024-04-22 12:14:44 -07:00
Alexis Laferrière
bd9c385ce5 Sema: Offer solution to silence inconsistent import access-level warnings
Adoption InternalImportsByDefault provides a safe access-level by default
to imports, as such ambiguities are not a risk and showing this warning is
superflous. When this warning is shown, make sure we note this alternative.
2024-04-22 10:52:21 -07:00
Alexis Laferrière
07662fc894 [Sema] Don't report public imports of submodules as being unused in API
An import of a submodule implies an import of its top module, and
referenced decl will be associated with the top module. Make sure
we don't warn on public imports of a submodule being unused in API and
only report if the top module is unused.
2024-01-03 15:27:09 -08:00
Alexis Laferrière
73904ec12f Sema: report inconsistent access levels on imports of one module from one file
Warn on imports of the same target module from the same source file when
they have different access-levels. This situation can lead to unexpected
behavior as the compiler will only take into account the most permissive
import.

In the following example, the module Foundation in functionally imported
as public. The `internal` modifier will be ignored. The new diagnostic
reports it as such.

```
public import Foundation
internal import Foundation // warning: module 'Foundation' is imported
as 'public' from the same file; this 'internal' access level will be
ignored
```

This could be an easy mistake to do when using scoped imports where this
diagnostic will also help.

rdar://117855481
2024-01-03 09:04:49 -08:00