mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The core substitution routine for the archetypes-to-interface types substitution was attempting to provide mappings for nested archetypes, when in fact these archetypes would (1) always be resolvable via their parent, and (2) could in fact cause infinite recursion, as with the new test case. Fixes SR-4617 / rdar://problem/31673819.
15 lines
388 B
Swift
15 lines
388 B
Swift
// RUN: %target-swift-frontend -primary-file %s -emit-ir
|
|
|
|
extension Dictionary {
|
|
init<S: Sequence>(grouping elements: S, by keyForValue: (S.Iterator.Element) -> Key)
|
|
where Array<S.Iterator.Element> == Value
|
|
{
|
|
self = [:]
|
|
for value in elements {
|
|
var values = self[keyForValue(value)] ?? []
|
|
values.append(value)
|
|
self[keyForValue(value)] = values
|
|
}
|
|
}
|
|
}
|