Skip to content

Conversation

gjcairo
Copy link
Collaborator

@gjcairo gjcairo commented Aug 2, 2024

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 imports 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.

@gjcairo gjcairo added the version/v2 Relates to v2 label Aug 2, 2024
@gjcairo gjcairo requested a review from glbrntt August 2, 2024 14:26
.grpcProtobuf
],
swiftSettings: [._swiftLanguageMode(.v5), .enableUpcomingFeature("ExistentialAny")]
swiftSettings: [._swiftLanguageMode(.v6), .enableUpcomingFeature("ExistentialAny")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one doesn't have "InternalImportsByDefault"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's because there are a bunch of generated files in this module. I will enable it for this one in a follow up PR after I've changed the code generator.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks for clarifying!

@gjcairo gjcairo requested a review from glbrntt August 5, 2024 14:33
Copy link
Collaborator

@glbrntt glbrntt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks Gus!

@glbrntt glbrntt merged commit 58acae6 into grpc:main Aug 5, 2024
@glbrntt glbrntt mentioned this pull request Aug 5, 2024
@gjcairo gjcairo deleted the import-visibility branch August 7, 2024 15:40
gjcairo added a commit that referenced this pull request Aug 12, 2024
…tor (#2010)

## Motivation
This is a follow-up of #2003.
As of 5.9, Swift supports access-level modifiers on imports. In an
upcoming Swift 6.x release, the default modifier will become `internal`.

## Modifications
This PR adds explicit access-level modifiers to the generated code and a
few other modules that use this generated code.

## Result
Explicit access level imports present in more places.
glbrntt pushed a commit to grpc/grpc-swift-protobuf that referenced this pull request Sep 20, 2024
…tor (#2010)

## Motivation
This is a follow-up of grpc/grpc-swift#2003.
As of 5.9, Swift supports access-level modifiers on imports. In an
upcoming Swift 6.x release, the default modifier will become `internal`.

## Modifications
This PR adds explicit access-level modifiers to the generated code and a
few other modules that use this generated code.

## Result
Explicit access level imports present in more places.
glbrntt pushed a commit to grpc/grpc-swift-nio-transport that referenced this pull request Sep 20, 2024
…tor (#2010)

## Motivation
This is a follow-up of grpc/grpc-swift#2003.
As of 5.9, Swift supports access-level modifiers on imports. In an
upcoming Swift 6.x release, the default modifier will become `internal`.

## Modifications
This PR adds explicit access-level modifiers to the generated code and a
few other modules that use this generated code.

## Result
Explicit access level imports present in more places.
glbrntt pushed a commit to grpc/grpc-swift-extras that referenced this pull request Sep 20, 2024
…tor (#2010)

## Motivation
This is a follow-up of grpc/grpc-swift#2003.
As of 5.9, Swift supports access-level modifiers on imports. In an
upcoming Swift 6.x release, the default modifier will become `internal`.

## Modifications
This PR adds explicit access-level modifiers to the generated code and a
few other modules that use this generated code.

## Result
Explicit access level imports present in more places.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

version/v2 Relates to v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants