File tree 1 file changed +11
-5
lines changed
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -648,15 +648,21 @@ swift::matchWitness(
648
648
} else if (isa<ConstructorDecl>(witness)) {
649
649
decomposeFunctionType = true ;
650
650
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.
653
654
if (enumCase->hasAssociatedValues () && isa<VarDecl>(req))
654
655
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))
657
659
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 ())
659
663
return RequirementMatch (witness, MatchKind::StaticNonStaticConflict);
664
+
665
+ // An enum case cannot satisfy a settable property requirement.
660
666
if (isa<VarDecl>(req) &&
661
667
cast<VarDecl>(req)->isSettable (req->getDeclContext ()))
662
668
return RequirementMatch (witness, MatchKind::SettableConflict);
You can’t perform that action at this time.
0 commit comments