Commit Graph

12 Commits

Author SHA1 Message Date
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
5072b303ff [Serialization] Ignore missing potentially optional dependencies in getImportedModules
The service `ModuleFile::getImportedModules` is called after the
dependency loading logic runs. We can trust this previous logic to have
correctly loaded optional dependencies. In `getImportedModules` we can
just ignore such missing dependencies.

rdar://115372249
2023-09-12 17:32:32 -07:00
Alexis Laferrière
ea2465dea6 [Sema] Report uses of package import without a package name 2023-09-05 17:33:49 -07:00
Alexis Laferrière
ab939a44cf [Serialization] Add 2 scenarios to the test for transitive testable dependencies
* A multi-file scenario where one file has a normal import and the other
  a testable import. In this case we still load the extra dependencies
  and show diagnostics only of the testable import.

* A scenario where module A @testable imports module B, which @_exported
  imports module C. In this case, non-public imports of B are loaded,
  but not those of C. This is a limitation of the current implementation
  and could be improved upon in the future.
2023-03-29 13:59:29 -07:00
Alexis Laferrière
f7f69c6ae1 [Serialization] Load non-public transitive dependencies on @testable imports
A @testable import allows a client to call internal decls which may
refer to non-public dependencies. To support such a use case, load
non-public transitive dependencies of a module when it's imported
@testable from the main module.

This replaces the previous behavior where we loaded those dependencies
for any modules built for testing. This was risky as we would load more
module for any debug build, opening the door to a different behavior
between debug and release builds. In contrast, applying this logic to
@testable clients will only change the behavior of test targets.

rdar://107329303
2023-03-29 13:59:28 -07:00
Alexis Laferrière
599346885e [Serialization] Differentiate module loading behavior for non-public imports
Differentiate `internal` and `fileprivate` imports from
implementation-only imports at the module-wide level to offer a
different module loading strategy. The main difference is for non-public
imports from a module with testing enabled to be loaded by transitive
clients.

Ideally, we would only load transitive non-public dependencies on
testable imports of the middle module. The current module loading logic
doesn't allow for this behavior easily as a module may be first loaded
for a normal import and extra dependencies would have to be loaded on
later imports. We may want to refactor the module loading logic to allow
this if needed.

rdar://106514965
2023-03-21 16:46:53 -07:00
Alexis Laferrière
f4d2d2a30f [Sema] Reenable access-level on imports tests 2023-03-14 09:35:24 -07:00
swift-ci
bdb484ac89 Merge pull request #64092 from meg-gupta/disabletests
Disabling tests failing in CI
2023-03-04 11:18:10 -08:00
Meghana Gupta
b262311f24 Disable access level import tests 2023-03-03 17:33:30 -08:00
Alexis Laferrière
732a7f68e3 [Sema] Update test tracking dependencies of access-level on imports
This general test applies to all access-level. Let's precise that it
tests the scenario where a client is outside of the package to preserve
the current behavior. A new tests will check the behavior of a package
dependency for clients in package.
2023-03-03 11:42:59 -08:00
Alexis Laferrière
0d82ba3059 [ModuleInterface] Fixup tests about access-level on imports and dependencies 2023-03-01 14:41:11 -08:00
Alexis Laferrière
94aeb8c0ff [ModuleInterface] Hide non-public imports from a resilient module
When using access level on imports, consider non-public imports to be
implementation details not exposed to clients. As such, a client loading
a library doesn't need to load non-public transitive dependencies.

This behave like `@_implementationOnly imports` at a module-wide level,
but it is restricted to resilient modules only. An import with any
access-level in a non-resilient module remains visible to transitive
clients.
2023-03-01 00:11:59 -08:00