Skip to content

Commit 05bec0c

Browse files
committed
swift-api-digester: describing external type declarations as extensions in error messages
External type declarations are synthesized to incorporate members in extensions to types of external modules. In diagnostics, we should use 'extension' instead of 'struct/class' for these decls to avoid confusion.
1 parent 967f1e6 commit 05bec0c

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

test/api-digester/Inputs/cake1.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,7 @@ public protocol HasMutatingMethodClone: HasMutatingMethod {
168168
mutating func foo()
169169
var bar: Int { mutating get }
170170
}
171+
172+
public extension Int {
173+
public func IntEnhancer() {}
174+
}

test/api-digester/Outputs/Cake-abi.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cake1: Protocol P3 has generic signature change from <τ_0_0 : cake.P1, τ_0_0 :
66
/* RawRepresentable Changes */
77

88
/* Removed Decls */
9+
Swift: Extension Int has been removed
910
cake1: Accessor GlobalVarChangedToLet.Set() has been removed
1011
cake1: Accessor RemoveSetters.Value.Set() has been removed
1112
cake1: AssociatedType RequiementChanges.removedType has been removed

test/api-digester/Outputs/Cake.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ cake1: Protocol P3 has generic signature change from <Self : cake.P1, Self : cak
66
/* RawRepresentable Changes */
77

88
/* Removed Decls */
9+
Swift: Extension Int has been removed
910
cake1: Accessor GlobalVarChangedToLet.Set() has been removed
1011
cake1: Accessor RemoveSetters.Value.Set() has been removed
1112
cake1: AssociatedType RequiementChanges.removedType has been removed

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,15 @@ StringRef SDKNodeDecl::getScreenInfo() const {
385385
OS << "(" << HeaderName << ")";
386386
if (!OS.str().empty())
387387
OS << ": ";
388-
OS << getDeclKind() << " " << getFullyQualifiedName();
388+
bool IsExtension = false;
389+
if (auto *TD = dyn_cast<SDKNodeDeclType>(this)) {
390+
IsExtension = TD->isExternal();
391+
}
392+
if (IsExtension)
393+
OS << "Extension";
394+
else
395+
OS << getDeclKind();
396+
OS << " " << getFullyQualifiedName();
389397
return Ctx.buffer(OS.str());
390398
}
391399

0 commit comments

Comments
 (0)