Skip to content

Commit dfcfdf7

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 a79b1ff commit dfcfdf7

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",
@@ -1235,7 +1235,7 @@
12351235
"declKind": "Protocol",
12361236
"usr": "s:4cake4PSubP",
12371237
"moduleName": "cake",
1238-
"genericSig": "<τ_0_0 : cake.PSuper>",
1238+
"genericSig": "<τ_0_0 : PSuper>",
12391239
"conformances": [
12401240
{
12411241
"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
@@ -1090,16 +1090,20 @@ StringRef printGenericSignature(SDKContext &Ctx, ArrayRef<Requirement> AllReqs)
10901090
return StringRef();
10911091
OS << "<";
10921092
bool First = true;
1093+
PrintOptions Opts = PrintOptions::printInterface();
1094+
// We always print unqualifed type names to avoid false positives introduced
1095+
// by the heuristics working differently.
1096+
Opts.FullyQualifiedTypesIfAmbiguous = false;
10931097
for (auto Req: AllReqs) {
10941098
if (!First) {
10951099
OS << ", ";
10961100
} else {
10971101
First = false;
10981102
}
10991103
if (Ctx.checkingABI())
1100-
getCanonicalRequirement(Req).print(OS, PrintOptions::printInterface());
1104+
getCanonicalRequirement(Req).print(OS, Opts);
11011105
else
1102-
Req.print(OS, PrintOptions::printInterface());
1106+
Req.print(OS, Opts);
11031107
}
11041108
OS << ">";
11051109
return Ctx.buffer(OS.str());

0 commit comments

Comments
 (0)