Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2323,22 +2323,13 @@ void Serializer::writeForeignErrorConvention(const ForeignErrorConvention &fec){
/// - \p decl is declared in an extension of a type that depends on
/// \p problemContext
static bool contextDependsOn(const NominalTypeDecl *decl,
const DeclContext *problemContext) {
const DeclContext *dc = decl;
do {
if (dc == problemContext)
return true;
if (auto *extension = dyn_cast<ExtensionDecl>(dc))
dc = extension->getAsNominalTypeOrNominalTypeExtensionContext();
else
dc = dc->getParent();
} while (!dc->isModuleScopeContext());
return false;
const ModuleDecl *problemModule) {
return decl->getParentModule() == problemModule;
}

static void collectDependenciesFromType(llvm::SmallSetVector<Type, 4> &seen,
Type ty,
const DeclContext *excluding) {
const ModuleDecl *excluding) {
ty.visit([&](Type next) {
auto *nominal = next->getAnyNominal();
if (!nominal)
Expand Down Expand Up @@ -2712,7 +2703,7 @@ void Serializer::writeDecl(const Decl *D) {
continue;
collectDependenciesFromType(dependencyTypes,
nextElt->getArgumentInterfaceType(),
/*excluding*/theEnum);
/*excluding*/theEnum->getParentModule());
}
for (Type ty : dependencyTypes)
inheritedAndDependencyTypes.push_back(addTypeRef(ty));
Expand Down
3 changes: 3 additions & 0 deletions test/Serialization/Inputs/enum-mutual-circularity-2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
public enum TweedleDum {
indirect case dee(TweedleDee)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import EnumCircularity

func foo(_: TweedleDee) {}
9 changes: 9 additions & 0 deletions test/Serialization/enum-mutual-circularity.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: %target-swift-frontend -emit-module -module-name EnumCircularity -o %t/partial1.swiftmodule -primary-file %s %S/Inputs/enum-mutual-circularity-2.swift
// RUN: %target-swift-frontend -emit-module -module-name EnumCircularity -o %t/partial2.swiftmodule %s -primary-file %S/Inputs/enum-mutual-circularity-2.swift
// RUN: %target-swift-frontend -emit-module -module-name EnumCircularity -o %t/EnumCircularity.swiftmodule %t/partial1.swiftmodule %t/partial2.swiftmodule
// RUN: %target-swift-frontend -I %t -c -o %t/client.o %S/Inputs/enum-mutual-circularity-client.swift

public enum TweedleDee {
indirect case dum(TweedleDum)
}