Skip to content

Commit f25b887

Browse files
committed
SILGen: Don't emit no-payload case constructors at all
With the change to open-code enum construction, it is no longer possible to form a reference to a no-payload case constructor function (at least until we allow enum cases to witness protocol requirements), so only payload case constructors need to be emitted now. Currently, we still emit all the case constructor functions for payload cases unconditionally, even though now this is only necessary for the ones that are partially applied. This will be addressed in a follow-on patch.
1 parent a7a9e16 commit f25b887

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/SILGen/SILGenDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,9 +1157,10 @@ void SILGenModule::emitExternalDefinition(Decl *d) {
11571157
auto ed = cast<EnumDecl>(d);
11581158
// Emit the enum cases and derived conformance methods for the type.
11591159
for (auto member : ed->getMembers()) {
1160-
if (auto elt = dyn_cast<EnumElementDecl>(member))
1161-
emitEnumConstructor(elt);
1162-
else if (auto func = dyn_cast<FuncDecl>(member))
1160+
if (auto elt = dyn_cast<EnumElementDecl>(member)) {
1161+
if (elt->hasArgumentType())
1162+
emitEnumConstructor(elt);
1163+
} else if (auto func = dyn_cast<FuncDecl>(member))
11631164
emitFunction(func);
11641165
else if (auto ctor = dyn_cast<ConstructorDecl>(member))
11651166
emitConstructor(ctor);

0 commit comments

Comments
 (0)