@@ -282,10 +282,20 @@ StoredPropertiesAndMissingMembersRequest::evaluate(Evaluator &evaluator,
282
282
// / This query is careful not to trigger accessor macro expansion, which
283
283
// / creates a cycle. It conservatively assumes that all accessor macros
284
284
// / produce computed properties, which is... incorrect.
285
+ // /
286
+ // / The query also avoids triggering a `StorageImplInfoRequest` for patterns
287
+ // / involved in a ProtocolDecl, because we know they can never contain storage.
288
+ // / For background, vars of noncopyable type have their OpaqueReadOwnership
289
+ // / determined by the type of the var decl, but that type hasn't always been
290
+ // / determined when this query is made.
285
291
static bool mayHaveStorage (Pattern *pattern) {
286
- // Check whether there are any accessor macros.
292
+ // Check whether there are any accessor macros, or it's a protocol member .
287
293
bool hasAccessorMacros = false ;
294
+ bool inProtocolDecl = false ;
288
295
pattern->forEachVariable ([&](VarDecl *VD) {
296
+ if (isa<ProtocolDecl>(VD->getDeclContext ()))
297
+ inProtocolDecl = true ;
298
+
289
299
VD->forEachAttachedMacro (MacroRole::Accessor,
290
300
[&](CustomAttr *customAttr, MacroDecl *macro) {
291
301
hasAccessorMacros = true ;
@@ -295,6 +305,10 @@ static bool mayHaveStorage(Pattern *pattern) {
295
305
if (hasAccessorMacros)
296
306
return false ;
297
307
308
+ // protocol members can never contain storage; avoid triggering request.
309
+ if (inProtocolDecl)
310
+ return false ;
311
+
298
312
return pattern->hasStorage ();
299
313
}
300
314
@@ -599,9 +613,13 @@ IsSetterMutatingRequest::evaluate(Evaluator &evaluator,
599
613
OpaqueReadOwnership
600
614
OpaqueReadOwnershipRequest::evaluate (Evaluator &evaluator,
601
615
AbstractStorageDecl *storage) const {
602
- return (storage->getAttrs ().hasAttribute <BorrowedAttr>()
603
- ? OpaqueReadOwnership::Borrowed
604
- : OpaqueReadOwnership::Owned);
616
+ if (storage->getAttrs ().hasAttribute <BorrowedAttr>())
617
+ return OpaqueReadOwnership::Borrowed;
618
+
619
+ if (storage->getValueInterfaceType ()->isPureMoveOnly ())
620
+ return OpaqueReadOwnership::Borrowed;
621
+
622
+ return OpaqueReadOwnership::Owned;
605
623
}
606
624
607
625
// / Insert the specified decl into the DeclContext's member list. If the hint
0 commit comments