Skip to content

Revert "[Archetype builder] Mark same-type constraints on nested types as redundant" #5866

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
Nov 20, 2016
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
7 changes: 3 additions & 4 deletions lib/AST/ArchetypeBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,6 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
}

// Recursively resolve the associated types to their concrete types.
RequirementSource nestedSource(RequirementSource::Redundant, Source.getLoc());
for (auto nested : T->getNestedTypes()) {
AssociatedTypeDecl *assocType
= nested.second.front()->getResolvedAssociatedType();
Expand All @@ -1329,7 +1328,7 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
concreteArchetype->getNestedType(nested.first);
addSameTypeRequirementToConcrete(nested.second.front(),
witnessType.getValue(),
nestedSource);
Source);
} else {
assert(conformances.count(assocType->getProtocol()) > 0
&& "missing conformance?");
Expand All @@ -1346,11 +1345,11 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
if (auto witnessPA = resolveArchetype(witnessType)) {
addSameTypeRequirementBetweenArchetypes(nested.second.front(),
witnessPA,
nestedSource);
Source);
} else {
addSameTypeRequirementToConcrete(nested.second.front(),
witnessType,
nestedSource);
Source);
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions test/Generics/requirement_inference.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,6 @@ func inferSameType2<T : P3, U : P4>(_: T) where U.P4Assoc : P2, T.P3Assoc == U.P
// CHECK-NEXT: Generic signature
func inferSameType3<T : PCommonAssoc1>(_: T) where T.CommonAssoc : P1, T : PCommonAssoc2 {}

struct X6 : PAssoc {
typealias Assoc = X6
}

// CHECK-LABEL: .inferSameType4@
// CHECK-NEXT: Requirements:
// CHECK-NEXT: T : PAssoc [explicit @
// CHECK-NEXT: T[.PAssoc].Assoc == X6 [explicit
// CHECK-NEXT: T[.PAssoc].Assoc[.PAssoc].Assoc == X6.Assoc [redundant
// CHECK-NEXT: T[.PAssoc].Assoc[.PAssoc].Assoc[.PAssoc].Assoc == X6.Assoc [redundant
// CHECK-NEXT: Generic signature: <T where T : PAssoc, T.Assoc == X6>
// CHECK-NEXT: Canonical generic signature: <τ_0_0 where τ_0_0 : PAssoc, τ_0_0.Assoc == X6>
func inferSameType4<T : PAssoc>(_: T) where T.Assoc : PAssoc, T.Assoc.Assoc : PAssoc, T.Assoc == X6 {}

protocol P5 {
associatedtype Element
}
Expand Down
2 changes: 1 addition & 1 deletion test/SILOptimizer/prespecialize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// CHECK-LABEL: sil [noinline] @_TF13prespecialize4testFTRGSaSi_4sizeSi_T_
//
// function_ref specialized Collection<A where ...>.makeIterator() -> IndexingIterator<A>
// CHECK: function_ref @_TTSgq5GVs14CountableRangeSi_GS_Si_s10Collections___TFesRxs10Collectionwx8IteratorzGVs16IndexingIteratorx_rS_12makeIteratorfT_GS1_x_
// CHECK: function_ref @_TTSgq5SiSis10ComparablesSis11_Strideables___TFVs14CountableRangeCfT15uncheckedBoundsT5lowerx5upperx__GS_x_
//
// function_ref specialized IndexingIterator.next() -> A._Element?
// CHECK: function_ref @_TTSgq5GVs14CountableRangeSi_GS_Si_s14_IndexableBases___TFVs16IndexingIterator4nextfT_GSqwx8_Element_
Expand Down