Skip to content

Fix more InternalImportsByDefault errors #7905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Aug 21, 2024

SwiftPM doesn't build with all toolchains when the InternalImportsByDefault upcoming feature is properly enabled.

Motivation:

With the upcoming feature InternalImportsByDefault enabled, some versions of the Swift compiler diagnose this pattern:

import protocol _Concurrency.Actor

// error: package protocol cannot refine an internal protocol
package protocol Proto: Actor {
  // ...
}

Modifications:

Address these diagnostics by using correct access levels for direct imports of _Concurrency.

Result:

SwiftPM builds with all relevant Swift compilers with InternalImportsByDefault enabled.

@tshortli
Copy link
Contributor Author

This is a follow on to #7895.

@MaxDesiatov
Copy link
Contributor

@swift-ci test windows

@MaxDesiatov
Copy link
Contributor

IIRC _Concurrency is not imported implicitly when building with CMake, that's why those imports were added in the first place

@tshortli
Copy link
Contributor Author

IIRC _Concurrency is not imported implicitly when building with CMake, that's why those imports were added in the first place

I see, I wonder if that is due to -disable-implicit-concurrency-module-import getting passed down in CMake builds for some reason? It's hard for me to imagine a reason why that flag would be needed by anything in SwiftPM, maybe it's a mistake?

With the upcoming feature `InternalImportsByDefault` enabled, some versions of
the Swift compiler diagnose this pattern:

```
import protocol _Concurrency.Actor

// error: package protocol cannot refine an internal protocol
package protocol Proto: Actor {
  // ...
}
```

Address these diagnostics by using correct access levels for direct imports of
`_Concurrency`.
@tshortli tshortli force-pushed the package-protocol-cannot-refine-internal branch from b557c3a to c3b39cf Compare August 21, 2024 22:52
@tshortli
Copy link
Contributor Author

@swift-ci please test

@tshortli
Copy link
Contributor Author

Yeah, the flag seems to be intentional:

> rg disable-implicit-concurrency-module-import
Utilities/bootstrap
671:        swiftpm_args += ["-Xswiftc", "-Xfrontend", "-Xswiftc", "-disable-implicit-concurrency-module-import"]

Sources/swift-bootstrap/main.swift
221:            "-Xfrontend", "-disable-implicit-concurrency-module-import",

Maybe that dates from the days before _Concurrency was available ubiquitously? In any case, I won't question it for now. I've put the imports back and tried to thread the needle differently.

@bnbarham
Copy link
Contributor

Yeah, the flag seems to be intentional:

Can probably remove. It is indeed from before _Concurrency was always available. I recently removed it from the manifest build themselves, I just missed that bootstrap was also doing it.

@tshortli
Copy link
Contributor Author

@swift-ci please test Windows

@tshortli tshortli enabled auto-merge (squash) August 22, 2024 03:16
@tshortli tshortli merged commit aa82ab3 into swiftlang:main Aug 22, 2024
5 checks passed
@tshortli tshortli deleted the package-protocol-cannot-refine-internal branch August 22, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants