Skip to content

Commit 25f7632

Browse files
committed
IRGen: Record enum payload type, not the constructor type
If we have a 'case Foo(T)' inside 'enum E', we only want to keep 'T' around, not 'E.Type -> T -> E'.
1 parent 9e7fadc commit 25f7632

File tree

3 files changed

+243
-646
lines changed

3 files changed

+243
-646
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,13 +126,12 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
126126
const uint32_t fieldRecordSize = 12;
127127
ArrayRef<const NominalTypeDecl *> NominalTypeDecls;
128128

129-
void addFieldDecl(const ValueDecl *value) {
129+
void addFieldDecl(const ValueDecl *value, CanType type) {
130130
swift::reflection::FieldRecordFlags Flags;
131131
Flags.setIsObjC(value->isObjC());
132132

133133
addConstantInt32(Flags.getRawValue());
134134

135-
auto type = value->getInterfaceType()->getCanonicalType();
136135
addTypeRef(value->getModuleContext(), type);
137136

138137
if (IGM.Opts.StripReflectionNames) {
@@ -155,7 +154,9 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
155154
addConstantInt32(std::distance(properties.begin(), properties.end()));
156155
addConstantInt32(fieldRecordSize);
157156
for (auto property : properties)
158-
addFieldDecl(property);
157+
addFieldDecl(property,
158+
property->getInterfaceType()
159+
->getCanonicalType());
159160
break;
160161
}
161162
case DeclKind::Enum: {
@@ -164,7 +165,9 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
164165
addConstantInt32(std::distance(cases.begin(), cases.end()));
165166
addConstantInt32(fieldRecordSize);
166167
for (auto enumCase : cases)
167-
addFieldDecl(enumCase);
168+
addFieldDecl(enumCase,
169+
enumCase->getArgumentInterfaceType()
170+
->getCanonicalType());
168171
break;
169172
}
170173
default:

0 commit comments

Comments
 (0)