[Swift 6.0 regression] Cannot inherit from some Foundation classes on Linux "because it has overridable members that could not be loaded"

Reported as both an RxSwift issue, as well as a swift-corelibs-foundation issue.

repro.swift:3:7: error: cannot inherit from class 'NSLock' (compiled with Swift 6.0) because it has overridable members that could not be loaded in Swift 5.10
1 | import Foundation
2 | 
3 | class FooLock: NSLock {}
  |       `- error: cannot inherit from class 'NSLock' (compiled with Swift 6.0) because it has overridable members that could not be loaded in Swift 5.10
4 | 

We've hit this for a while on nightly toolchains, and I've verified that it also reproduces with the Swift 6.0 release. Bisecting between past nightly toolchains shows that the regression was introduced with the 2024-07-22 nightly. For a while I was skeptical of our build environment, but it seems that the Linux build of RxSwift in the Swift Package Index independently confirms the issue.

I'm shouting a bit more widely now that this has escaped to a release, looking for a way forward and answers to a few questions. Happy to assist with any triage or legwork here.

Is this source breakage intentional? If so, we can focus on a refactor away from the NSLock inheritance.

Is this some non-Darwin fallout from the Foundation re-core? I've seen mention of the re-core, and the dates of the known good (07-15) and known bad (07-22) toolchains do seem to align with that effort, although I don't know enough about it to make any solid conclusions. Would it be worthwhile to try bisecting swift-corelibs-foundation between those tags?

cc @Tony_Parker @jmschonfeld @millenomi @mishal_shah @freak4pc @JaapWijnen

Has there been any progress on this so far? I just got the same error on Swift 6.0 on Linux (GitHub Actions runner):

error: cannot inherit from class 'Thread' because it has overridable members that could not be loaded

And here is the public repo where I encountered this issue (during the build step of my GitHub Actions) if it is needed: GitHub - RussBaz/swift-uv

The most recent updates (including a viable, but discouraged workaround) can be found in this issue: Linux specific regression -- error: cannot inherit from class 'NSLock' because it has overridable members that could not be loaded · Issue #5108 · swiftlang/swift-corelibs-foundation · GitHub.

1 Like