Skip to content

Commit 6adab3c

Browse files
committed
AST: Assert if unsubstituted requirements passed in to checkRequirements()
1 parent f9e7181 commit 6adab3c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/AST/Requirement.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,22 @@ CheckRequirementsResult swift::checkRequirements(ArrayRef<Requirement> requireme
253253

254254
while (!worklist.empty()) {
255255
auto req = worklist.pop_back_val();
256+
257+
// Check preconditions.
258+
#ifndef NDEBUG
259+
{
260+
auto firstType = req.getFirstType();
261+
assert(!firstType->hasTypeParameter());
262+
assert(!firstType->hasTypeVariable());
263+
264+
if (req.getKind() != RequirementKind::Layout) {
265+
auto secondType = req.getSecondType();
266+
assert(!secondType->hasTypeParameter());
267+
assert(!secondType->hasTypeVariable());
268+
}
269+
}
270+
#endif
271+
256272
switch (req.checkRequirement(worklist, /*allowMissing=*/true)) {
257273
case CheckRequirementResult::Success:
258274
case CheckRequirementResult::ConditionalConformance:

0 commit comments

Comments
 (0)