Skip to content

Commit d15f611

Browse files
authored
Merge pull request #19620 from nkcsgexi/include-operator
swift-module-digester: include operator overloads in the module dump.
2 parents 36ca10f + a6f886c commit d15f611

File tree

5 files changed

+108
-6
lines changed

5 files changed

+108
-6
lines changed

test/api-digester/Inputs/cake.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,7 @@ public protocol PSub: PSuper {
8080
}
8181

8282
public let GlobalVar = 1
83+
84+
public extension P1 {
85+
static func +(lhs: P1, rhs: P1) -> P1 { return lhs }
86+
}

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@
77
"kind": "TypeDecl",
88
"name": "P1",
99
"printedName": "P1",
10+
"children": [
11+
{
12+
"kind": "Function",
13+
"name": "+",
14+
"printedName": "+(_:_:)",
15+
"children": [
16+
{
17+
"kind": "TypeNominal",
18+
"name": "P1",
19+
"printedName": "P1",
20+
"usr": "s:4cake2P1P"
21+
},
22+
{
23+
"kind": "TypeNominal",
24+
"name": "P1",
25+
"printedName": "P1",
26+
"usr": "s:4cake2P1P"
27+
},
28+
{
29+
"kind": "TypeNominal",
30+
"name": "P1",
31+
"printedName": "P1",
32+
"usr": "s:4cake2P1P"
33+
}
34+
],
35+
"declKind": "Func",
36+
"usr": "s:4cake2P1PAAE1poiyAaB_pAaB_p_AaB_ptFZ",
37+
"moduleName": "cake",
38+
"genericSig": "<τ_0_0 where τ_0_0 : P1>",
39+
"static": true
40+
}
41+
],
1042
"declKind": "Protocol",
1143
"usr": "s:4cake2P1P",
1244
"moduleName": "cake"

test/api-digester/Outputs/cake.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@
77
"kind": "TypeDecl",
88
"name": "P1",
99
"printedName": "P1",
10+
"children": [
11+
{
12+
"kind": "Function",
13+
"name": "+",
14+
"printedName": "+(_:_:)",
15+
"children": [
16+
{
17+
"kind": "TypeNominal",
18+
"name": "P1",
19+
"printedName": "P1",
20+
"usr": "s:4cake2P1P"
21+
},
22+
{
23+
"kind": "TypeNominal",
24+
"name": "P1",
25+
"printedName": "P1",
26+
"usr": "s:4cake2P1P"
27+
},
28+
{
29+
"kind": "TypeNominal",
30+
"name": "P1",
31+
"printedName": "P1",
32+
"usr": "s:4cake2P1P"
33+
}
34+
],
35+
"declKind": "Func",
36+
"usr": "s:4cake2P1PAAE1poiyAaB_pAaB_p_AaB_ptFZ",
37+
"moduleName": "cake",
38+
"genericSig": "<Self where Self : P1>",
39+
"static": true
40+
}
41+
],
1042
"declKind": "Protocol",
1143
"usr": "s:4cake2P1P",
1244
"moduleName": "cake"

