young
(rtSwift)
1
Xcode Version 13.0 beta (13A5154h)
let now = Date.now
let range = now..<Date(timeInterval: 25 * 60, since: now)
// why this doesn't work?
range.formatted(.components(style: .abbreviated, fields: [.minute]))
// ^^^^^^^^^ <==== cannot infer this is a Set?
// Compile errors:
// Cannot convert value of type '[Any]' to expected argument type 'Set<Date.ComponentsFormatStyle.Field>?'
// Reference to member 'minute' cannot be resolved without a contextual type
range.formatted(.components(style: .abbreviated, fields: .init([.minute])))
// ^^^^^^^^^ add .init() works
// inference works here
range.formatted(Date.ComponentsFormatStyle(style: .abbreviated, fields: [.minute]))
// ^^^^^^^^^ this here works
So in the static member func components(...), it's not able to convert array literal into a Set. But it works fine in Date.ComponentsFormatStyle(...).
SR-14844