Skip to content

Commit 6d90d16

Browse files
committed
Sema: Use ASSERT before getting trailing objects of Constraint
If the precondition doesn't hold, we will return a pointer to some random memory, so it's best to always crash since this indicates something is seriously wrong.
1 parent 83118a7 commit 6d90d16

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

include/swift/Sema/Constraint.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
872872

873873
/// Retrieve the overload choice for an overload-binding constraint.
874874
OverloadChoice getOverloadChoice() const {
875-
assert(Kind == ConstraintKind::BindOverload);
875+
ASSERT(Kind == ConstraintKind::BindOverload);
876876
return *getTrailingObjects<OverloadChoice>();
877877
}
878878

@@ -903,7 +903,7 @@ class Constraint final : public llvm::ilist_node<Constraint>,
903903

904904
/// Retrieve the DC in which the overload was used.
905905
DeclContext *getDeclContext() const {
906-
assert(HasDeclContext);
906+
ASSERT(HasDeclContext);
907907
return *getTrailingObjects<DeclContext *>();
908908
}
909909

0 commit comments

Comments
 (0)