Skip to content

Commit 4d4bac2

Browse files
authored
Revert "[Archetype builder] Mark same-type constraints on nested types as redundant." (#5866)
This reverts commit 6a7d257. The fix was too aggressive, and ended up dropping requirements that are required. Fixes rdar://problem/29332919
1 parent d1fcd5b commit 4d4bac2

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
@@ -1312,7 +1312,6 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
13121312
}
13131313

13141314
// Recursively resolve the associated types to their concrete types.
1315-
RequirementSource nestedSource(RequirementSource::Redundant, Source.getLoc());
13161315
for (auto nested : T->getNestedTypes()) {
13171316
AssociatedTypeDecl *assocType
13181317
= nested.second.front()->getResolvedAssociatedType();
@@ -1321,7 +1320,7 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
13211320
concreteArchetype->getNestedType(nested.first);
13221321
addSameTypeRequirementToConcrete(nested.second.front(),
13231322
witnessType.getValue(),
1324-
nestedSource);
1323+
Source);
13251324
} else {
13261325
assert(conformances.count(assocType->getProtocol()) > 0
13271326
&& "missing conformance?");
@@ -1338,11 +1337,11 @@ bool ArchetypeBuilder::addSameTypeRequirementToConcrete(
13381337
if (auto witnessPA = resolveArchetype(witnessType)) {
13391338
addSameTypeRequirementBetweenArchetypes(nested.second.front(),
13401339
witnessPA,
1341-
nestedSource);
1340+
Source);
13421341
} else {
13431342
addSameTypeRequirementToConcrete(nested.second.front(),
13441343
witnessType,
1345-
nestedSource);
1344+
Source);
13461345
}
13471346
}
13481347
}

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)