Skip to content

Commit 0f83231

Browse files
committed
ABI/API checker: avoid printing fully qualified names in generic signature
The heuristics to decide whether fully qualified type names should be printed may work differently when generating the baseline and when importing from just built frameworks. This patch makes it consistent so that such false positives won't happen. rdar://54276347
1 parent e89675e commit 0f83231

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/* Generic Signature Changes */
33
cake: Func P1.P1Constraint() has generic signature change from <τ_0_0 where τ_0_0 : P1, τ_0_0 : P2> to <τ_0_0 where τ_0_0 : P1>
4-
cake: Protocol P3 has generic signature change from <τ_0_0 : cake.P1, τ_0_0 : cake.P2> to <τ_0_0 : cake.P1, τ_0_0 : cake.P4>
4+
cake: Protocol P3 has generic signature change from <τ_0_0 : P1, τ_0_0 : P2> to <τ_0_0 : P1, τ_0_0 : P4>
55

66
/* RawRepresentable Changes */
77

test/api-digester/Outputs/Cake.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
/* Generic Signature Changes */
33
cake: Func P1.P1Constraint() has generic signature change from <Self where Self : P1, Self : P2> to <Self where Self : P1>
4-
cake: Protocol P3 has generic signature change from <Self : cake.P1, Self : cake.P2> to <Self : cake.P1, Self : cake.P4>
4+
cake: Protocol P3 has generic signature change from <Self : P1, Self : P2> to <Self : P1, Self : P4>
55

66
/* RawRepresentable Changes */
77

test/api-digester/Outputs/cake-abi.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"declKind": "Protocol",
6060
"usr": "s:4cake2P3P",
6161
"moduleName": "cake",
62-
"genericSig": "<τ_0_0 : cake.P1, τ_0_0 : cake.P2>",
62+
"genericSig": "<τ_0_0 : P1, τ_0_0 : P2>",
6363
"conformances": [
6464
{
6565
"kind": "Conformance",
@@ -1238,7 +1238,7 @@
12381238
"declKind": "Protocol",
12391239
"usr": "s:4cake4PSubP",
12401240
"moduleName": "cake",
1241-
"genericSig": "<τ_0_0 : cake.PSuper>",
1241+
"genericSig": "<τ_0_0 : PSuper>",
12421242
"conformances": [
12431243
{
12441244
"kind": "Conformance",

test/api-digester/Outputs/cake.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"declKind": "Protocol",
6060
"usr": "s:4cake2P3P",
6161
"moduleName": "cake",
62-
"genericSig": "<Self : cake.P1, Self : cake.P2>",
62+
"genericSig": "<Self : P1, Self : P2>",
6363
"conformances": [
6464
{
6565
"kind": "Conformance",
@@ -1137,7 +1137,7 @@
11371137
"declKind": "Protocol",
11381138
"usr": "s:4cake4PSubP",
11391139
"moduleName": "cake",
1140-
"genericSig": "<Self : cake.PSuper>",
1140+
"genericSig": "<Self : PSuper>",
11411141
"conformances": [
11421142
{
11431143
"kind": "Conformance",

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,16 +1088,20 @@ StringRef printGenericSignature(SDKContext &Ctx, ArrayRef<Requirement> AllReqs)
10881088
return StringRef();
10891089
OS << "<";
10901090
bool First = true;
1091+
PrintOptions Opts = PrintOptions::printInterface();
1092+
// We always print unqualifed type names to avoid false positives introduced
1093+
// by the heuristics working differently.
1094+
Opts.FullyQualifiedTypesIfAmbiguous = false;
10911095
for (auto Req: AllReqs) {
10921096
if (!First) {
10931097
OS << ", ";
10941098
} else {
10951099
First = false;
10961100
}
10971101
if (Ctx.checkingABI())
1098-
getCanonicalRequirement(Req).print(OS, PrintOptions::printInterface());
1102+
getCanonicalRequirement(Req).print(OS, Opts);
10991103
else
1100-
Req.print(OS, PrintOptions::printInterface());
1104+
Req.print(OS, Opts);
11011105
}
11021106
OS << ">";
11031107
return Ctx.buffer(OS.str());

0 commit comments

Comments
 (0)