Skip to content

Commit 8cae987

Browse files
committed
Fix the assert
1 parent 542a8b4 commit 8cae987

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

stdlib/public/runtime/Casting.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,10 +669,12 @@ isAnyObjectExistentialType(const ExistentialTypeMetadata *targetType) {
669669
if (numProtos != 1)
670670
return false;
671671
const ProtocolDescriptor *protocol = targetType->Protocols[0];
672+
bool isAnyObjectProtocol =
673+
protocol->Flags.getSpecialProtocol() == SpecialProtocol::AnyObject;
672674
// Assert that AnyObject does not need any witness tables. We rely on this.
673-
assert(!protocol->Flags.needsWitnessTable() &&
675+
assert(!isAnyObjectProtocol || !protocol->Flags.needsWitnessTable() &&
674676
"AnyObject should not require witness tables");
675-
return (protocol->Flags.getSpecialProtocol() == SpecialProtocol::AnyObject);
677+
return isAnyObjectProtocol;
676678
}
677679

678680
/// Given a possibly-existential value, find its dynamic type and the

0 commit comments

Comments
 (0)