Skip to content

Commit 387c338

Browse files
authored
Merge pull request swiftlang#18733 from DougGregor/gsb-sanity
2 parents 9eec249 + fa183b3 commit 387c338

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,34 +2280,24 @@ Type EquivalenceClass::getAnchor(
22802280
return substAnchor();
22812281
}
22822282

2283-
// Form the anchor.
2284-
bool updatedAnchor = false;
2283+
// Record the cache miss and update the cache.
2284+
++NumArchetypeAnchorCacheMisses;
2285+
archetypeAnchorCache.anchor =
2286+
builder.getCanonicalTypeParameter(
2287+
members.front()->getDependentType(genericParams));
2288+
archetypeAnchorCache.lastGeneration = builder.Impl->Generation;
2289+
2290+
#ifndef NDEBUG
2291+
// All members must produce the same anchor.
22852292
for (auto member : members) {
22862293
auto anchorType =
22872294
builder.getCanonicalTypeParameter(
22882295
member->getDependentType(genericParams));
2289-
2290-
#ifndef NDEBUG
2291-
// Check that we get consistent results from all of the anchors.
2292-
if (updatedAnchor) {
2293-
assert(anchorType->isEqual(archetypeAnchorCache.anchor) &&
2294-
"Inconsistent anchor computation");
2295-
continue;
2296-
}
2297-
#endif
2298-
2299-
// Record the cache miss and update the cache.
2300-
++NumArchetypeAnchorCacheMisses;
2301-
archetypeAnchorCache.anchor = anchorType;
2302-
archetypeAnchorCache.lastGeneration = builder.Impl->Generation;
2303-
updatedAnchor = true;
2304-
2305-
#if NDEBUG
2306-
break;
2307-
#endif
2296+
assert(anchorType->isEqual(archetypeAnchorCache.anchor) &&
2297+
"Inconsistent anchor computation");
23082298
}
2299+
#endif
23092300

2310-
assert(updatedAnchor && "Couldn't update anchor?");
23112301
return substAnchor();
23122302
}
23132303

0 commit comments

Comments
 (0)