Skip to content

Commit 0ae7671

Browse files
committed
Revert "[Archetype builder] Mark same-type constraints on nested types as redundant."
This reverts commit 6a7d257. The fix was too aggressive, and ended up dropping requirements that are required. Fixes rdar://problem/29332919
1 parent 1f731be commit 0ae7671

File tree

3 files changed

+4
-19
lines changed

3 files changed

+4
-19
lines changed

lib/AST/ArchetypeBuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,6 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
13201320
}
13211321

13221322
// Recursively resolve the associated types to their concrete types.
1323-
RequirementSource nestedSource(RequirementSource::Redundant, Source.getLoc());
13241323
for (auto nested : T->getNestedTypes()) {
13251324
AssociatedTypeDecl *assocType
13261325
= nested.second.front()->getResolvedAssociatedType();
@@ -1329,7 +1328,7 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
13291328
concreteArchetype->getNestedType(nested.first);
13301329
addSameTypeRequirementToConcrete(nested.second.front(),
13311330
witnessType.getValue(),
1332-
nestedSource);
1331+
Source);
13331332
} else {
13341333
assert(conformances.count(assocType->getProtocol()) > 0
13351334
&& "missing conformance?");
@@ -1346,11 +1345,11 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
13461345
if (auto witnessPA = resolveArchetype(witnessType)) {
13471346
addSameTypeRequirementBetweenArchetypes(nested.second.front(),
13481347
witnessPA,
1349-
nestedSource);
1348+
Source);
13501349
} else {
13511350
addSameTypeRequirementToConcrete(nested.second.front(),
13521351
witnessType,
1353-
nestedSource);
1352+
Source);
13541353
}
13551354
}
13561355
}

test/Generics/requirement_inference.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,6 @@ func inferSameType2<T : P3, U : P4>(_: T) where U.P4Assoc : P2, T.P3Assoc == U.P
136136
// CHECK-NEXT: Generic signature
137137
func inferSameType3<T : PCommonAssoc1>(_: T) where T.CommonAssoc : P1, T : PCommonAssoc2 {}
138138

139-
struct X6 : PAssoc {
140-
typealias Assoc = X6
141-
}
142-
143-
// CHECK-LABEL: .inferSameType4@
144-
// CHECK-NEXT: Requirements:
145-
// CHECK-NEXT: T : PAssoc [explicit @
146-
// CHECK-NEXT: T[.PAssoc].Assoc == X6 [explicit
147-
// CHECK-NEXT: T[.PAssoc].Assoc[.PAssoc].Assoc == X6.Assoc [redundant
148-
// CHECK-NEXT: T[.PAssoc].Assoc[.PAssoc].Assoc[.PAssoc].Assoc == X6.Assoc [redundant
149-
// CHECK-NEXT: Generic signature: <T where T : PAssoc, T.Assoc == X6>
150-
// CHECK-NEXT: Canonical generic signature: <τ_0_0 where τ_0_0 : PAssoc, τ_0_0.Assoc == X6>
151-
func inferSameType4<T : PAssoc>(_: T) where T.Assoc : PAssoc, T.Assoc.Assoc : PAssoc, T.Assoc == X6 {}
152-
153139
protocol P5 {
154140
associatedtype Element
155141
}

test/SILOptimizer/prespecialize.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// CHECK-LABEL: sil [noinline] @_TF13prespecialize4testFTRGSaSi_4sizeSi_T_
1212
//
1313
// function_ref specialized Collection<A where ...>.makeIterator() -> IndexingIterator<A>
14-
// CHECK: function_ref @_TTSgq5GVs14CountableRangeSi_GS_Si_s10Collections___TFesRxs10Collectionwx8IteratorzGVs16IndexingIteratorx_rS_12makeIteratorfT_GS1_x_
14+
// CHECK: function_ref @_TTSgq5SiSis10ComparablesSis11_Strideables___TFVs14CountableRangeCfT15uncheckedBoundsT5lowerx5upperx__GS_x_
1515
//
1616
// function_ref specialized IndexingIterator.next() -> A._Element?
1717
// CHECK: function_ref @_TTSgq5GVs14CountableRangeSi_GS_Si_s14_IndexableBases___TFVs16IndexingIterator4nextfT_GSqwx8_Element_

0 commit comments

Comments
 (0)