@@ -166,65 +166,46 @@ Type swift::getDistributedActorIDType(NominalTypeDecl *actor) {
166
166
return getAssociatedTypeOfDistributedSystemOfActor (actor, C.Id_ActorID );
167
167
}
168
168
169
- Type swift::getDistributedActorSystemActorIDType (NominalTypeDecl *system) {
170
- assert (!system->isDistributedActor ());
171
- auto &ctx = system->getASTContext ();
169
+ static Type getTypeWitnessByName (NominalTypeDecl *type, ProtocolDecl *protocol,
170
+ Identifier member) {
171
+ if (!protocol)
172
+ return ErrorType::get (type->getASTContext ());
172
173
173
- auto DAS = ctx.getDistributedActorSystemDecl ();
174
- if (!DAS)
174
+ auto module = type->getParentModule ();
175
+ Type selfType = type->getSelfInterfaceType ();
176
+ auto conformance = module ->lookupConformance (selfType, protocol);
177
+ if (!conformance || conformance.isInvalid ())
175
178
return Type ();
179
+ return conformance.getTypeWitnessByName (selfType, member);
180
+ }
176
181
177
- // Dig out the serialization requirement type.
178
- auto module = system->getParentModule ( );
179
- Type selfType = system->getSelfInterfaceType ();
180
- auto conformance = module -> lookupConformance (selfType, DAS);
181
- return conformance. getTypeWitnessByName (selfType, ctx.Id_ActorID );
182
+ Type swift::getDistributedActorSystemActorIDType (NominalTypeDecl *system) {
183
+ assert (! system->isDistributedActor () );
184
+ auto &ctx = system->getASTContext ();
185
+ return getTypeWitnessByName (system, ctx. getDistributedActorSystemDecl (),
186
+ ctx.Id_ActorID );
182
187
}
183
188
184
189
Type swift::getDistributedActorSystemResultHandlerType (
185
190
NominalTypeDecl *system) {
186
191
assert (!system->isDistributedActor ());
187
192
auto &ctx = system->getASTContext ();
188
-
189
- auto DAS = ctx.getDistributedActorSystemDecl ();
190
- if (!DAS)
191
- return Type ();
192
-
193
- // Dig out the serialization requirement type.
194
- auto module = system->getParentModule ();
195
- Type selfType = system->getSelfInterfaceType ();
196
- auto conformance = module ->lookupConformance (selfType, DAS);
197
- return conformance.getTypeWitnessByName (selfType, ctx.Id_ResultHandler );
193
+ return getTypeWitnessByName (system, ctx.getDistributedActorSystemDecl (),
194
+ ctx.Id_ResultHandler );
198
195
}
199
196
200
197
Type swift::getDistributedActorSystemInvocationEncoderType (NominalTypeDecl *system) {
201
198
assert (!system->isDistributedActor ());
202
199
auto &ctx = system->getASTContext ();
203
-
204
- auto DAS = ctx.getDistributedActorSystemDecl ();
205
- if (!DAS)
206
- return Type ();
207
-
208
- // Dig out the serialization requirement type.
209
- auto module = system->getParentModule ();
210
- Type selfType = system->getSelfInterfaceType ();
211
- auto conformance = module ->lookupConformance (selfType, DAS);
212
- return conformance.getTypeWitnessByName (selfType, ctx.Id_InvocationEncoder );
200
+ return getTypeWitnessByName (system, ctx.getDistributedActorSystemDecl (),
201
+ ctx.Id_InvocationEncoder );
213
202
}
214
203
215
204
Type swift::getDistributedActorSystemInvocationDecoderType (NominalTypeDecl *system) {
216
205
assert (!system->isDistributedActor ());
217
206
auto &ctx = system->getASTContext ();
218
-
219
- auto DAS = ctx.getDistributedActorSystemDecl ();
220
- if (!DAS)
221
- return Type ();
222
-
223
- // Dig out the serialization requirement type.
224
- auto module = system->getParentModule ();
225
- Type selfType = system->getSelfInterfaceType ();
226
- auto conformance = module ->lookupConformance (selfType, DAS);
227
- return conformance.getTypeWitnessByName (selfType, ctx.Id_InvocationDecoder );
207
+ return getTypeWitnessByName (system, ctx.getDistributedActorSystemDecl (),
208
+ ctx.Id_InvocationDecoder );
228
209
}
229
210
230
211
Type swift::getDistributedSerializationRequirementType (
0 commit comments