public protocol P {
associatedtype AT
}
@dynamicMemberLookup
public struct S<A> {
public subscript<B>(dynamicMember keyPath: KeyPath<A.AT, B>) -> S<B>
where A: P {
fatalError()
}
}
extension Result: P {
public struct AT {
public var success: Success {
fatalError()
}
}
}
func f() {
// This compiles fine.
let kp = \S<Result<Void, Never>>.success
}
In the tests:
import KeyPathCrossModuleBug
func f() {
// This compiles in the main target but not here.
let kp = \S<Result<Void, Never>>.success
}
Description
Code that compiled fine in Swift 5 is now crashing in Swift 6.
Reproduction
key-path-cross-module-bug.zip
I tried to reduce this as best as I can.
In the library:
In the tests:
Stack dump
Expected behavior
I expect it to compile just fine as it did in Swift 5.
Environment
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2) Target: arm64-apple-macosx15.0
Additional information
This crash is affecting the swift-case-paths library.