Skip to content

[Serialization] Drop extensions whose requirements are missing types #17488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2018
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
10 changes: 6 additions & 4 deletions lib/Serialization/Serialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2698,10 +2698,12 @@ void Serializer::writeDecl(const Decl *D) {
inheritedAndDependencyTypes.push_back(addTypeRef(inherited.getType()));
size_t numInherited = inheritedAndDependencyTypes.size();

// FIXME: Figure out what to do with requirements and such, which the
// extension also depends on. Right now just do what is safe to drop, which
// is the base declaration.
auto dependencies = collectDependenciesFromType(baseTy);
llvm::SmallSetVector<Type, 4> dependencies;
collectDependenciesFromType(dependencies, baseTy, /*excluding*/nullptr);
for (Requirement req : extension->getGenericRequirements()) {
collectDependenciesFromRequirement(dependencies, req,
/*excluding*/nullptr);
}
for (auto dependencyTy : dependencies)
inheritedAndDependencyTypes.push_back(addTypeRef(dependencyTy));

Expand Down
12 changes: 12 additions & 0 deletions test/Serialization/Recovery/type-removal-objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,15 @@ public unowned(unsafe) var someUnownedUnsafeObject: Base = Base()
// CHECK-DAG: weak var someWeakObject: @sil_weak Base
// CHECK-RECOVERY-NEGATIVE-NOT: var someWeakObject:
public weak var someWeakObject: Base? = nil

// CHECK-DAG: struct GenericStruct<T>
// CHECK-RECOVERY-DAG: struct GenericStruct<T>
struct GenericStruct<T> {}

// CHECK-DAG: extension GenericStruct where T : SomeProto
// CHECK-RECOVERY-NEGATIVE-NOT: extension GenericStruct{{.*}}SomeProto
extension GenericStruct where T: SomeProto {
// CHECK-DAG: func someOperation
// CHECK-RECOVERY-NEGATIVE-NOT: someOperation
func someOperation() {}
}