Skip to content

Commit 21fa110

Browse files
authored
Merge pull request #65177 from rjmccall/remove-abstraction-pattern-subs-assertion
Remove a couple of over-eager assertions
2 parents f13e131 + 9bf4e8c commit 21fa110

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

include/swift/SIL/AbstractionPattern.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,6 @@ class AbstractionPattern {
524524
assert(OrigType == signature.getReducedType(origType));
525525
GenericSig = signature;
526526
}
527-
assert(!subs || !OrigType->hasTypeParameter() ||
528-
subs.getGenericSignature()->isEqual(
529-
getGenericSignatureForFunctionComponent()));
530527
}
531528

532529
void initClangType(SubstitutionMap subs, CanGenericSignature signature,
@@ -1089,15 +1086,9 @@ class AbstractionPattern {
10891086
AbstractionPattern withSubstitutions(SubstitutionMap subs) const {
10901087
AbstractionPattern result = *this;
10911088
if (subs) {
1092-
#ifndef NDEBUG
10931089
// If we have a generic signature, it should match the substitutions.
1094-
// But there are situations in which it's okay that we don't store
1095-
// a signature.
1096-
auto sig = getGenericSignatureForFunctionComponent();
1097-
assert((sig && sig->isEqual(subs.getGenericSignature())) ||
1098-
!OrigType ||
1099-
!OrigType->hasTypeParameter());
1100-
#endif
1090+
// But in corner cases, "match" can mean that it applies to an inner
1091+
// local generic context, which is not something we can easily assert.
11011092
result.GenericSubs = subs;
11021093
}
11031094
return result;

test/SILGen/nested_generics.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,20 @@ class SubclassOfInner<T, U> : OuterRing<T>.InnerRing<U> {
223223
}
224224
}
225225

226+
// Reduced from some code in Doggie. rdar://107642925
227+
struct LocalGenericFunc<Element> {
228+
var address: UnsafeMutablePointer<Element>
229+
init(address: UnsafeMutablePointer<Element>) {
230+
self.address = address
231+
}
232+
233+
mutating func foo() {
234+
func helper<S: Sequence>(_ newElements: S) where S.Element == Element {
235+
let buffer = address
236+
}
237+
}
238+
}
239+
226240
// CHECK-LABEL: sil private [transparent] [thunk] [ossa] @$s15nested_generics9OuterRingC05InnerD0Cyx_qd__GAA30ProtocolWithGenericRequirementA2aGP6method1t1u1v1TQz_1UQzqd__tAN_APqd__tlFTW : $@convention(witness_method: ProtocolWithGenericRequirement) <τ_0_0><τ_1_0><τ_2_0> (@in_guaranteed τ_0_0, @in_guaranteed τ_1_0, @in_guaranteed τ_2_0, @in_guaranteed OuterRing<τ_0_0>.InnerRing<τ_1_0>) -> (@out τ_0_0, @out τ_1_0, @out τ_2_0) {
227241
// CHECK: bb0([[T:%[0-9]+]] : $*τ_0_0, [[U:%[0-9]+]] : $*τ_1_0, [[V:%[0-9]+]] : $*τ_2_0, [[TOut:%[0-9]+]] : $*τ_0_0, [[UOut:%[0-9]+]] : $*τ_1_0, [[VOut:%[0-9]+]] : $*τ_2_0, [[SELF:%[0-9]+]] : $*OuterRing<τ_0_0>.InnerRing<τ_1_0>):
228242
// CHECK: [[SELF_COPY_VAL:%[0-9]+]] = load_borrow [[SELF]] : $*OuterRing<τ_0_0>.InnerRing<τ_1_0>

0 commit comments

Comments
 (0)