Skip to content

Commit 401d297

Browse files
committed
AST: Fix crash on invalid in isVanishingTupleConformance()
1 parent d22a247 commit 401d297

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/AST/ProtocolConformance.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -990,9 +990,12 @@ static bool isVanishingTupleConformance(
990990

991991
auto replacementTypes = substitutions.getReplacementTypes();
992992
assert(replacementTypes.size() == 1);
993-
auto packType = replacementTypes[0]->castTo<PackType>();
994993

995-
return (packType->getNumElements() == 1 &&
994+
// This might not be an actual pack type with an invalid tuple conformance.
995+
auto packType = replacementTypes[0]->getAs<PackType>();
996+
997+
return (packType &&
998+
packType->getNumElements() == 1 &&
996999
!packType->getElementTypes()[0]->is<PackExpansionType>());
9971000
}
9981001

0 commit comments

Comments
 (0)