Skip to content

Commit 35a829a

Browse files
committed
NFC: Minor clean-up
1 parent fb8c6bd commit 35a829a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/Sema/TypeCheckProtocol.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -648,15 +648,21 @@ swift::matchWitness(
648648
} else if (isa<ConstructorDecl>(witness)) {
649649
decomposeFunctionType = true;
650650
ignoreReturnType = true;
651-
} else if (isa<EnumElementDecl>(witness)) {
652-
auto enumCase = cast<EnumElementDecl>(witness);
651+
} else if (auto *enumCase = dyn_cast<EnumElementDecl>(witness)) {
652+
// An enum case with associated values can satisfy only a
653+
// method requirement.
653654
if (enumCase->hasAssociatedValues() && isa<VarDecl>(req))
654655
return RequirementMatch(witness, MatchKind::EnumCaseWithAssociatedValues);
655-
auto isValid = isa<VarDecl>(req) || isa<FuncDecl>(req);
656-
if (!isValid)
656+
657+
// An enum case can satisfy only a method or property requirement.
658+
if (!isa<VarDecl>(req) && !isa<FuncDecl>(req))
657659
return RequirementMatch(witness, MatchKind::KindConflict);
658-
if (!cast<ValueDecl>(req)->isStatic())
660+
661+
// An enum case can satisfy only a static requirement.
662+
if (!req->isStatic())
659663
return RequirementMatch(witness, MatchKind::StaticNonStaticConflict);
664+
665+
// An enum case cannot satisfy a settable property requirement.
660666
if (isa<VarDecl>(req) &&
661667
cast<VarDecl>(req)->isSettable(req->getDeclContext()))
662668
return RequirementMatch(witness, MatchKind::SettableConflict);

0 commit comments

Comments
 (0)