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
20 changes: 20 additions & 0 deletions lib/DriverTool/swift_api_digester_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,11 @@ static void diagnoseRemovedDecl(const SDKNodeDecl *D) {
if (Ctx.getOpts().SkipRemoveDeprecatedCheck &&
D->isDeprecated())
return;
// Don't complain about removing importation of SwiftOnoneSupport.
if (D->getKind() == SDKNodeKind::DeclImport &&
D->getName() == "SwiftOnoneSupport") {
return;
}
D->emitDiag(SourceLoc(), diag::removed_decl, false);
}

Expand Down Expand Up @@ -691,6 +696,21 @@ class PrunePass : public MatchedNodeListener, public SDKTreeDiffPass {
// to the allowlist.
ShouldComplain = false;
}
if (ShouldComplain) {
// Providing a default implementation via a protocol extension for
// a protocol requirement is both ABI and API safe.
if (auto *PD = dyn_cast<SDKNodeDecl>(D->getParent())) {
for (auto *SIB: PD->getChildren()) {
if (auto *SIBD = dyn_cast<SDKNodeDecl>(SIB)) {
if (SIBD->isFromExtension() &&
SIBD->getPrintedName() == D->getPrintedName()) {
ShouldComplain = false;
break;
}
}
}
}
}
if (ShouldComplain)
D->emitDiag(D->getLoc(), diag::protocol_req_added);
}
Expand Down
18 changes: 18 additions & 0 deletions test/api-digester/protocol-req-with-default-impl.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %empty-directory(%t)

// RUN: echo "public protocol P {}" > %t/Foo-1.swift
// RUN: echo "public protocol P { func f() }" > %t/Foo-2.swift
// RUN: echo "public extension P { func f() {} }" >> %t/Foo-2.swift

// RUN: %target-swift-frontend -emit-module %t/Foo-1.swift -module-name Foo -emit-module-interface-path %t/Foo1.swiftinterface
// RUN: %target-swift-frontend -emit-module %t/Foo-2.swift -module-name Foo -emit-module-interface-path %t/Foo2.swiftinterface

// RUN: %target-swift-frontend -compile-module-from-interface %t/Foo1.swiftinterface -o %t/Foo1.swiftmodule -module-name Foo -emit-abi-descriptor-path %t/Foo1.json

// RUN: %target-swift-frontend -compile-module-from-interface %t/Foo2.swiftinterface -o %t/Foo2.swiftmodule -module-name Foo -emit-abi-descriptor-path %t/Foo2.json

// RUN: %api-digester -diagnose-sdk -print-module --input-paths %t/Foo1.json -input-paths %t/Foo2.json -abi -o %t/result.txt

// RUN: %FileCheck %s < %t/result.txt

// CHECK-NOT: added as a protocol requirement