@@ -350,41 +350,6 @@ InitAccessorPropertiesRequest::evaluate(Evaluator &evaluator,
350
350
return decl->getASTContext ().AllocateCopy (results);
351
351
}
352
352
353
- // / Check whether the pattern may have storage.
354
- // /
355
- // / This query is careful not to trigger accessor macro expansion, which
356
- // / creates a cycle. It conservatively assumes that all accessor macros
357
- // / produce computed properties, which is... incorrect.
358
- // /
359
- // / The query also avoids triggering a `StorageImplInfoRequest` for patterns
360
- // / involved in a ProtocolDecl, because we know they can never contain storage.
361
- // / For background, vars of noncopyable type have their OpaqueReadOwnership
362
- // / determined by the type of the var decl, but that type hasn't always been
363
- // / determined when this query is made.
364
- static bool mayHaveStorage (Pattern *pattern) {
365
- // Check whether there are any accessor macros, or it's a protocol member.
366
- bool hasAccessorMacros = false ;
367
- bool inProtocolDecl = false ;
368
- pattern->forEachVariable ([&](VarDecl *VD) {
369
- if (isa<ProtocolDecl>(VD->getDeclContext ()))
370
- inProtocolDecl = true ;
371
-
372
- VD->forEachAttachedMacro (MacroRole::Accessor,
373
- [&](CustomAttr *customAttr, MacroDecl *macro) {
374
- hasAccessorMacros = true ;
375
- });
376
- });
377
-
378
- if (hasAccessorMacros)
379
- return false ;
380
-
381
- // protocol members can never contain storage; avoid triggering request.
382
- if (inProtocolDecl)
383
- return false ;
384
-
385
- return pattern->hasStorage ();
386
- }
387
-
388
353
// / Validate the \c entryNumber'th entry in \c binding.
389
354
const PatternBindingEntry *PatternBindingEntryRequest::evaluate (
390
355
Evaluator &eval, PatternBindingDecl *binding, unsigned entryNumber,
@@ -485,7 +450,7 @@ const PatternBindingEntry *PatternBindingEntryRequest::evaluate(
485
450
// default-initializable. If so, do it.
486
451
if (!pbe.isInitialized () &&
487
452
binding->isDefaultInitializable (entryNumber) &&
488
- mayHaveStorage ( pattern)) {
453
+ pattern-> hasStorage ( )) {
489
454
if (auto defaultInit = TypeChecker::buildDefaultInitializer (patternType)) {
490
455
// If we got a default initializer, install it and re-type-check it
491
456
// to make sure it is properly coerced to the pattern type.
0 commit comments