mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix solution application for keypath function subtype conversions
In #39612 we added subtyping for keypaths-as-functions, but during application the implementation naively coerced the keypath expression itself to the inferred supertype, resulting in erroneous results. This patch updates the solution application logic to build the keypath-function conversion expression based entirely on the 'natural' keypath type, only converting to the inferred supertype at the end via the usual coerceToType machinery for function conversions.
This commit is contained in:
@@ -637,3 +637,18 @@ struct TestKeyPathWithSomeType : DefineSomeType {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// apple/swift#71423
|
||||
protocol CodingKey {}
|
||||
|
||||
struct URICoderCodingKey : CodingKey {}
|
||||
|
||||
struct CodingStackEntry {
|
||||
var key: URICoderCodingKey
|
||||
}
|
||||
|
||||
struct Test {
|
||||
var codingStack: [CodingStackEntry]
|
||||
var codingPath: [any CodingKey] { codingStack.map(\.key) }
|
||||
// CHECK: keypath $KeyPath<CodingStackEntry, URICoderCodingKey>, (root $CodingStackEntry; stored_property #CodingStackEntry.key : $URICoderCodingKey)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user