Files
swift-mirror/validation-test/compiler_crashers_2_fixed/0090-sr4617.swift
Doug Gregor d21d6f1585 [Generic environment] Only substitute top-level archetypes.
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.
2017-04-18 13:19:21 -07:00

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
}
}
}