test/api-digester/source-stability.swift.expected

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,43 @@ AssociatedType StringProtocol.UTF16View has been added as a protocol requirement
119119
AssociatedType StringProtocol.UTF8View has been added as a protocol requirement
120120
AssociatedType StringProtocol.UnicodeScalarView has been added as a protocol requirement
121121
AssociatedType _SequenceWrapper.Base has been added as a protocol requirement
122+
123+
124+
// These operator changes are false positive because the baseline doesn't have operators.
125+
Func BinaryInteger.%(_:_:) has been added as a protocol requirement
126+
Func BinaryInteger.%=(_:_:) has been added as a protocol requirement
127+
Func BinaryInteger.&(_:_:) has been added as a protocol requirement
128+
Func BinaryInteger.&=(_:_:) has been added as a protocol requirement
129+
Func BinaryInteger.<<(_:_:) has been added as a protocol requirement
130+
Func BinaryInteger.<<=(_:_:) has been added as a protocol requirement
131+
Func BinaryInteger.>>(_:_:) has been added as a protocol requirement
132+
Func BinaryInteger.>>=(_:_:) has been added as a protocol requirement
133+
Func BinaryInteger.\/(_:_:) has been added as a protocol requirement
134+
Func BinaryInteger.\/=(_:_:) has been added as a protocol requirement
135+
Func BinaryInteger.^(_:_:) has been added as a protocol requirement
136+
Func BinaryInteger.^=(_:_:) has been added as a protocol requirement
122137
Func BinaryInteger.isMultiple(of:) has been added as a protocol requirement
138+
Func BinaryInteger.|(_:_:) has been added as a protocol requirement
139+
Func BinaryInteger.|=(_:_:) has been added as a protocol requirement
140+
Func BinaryInteger.~(_:) has been added as a protocol requirement
141+
Func Comparable.<(_:_:) has been added as a protocol requirement
142+
Func Comparable.<=(_:_:) has been added as a protocol requirement
143+
Func Comparable.>(_:_:) has been added as a protocol requirement
144+
Func Comparable.>=(_:_:) has been added as a protocol requirement
145+
Func Equatable.==(_:_:) has been added as a protocol requirement
146+
Func FixedWidthInteger.&<<(_:_:) has been added as a protocol requirement
147+
Func FixedWidthInteger.&<<=(_:_:) has been added as a protocol requirement
148+
Func FixedWidthInteger.&>>(_:_:) has been added as a protocol requirement
149+
Func FixedWidthInteger.&>>=(_:_:) has been added as a protocol requirement
150+
Func FloatingPoint.\/(_:_:) has been added as a protocol requirement
151+
Func FloatingPoint.\/=(_:_:) has been added as a protocol requirement
152+
Func Numeric.*(_:_:) has been added as a protocol requirement
153+
Func Numeric.*=(_:_:) has been added as a protocol requirement
154+
Func Numeric.+(_:_:) has been added as a protocol requirement
155+
Func Numeric.+=(_:_:) has been added as a protocol requirement
156+
Func Numeric.-(_:_:) has been added as a protocol requirement
157+
Func Numeric.-=(_:_:) has been added as a protocol requirement
158+
Func SignedNumeric.-(_:) has been added as a protocol requirement
123159

124160
// The subscript changes are bogus because we don't have subscript decls in the baseline.
125161
Subscript Collection.subscript(_:) has been added as a protocol requirement

tools/swift-api-digester/ModuleAnalyzerNodes.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,8 +1151,6 @@ SwiftDeclCollector::shouldIgnore(Decl *D, const Decl* Parent) {
11511151
if (isa<OperatorDecl>(D))
11521152
return true;
11531153
if (auto VD = dyn_cast<ValueDecl>(D)) {
1154-
if (VD->isOperator())
1155-
return true;
11561154
if (VD->getBaseName().empty())
11571155
return true;
11581156

@@ -1347,12 +1345,12 @@ void SwiftDeclCollector::processDecl(ValueDecl *VD) {
13471345
RootNode->addChild(constructFunctionNode(FD, SDKNodeKind::DeclFunction));
13481346
} else if (auto NTD = dyn_cast<NominalTypeDecl>(VD)) {
13491347
RootNode->addChild(constructTypeDeclNode(NTD));
1350-
}
1351-
if (auto VAD = dyn_cast<VarDecl>(VD)) {
1348+
} else if (auto VAD = dyn_cast<VarDecl>(VD)) {
13521349
RootNode->addChild(constructVarNode(VAD));
1353-
}
1354-
if (auto TAD = dyn_cast<TypeAliasDecl>(VD)) {
1350+
} else if (auto TAD = dyn_cast<TypeAliasDecl>(VD)) {
13551351
RootNode->addChild(constructTypeAliasNode(TAD));
1352+
} else {
1353+
llvm_unreachable("unhandled value decl");
13561354
}
13571355
}
13581356

0 commit comments

Comments
 (0)