mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[DI] Simplify immutability checks on _storage base
This commit is contained in:
committed by
Pavel Yaskevich
parent
24b2bcae09
commit
58e330dba9
@@ -468,8 +468,6 @@ DIMemoryObjectInfo::getPathStringToElement(unsigned Element,
|
||||
|
||||
/// If the specified value is a 'let' property in an initializer, return true.
|
||||
bool DIMemoryObjectInfo::isElementLetProperty(unsigned Element) const {
|
||||
NullablePtr<NominalTypeDecl> NTD;
|
||||
|
||||
// If this is an element of a `_storage` tuple, we need to
|
||||
// check the `$Storage` to determine whether underlying storage
|
||||
// backing element is immutable.
|
||||
@@ -477,16 +475,23 @@ bool DIMemoryObjectInfo::isElementLetProperty(unsigned Element) const {
|
||||
auto *wrappedType = cast<NominalTypeDecl>(
|
||||
storageVar->getDeclContext()->getInnermostTypeContext());
|
||||
assert(wrappedType && "_storage reference without type wrapper");
|
||||
NTD = wrappedType->getTypeWrapperStorageDecl();
|
||||
} else {
|
||||
// If we aren't representing 'self' in a non-delegating initializer, then we
|
||||
// can't have 'let' properties.
|
||||
if (!isNonDelegatingInit())
|
||||
return IsLet;
|
||||
|
||||
NTD = MemorySILType.getNominalOrBoundGenericNominal();
|
||||
auto storageVarType = storageVar->getInterfaceType()->getAs<TupleType>();
|
||||
assert(Element < storageVarType->getNumElements());
|
||||
auto propertyName = storageVarType->getElement(Element).getName();
|
||||
|
||||
auto *storageDecl = wrappedType->getTypeWrapperStorageDecl();
|
||||
auto *property = storageDecl->lookupDirect(propertyName).front();
|
||||
return cast<VarDecl>(property)->isLet();
|
||||
}
|
||||
|
||||
// If we aren't representing 'self' in a non-delegating initializer, then we
|
||||
// can't have 'let' properties.
|
||||
if (!isNonDelegatingInit())
|
||||
return IsLet;
|
||||
|
||||
auto NTD = MemorySILType.getNominalOrBoundGenericNominal();
|
||||
|
||||
if (!NTD) {
|
||||
// Otherwise, we miscounted elements?
|
||||
assert(Element == 0 && "Element count problem");
|
||||
@@ -496,7 +501,7 @@ bool DIMemoryObjectInfo::isElementLetProperty(unsigned Element) const {
|
||||
auto &Module = MemoryInst->getModule();
|
||||
|
||||
auto expansionContext = TypeExpansionContext(*MemoryInst->getFunction());
|
||||
for (auto *VD : NTD.get()->getStoredProperties()) {
|
||||
for (auto *VD : NTD->getStoredProperties()) {
|
||||
auto FieldType = MemorySILType.getFieldType(VD, Module, expansionContext);
|
||||
unsigned NumFieldElements =
|
||||
getElementCountRec(expansionContext, Module, FieldType, false);
|
||||
|
||||
Reference in New Issue
Block a user