Add a field reflection function that constructs keypaths. (#34815)

While the existing _forEachField in ReflectionMirror.swift
already gives the offsets and types for each field, this isn't
enough information to construct a keypath for that field in
order to modify it.

For reference, this should be sufficent to implement the features
described here: (https://forums.swift.org/t/storedpropertyiterable/19218/62)
purely at runtime without any derived conformances for many types.

Note: Since there isn't enough reflection information for
`.mutatingGetSet` fields, this means that we're not able to support
reflecting certain types of fields (functions, nonfinal class fields,
etc). Whether this is an error or not is controlled by the `.ignoreUnknown`
option.
This commit is contained in:
Parker Schuh
2020-11-30 09:17:23 -08:00
committed by GitHub
parent 89fab1b06b
commit 4e39e59a8a
8 changed files with 282 additions and 48 deletions

View File

@@ -92,6 +92,10 @@ public:
bool isIndirectCase() const {
return Flags.isIndirectCase();
}
bool isVar() const {
return Flags.isVar();
}
};
struct FieldRecordIterator {