File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -3840,15 +3840,20 @@ static bool isRawRepresentableGenericFunction(
3840
3840
ASTContext &ctx, const ValueDecl *witness,
3841
3841
const NormalProtocolConformance *conformance) {
3842
3842
auto *fnDecl = dyn_cast<AbstractFunctionDecl>(witness);
3843
- return fnDecl && fnDecl->isGeneric () &&
3843
+ if (!fnDecl || !fnDecl->isStdlibDecl ())
3844
+ return false ;
3845
+
3846
+ return fnDecl->isGeneric () && fnDecl->getGenericParams ()->size () == 1 &&
3847
+ fnDecl->getGenericRequirements ().size () == 2 &&
3844
3848
llvm::all_of (
3845
3849
fnDecl->getGenericRequirements (), [&](Requirement genericReq) {
3846
- return genericReq.getKind () == RequirementKind::Conformance &&
3847
- (genericReq.getProtocolDecl () ==
3848
- ctx.getProtocol (
3849
- KnownProtocolKind::RawRepresentable) ||
3850
- genericReq.getProtocolDecl () ==
3851
- conformance->getProtocol ());
3850
+ if (genericReq.getKind () != RequirementKind::Conformance)
3851
+ return false ;
3852
+ return genericReq.getProtocolDecl () ==
3853
+ ctx.getProtocol (
3854
+ KnownProtocolKind::RawRepresentable) ||
3855
+ genericReq.getProtocolDecl () ==
3856
+ conformance->getProtocol ();
3852
3857
});
3853
3858
}
3854
3859
You can’t perform that action at this time.
0 commit comments