Deprecated implementation-only imports (ImplementationOnlyDeprecated)
Warnings that identify import declarations with the @_implementationOnly attribute.
Overview
When applied to import declarations, the compiler-internal attribute @_implementationOnly attempts prevents declarations from the imported module from being exposed in the ABI or public interface of the dependent module. This attribute became deprecated when support for access levels on import declarations was introduced with SE-0409: Access level on imports.
One reason @_implementationOnly import is deprecated is that it is unsafe when used in modules that are built without Library evolution enabled. For example, suppose the following code were part of a library named Foo:
// Library `Foo`
@_implementationOnly import ImplementationDetail
public struct Bar {
internal var x: Baz // defined in ImplementationDetail
}If Foo is not compiled with library evolution, then the memory layout of values of Bar must be known at compile time in clients of Foo. However, the @_implementationOnly import of ImplementationDetail prevents clients from being able to look up Baz which is a type that contributes to the layout of Foo. As a result, the layout of Foo will be miscalculated resulting in undefined behavior.
See Also
Related Documentation
SE-0409: Access level on imports- Library evolution
@dynamicCallable implementation requirements (DynamicCallable)Add @preconcurrency import (AddPreconcurrencyImport)Always enabled availability domains (AlwaysAvailableDomain)Argument matching for trailing closures (TrailingClosureMatching)Calling a mutating async actor-isolated method (ActorIsolatedMutatingAsync)Calling an actor-isolated method from a synchronous nonisolated context (ActorIsolatedCall)Captures in a `@Sendable` closure (SendableClosureCaptures)Compilation caching (CompilationCaching)Conforming to `StringInterpolationProtocol` (StringInterpolationConformance)Conversion from `@isolated(any)` function type to synchronous function type (ConversionFromIsolatedAnyToSynchronous)Cross-isolation data race (RegionIsolationCrossIsolationDataRace)Deprecated declaration warnings (DeprecatedDeclaration)Dynamic exclusivity (DynamicExclusivity)Embedded Swift language restrictions (EmbeddedRestrictions)Existential Types and Performance (ExistentialType)