Skip to content

Remove a couple of over-eager assertions #65177

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
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
13 changes: 2 additions & 11 deletions include/swift/SIL/AbstractionPattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,6 @@ class AbstractionPattern {
assert(OrigType == signature.getReducedType(origType));
GenericSig = signature;
}
assert(!subs || !OrigType->hasTypeParameter() ||
subs.getGenericSignature()->isEqual(
getGenericSignatureForFunctionComponent()));
}

void initClangType(SubstitutionMap subs, CanGenericSignature signature,
Expand Down Expand Up @@ -1089,15 +1086,9 @@ class AbstractionPattern {
AbstractionPattern withSubstitutions(SubstitutionMap subs) const {
AbstractionPattern result = *this;
if (subs) {
#ifndef NDEBUG
// If we have a generic signature, it should match the substitutions.
// But there are situations in which it's okay that we don't store
// a signature.
auto sig = getGenericSignatureForFunctionComponent();
assert((sig && sig->isEqual(subs.getGenericSignature())) ||
!OrigType ||
!OrigType->hasTypeParameter());
#endif
// But in corner cases, "match" can mean that it applies to an inner
// local generic context, which is not something we can easily assert.
result.GenericSubs = subs;
}
return result;
Expand Down
14 changes: 14 additions & 0 deletions test/SILGen/nested_generics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,20 @@ class SubclassOfInner<T, U> : OuterRing<T>.InnerRing<U> {
}
}

// Reduced from some code in Doggie. rdar://107642925
struct LocalGenericFunc<Element> {
var address: UnsafeMutablePointer<Element>
init(address: UnsafeMutablePointer<Element>) {
self.address = address
}

mutating func foo() {
func helper<S: Sequence>(_ newElements: S) where S.Element == Element {
let buffer = address
}
}
}

// 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) {
// 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>):
// CHECK: [[SELF_COPY_VAL:%[0-9]+]] = load_borrow [[SELF]] : $*OuterRing<τ_0_0>.InnerRing<τ_1_0>
Expand Down