Skip to content

[Generic environment] Only substitute top-level archetypes. #8840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/AST/GenericEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ Type GenericEnvironment::QueryArchetypeToInterfaceSubstitutions::operator()(
auto archetype = type->getAs<ArchetypeType>();
if (!archetype) return Type();

// Only top-level archetypes need to be substituted directly; nested
// archetypes will be handled via their root archetypes.
if (archetype->getParent()) return Type();

// If not all generic parameters have had their context types recorded,
// perform a linear search.
auto genericParams = self->Signature->getGenericParams();
Expand Down
14 changes: 14 additions & 0 deletions validation-test/compiler_crashers_2_fixed/0090-sr4617.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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
}
}
}