Browse Source

Enable `InternalImportsByDefault` in v2 modules (#2003)

Starting with Swift 5.10, `InternalImportsByDefault` is an optional feature flag to make all `import` statements be `internal` by default, instead of `public`, which has been the default since the beginning in Swift.
With a future language mode, this will become the new default, and all imports will be `internal` unless otherwise specified. The main reason for this change is to minimise dependency creep.

This PR enables the feature flag on v2 modules, and adds `public`/`package` access modifiers to `import`s where required.

Note that sadly, `@usableFromInline` has not been implemented for `import` statements, so in `@inlinable`/`@usableFromInline` contexts where non-publicly-imported types are used, the only workaround for now is to import the module as `public`. I've left a comment next to these imports.
Gustavo Cairo 1 year ago
parent
commit
89004c99da

+ 2 - 2
Sources/GRPCProtobuf/Coding.swift

@@ -14,8 +14,8 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-import GRPCCore
-import SwiftProtobuf
+public import GRPCCore
+public import SwiftProtobuf
 
 
 /// Serializes a Protobuf message into a sequence of bytes.
 /// Serializes a Protobuf message into a sequence of bytes.
 public struct ProtobufSerializer<Message: SwiftProtobuf.Message>: GRPCCore.MessageSerializer {
 public struct ProtobufSerializer<Message: SwiftProtobuf.Message>: GRPCCore.MessageSerializer {

+ 4 - 4
Sources/GRPCProtobufCodeGen/ProtobufCodeGenParser.swift

@@ -14,11 +14,11 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-import Foundation
-import SwiftProtobuf
-import SwiftProtobufPluginLibrary
+internal import Foundation
+internal import SwiftProtobuf
+internal import SwiftProtobufPluginLibrary
 
 
-import struct GRPCCodeGen.CodeGenerationRequest
+internal import struct GRPCCodeGen.CodeGenerationRequest
 
 
 /// Parses a ``FileDescriptor`` object into a ``CodeGenerationRequest`` object.
 /// Parses a ``FileDescriptor`` object into a ``CodeGenerationRequest`` object.
 internal struct ProtobufCodeGenParser {
 internal struct ProtobufCodeGenParser {

+ 2 - 2
Sources/GRPCProtobufCodeGen/ProtobufCodeGenerator.swift

@@ -14,8 +14,8 @@
  * limitations under the License.
  * limitations under the License.
  */
  */
 
 
-import GRPCCodeGen
-import SwiftProtobufPluginLibrary
+public import GRPCCodeGen
+public import SwiftProtobufPluginLibrary
 
 
 public struct ProtobufCodeGenerator {
 public struct ProtobufCodeGenerator {
   internal var configuration: SourceGenerator.Configuration
   internal var configuration: SourceGenerator.Configuration