Skip to content

Commit 4bf2398

Browse files
committed
GSB: Fix off-by-one error when merging layout requirements of two equivalence classes
Literally an off-by-one error -- we were skipping over the first requirement and not copying it over. I think this is because the updateLayout() call used to be addLayoutRequirementDirect(), which would add the first layout constraint, and I forgot to remove the '+ 1' when I refactored this.
1 parent d311549 commit 4bf2398

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5129,7 +5129,7 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenTypeParameters(
51295129
updateLayout(T1, equivClass2->layout);
51305130
equivClass->layoutConstraints.insert(
51315131
equivClass->layoutConstraints.end(),
5132-
equivClass2->layoutConstraints.begin() + 1,
5132+
equivClass2->layoutConstraints.begin(),
51335133
equivClass2->layoutConstraints.end());
51345134
}
51355135
}

test/Generics/derived_via_concrete.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,14 @@ func derivedViaConcreteZ1<A, B>(_: A, _: B)
6060
// expected-warning@-1 {{redundant conformance constraint 'A' : 'W'}}
6161
// expected-note@-2 {{conformance constraint 'A' : 'W' implied here}}
6262

63+
// FIXME: We should not diagnose 'B : AnyObject' as redundant, even
64+
// though it really is, because it was made redundant by an inferred
65+
// requirement.
66+
6367
// CHECK: Generic signature: <A, B where A : Z<B>, B : AnyObject>
6468
func derivedViaConcreteZ2<A, B>(_: A, _: B)
6569
where A : W, B : AnyObject, A : Z<B> {}
6670
// expected-warning@-1 {{redundant conformance constraint 'A' : 'W'}}
67-
// expected-note@-2 {{conformance constraint 'A' : 'W' implied here}}
71+
// expected-note@-2 {{conformance constraint 'A' : 'W' implied here}}
72+
// expected-warning@-3 {{redundant constraint 'B' : 'AnyObject'}}
73+
// expected-note@-4 {{constraint 'B' : 'AnyObject' implied here}}

0 commit comments

Comments
 (0)