@@ -6055,20 +6055,26 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
6055
6055
}
6056
6056
6057
6057
auto proto = conformance->getProtocol ();
6058
- if (proto->isSpecificProtocol (
6059
- KnownProtocolKind::StringInterpolationProtocol)) {
6060
- if (auto typeDecl = dc->getSelfNominalTypeDecl ()) {
6061
- diagnoseMissingAppendInterpolationMethod (typeDecl);
6058
+
6059
+ if (auto kp = proto->getKnownProtocolKind ()) {
6060
+ switch (*kp) {
6061
+ case KnownProtocolKind::StringInterpolationProtocol:
6062
+ if (auto typeDecl = dc->getSelfNominalTypeDecl ()) {
6063
+ diagnoseMissingAppendInterpolationMethod (typeDecl);
6064
+ }
6065
+ break ;
6062
6066
}
6063
- } else if (proto-> isSpecificProtocol ( KnownProtocolKind::Sendable)) {
6064
- SendableConformance = conformance;
6067
+ case KnownProtocolKind::Sendable: {
6068
+ SendableConformance = conformance;
6065
6069
6066
- if (auto normal = conformance->getRootNormalConformance ()) {
6067
- if (isImpliedByConformancePredatingConcurrency (normal))
6068
- sendableConformancePreconcurrency = true ;
6070
+ if (auto normal = conformance->getRootNormalConformance ()) {
6071
+ if (isImpliedByConformancePredatingConcurrency (normal))
6072
+ sendableConformancePreconcurrency = true ;
6073
+ }
6074
+ break ;
6069
6075
}
6070
- } else if (proto-> isSpecificProtocol ( KnownProtocolKind::DistributedActor)) {
6071
- if (auto classDecl = dyn_cast<ClassDecl>(nominal)) {
6076
+ case KnownProtocolKind::DistributedActor: {
6077
+ if (auto classDecl = dyn_cast<ClassDecl>(nominal)) {
6072
6078
if (!classDecl->isDistributedActor ()) {
6073
6079
if (classDecl->isActor ()) {
6074
6080
dc->getSelfNominalTypeDecl ()
@@ -6082,47 +6088,64 @@ void TypeChecker::checkConformancesInContext(IterableDeclContext *idc) {
6082
6088
.fixItReplace (nominal->getStartLoc (), " distributed actor" );
6083
6089
}
6084
6090
}
6091
+ break ;
6085
6092
}
6086
- } else if (proto->isSpecificProtocol (
6087
- KnownProtocolKind::DistributedActorSystem)) {
6088
- checkDistributedActorSystem (nominal);
6089
- } else if (proto->isSpecificProtocol (KnownProtocolKind::Actor)) {
6090
- if (auto classDecl = dyn_cast<ClassDecl>(nominal)) {
6091
- if (!classDecl->isExplicitActor ()) {
6092
- dc->getSelfNominalTypeDecl ()
6093
- ->diagnose (diag::actor_protocol_illegal_inheritance,
6094
- dc->getSelfNominalTypeDecl ()->getName (),
6095
- proto->getName ())
6096
- .fixItReplace (nominal->getStartLoc (), " actor" );
6093
+ case KnownProtocolKind::DistributedActorSystem: {
6094
+ checkDistributedActorSystem (nominal);
6095
+ break ;
6096
+ }
6097
+ case KnownProtocolKind::Actor: {
6098
+ if (auto classDecl = dyn_cast<ClassDecl>(nominal)) {
6099
+ if (!classDecl->isExplicitActor ()) {
6100
+ dc->getSelfNominalTypeDecl ()
6101
+ ->diagnose (diag::actor_protocol_illegal_inheritance,
6102
+ dc->getSelfNominalTypeDecl ()->getName (),
6103
+ proto->getName ())
6104
+ .fixItReplace (nominal->getStartLoc (), " actor" );
6105
+ }
6097
6106
}
6107
+ break ;
6098
6108
}
6099
- } else if (proto->isSpecificProtocol (KnownProtocolKind::AnyActor)) {
6100
- if (auto classDecl = dyn_cast<ClassDecl>(nominal)) {
6101
- if (!classDecl->isExplicitActor () &&
6102
- !classDecl->isExplicitDistributedActor ()) {
6103
- dc->getSelfNominalTypeDecl ()
6104
- ->diagnose (diag::actor_protocol_illegal_inheritance,
6105
- dc->getSelfNominalTypeDecl ()->getName (),
6106
- proto->getName ())
6107
- .fixItReplace (nominal->getStartLoc (), " actor" );
6109
+ case KnownProtocolKind::AnyActor: {
6110
+ if (auto classDecl = dyn_cast<ClassDecl>(nominal)) {
6111
+ if (!classDecl->isExplicitActor () &&
6112
+ !classDecl->isExplicitDistributedActor ()) {
6113
+ dc->getSelfNominalTypeDecl ()
6114
+ ->diagnose (diag::actor_protocol_illegal_inheritance,
6115
+ dc->getSelfNominalTypeDecl ()->getName (),
6116
+ proto->getName ())
6117
+ .fixItReplace (nominal->getStartLoc (), " actor" );
6118
+ }
6108
6119
}
6120
+ break ;
6121
+ }
6122
+ case KnownProtocolKind::UnsafeSendable: {
6123
+ hasDeprecatedUnsafeSendable = true ;
6124
+ break ;
6125
+ }
6126
+ case KnownProtocolKind::Executor: {
6127
+ tryDiagnoseExecutorConformance (Context, nominal, proto);
6128
+ break ;
6129
+ }
6130
+ case KnownProtocolKind::Copyable: {
6131
+ if (NoncopyableGenerics)
6132
+ checkCopyableConformance (dc, conformance);
6133
+ break ;
6134
+ }
6135
+ case KnownProtocolKind::Escapable: {
6136
+ if (NoncopyableGenerics)
6137
+ checkEscapableConformance (dc, conformance);
6138
+ break ;
6109
6139
}
6110
- } else if (proto->isSpecificProtocol (
6111
- KnownProtocolKind::UnsafeSendable)) {
6112
- hasDeprecatedUnsafeSendable = true ;
6113
- } else if (proto->isSpecificProtocol (KnownProtocolKind::Executor)) {
6114
- tryDiagnoseExecutorConformance (Context, nominal, proto);
6115
- } else if (NoncopyableGenerics
6116
- && proto->isSpecificProtocol (KnownProtocolKind::Copyable)) {
6117
- checkCopyableConformance (dc, conformance);
6118
- } else if (NoncopyableGenerics
6119
- && proto->isSpecificProtocol (KnownProtocolKind::Escapable)) {
6120
- checkEscapableConformance (dc, conformance);
6121
- } else if (Context.LangOpts .hasFeature (Feature::BitwiseCopyable) &&
6122
- proto->isSpecificProtocol (KnownProtocolKind::BitwiseCopyable)) {
6123
- checkBitwiseCopyableConformance (
6124
- conformance, /* isImplicit=*/ conformance->getSourceKind () ==
6125
- ConformanceEntryKind::Synthesized);
6140
+ case KnownProtocolKind::BitwiseCopyable: {
6141
+ if (Context.LangOpts .hasFeature (Feature::BitwiseCopyable)) {
6142
+ checkBitwiseCopyableConformance (
6143
+ conformance, /* isImplicit=*/ conformance->getSourceKind () ==
6144
+ ConformanceEntryKind::Synthesized);
6145
+ }
6146
+ break ;
6147
+ default :
6148
+ break ;
6126
6149
}
6127
6150
}
6128
6151
0 commit comments