AST: Turn NominalTypeDecl::getStoredProperties() into a request

This improves on the previous situation:

- The request ensures that the backing storage for lazy properties
  and property wrappers gets synthesized first; previously it was
  only somewhat guaranteed by callers.

- Instead of returning a range this just returns an ArrayRef,
  which simplifies clients.

- Indexing into the ArrayRef is O(1), which addresses some FIXMEs
  in the SIL optimizer.
This commit is contained in:
Slava Pestov
2019-07-11 18:34:28 -04:00
parent b0e18e81ac
commit 83c90b6b2a
30 changed files with 201 additions and 145 deletions

View File

@@ -803,9 +803,8 @@ SILValue SILGenFunction::emitUnwrapIntegerResult(SILLocation loc,
while (!value->getType().is<BuiltinIntegerType>()) {
auto structDecl = value->getType().getStructOrBoundGenericStruct();
assert(structDecl && "value for error result wasn't of struct type!");
assert(std::next(structDecl->getStoredProperties().begin())
== structDecl->getStoredProperties().end());
auto property = *structDecl->getStoredProperties().begin();
assert(structDecl->getStoredProperties().size() == 1);
auto property = structDecl->getStoredProperties()[0];
value = B.createStructExtract(loc, value, property);
}