Skip to content

Commit 7ccef06

Browse files
authored
Swift-api-digester: check self-parameter explicitly instead of using its context. NFC (#8660)
1 parent 4463bb8 commit 7ccef06

File tree

3 files changed

+11
-30
lines changed

3 files changed

+11
-30
lines changed

test/api-digester/Outputs/cake.json

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,6 @@
148148
"printedName": "C1"
149149
}
150150
]
151-
},
152-
{
153-
"kind": "TypeNominal",
154-
"name": "C1",
155-
"printedName": "C1"
156151
}
157152
]
158153
},
@@ -170,11 +165,6 @@
170165
"name": "Void",
171166
"printedName": "()"
172167
},
173-
{
174-
"kind": "TypeNominal",
175-
"name": "C1",
176-
"printedName": "C1"
177-
},
178168
{
179169
"kind": "TypeNominal",
180170
"name": "Optional",
@@ -215,11 +205,6 @@
215205
"location": "",
216206
"moduleName": "cake",
217207
"children": [
218-
{
219-
"kind": "TypeNominal",
220-
"name": "C1",
221-
"printedName": "C1"
222-
},
223208
{
224209
"kind": "TypeNominal",
225210
"name": "C1",
@@ -241,11 +226,6 @@
241226
"name": "Void",
242227
"printedName": "()"
243228
},
244-
{
245-
"kind": "TypeNominal",
246-
"name": "C1",
247-
"printedName": "C1"
248-
},
249229
{
250230
"kind": "TypeNominal",
251231
"name": "C1",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ Func Dictionary.removeValue(forKey:) has been removed
2323
Func Dictionary.updateValue(_:forKey:) has been removed
2424

2525
/* FIXME: Bogus */
26+
Var BidirectionalCollection.indices has declared type change from DefaultBidirectionalIndices<Self> to Self.Indices
2627
Var Dictionary.endIndex has declared type change from DictionaryIndex<Key, Value> to Dictionary<Key, Value>.Index
2728
Var Dictionary.startIndex has declared type change from DictionaryIndex<Key, Value> to Dictionary<Key, Value>.Index
29+
Var RandomAccessCollection.indices has declared type change from DefaultRandomAccessIndices<Self> to Self.Indices
2830
Var Set.endIndex has declared type change from SetIndex<Element> to Set<Element>.Index
2931
Var Set.startIndex has declared type change from SetIndex<Element> to Set<Element>.Index
3032
Constructor AnyIterator.init(_:) has parameter 0 type change from () -> Element? to () -> AnyIterator.Element?

tools/swift-api-digester/swift-api-digester.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,15 +1146,14 @@ static SDKNode *constructTypeNode(SDKContext &Ctx, Type T) {
11461146
// We sometimes skip the first parameter because it can be metatype of dynamic
11471147
// this if the function is a member function.
11481148
static SDKNode *constructFunctionNode(SDKContext &Ctx, FuncDecl* FD,
1149-
SDKNodeKind Kind, bool SkipFirst) {
1149+
SDKNodeKind Kind) {
11501150
auto Func = SDKNodeInitInfo(Ctx, FD).createSDKNode(Kind);
11511151
Func->addChild(constructTypeNode(Ctx, FD->getResultInterfaceType()));
11521152
for (auto *paramList : FD->getParameterLists()) {
1153-
for (auto param : *paramList)
1154-
Func->addChild(constructTypeNode(Ctx, param->getInterfaceType()));
1155-
}
1156-
if (SkipFirst) {
1157-
Func->removeChild(Func->getChildBegin() + 1);
1153+
for (auto param : *paramList) {
1154+
if (!param->isSelfParameter())
1155+
Func->addChild(constructTypeNode(Ctx, param->getInterfaceType()));
1156+
}
11581157
}
11591158
return Func;
11601159
}
@@ -1225,9 +1224,9 @@ static SDKNode *constructVarNode(SDKContext &Ctx, ValueDecl *VD) {
12251224
Var->addChild(constructTypeNode(Ctx, VD->getInterfaceType()));
12261225
if (auto VAD = dyn_cast<AbstractStorageDecl>(VD)) {
12271226
if (auto Getter = VAD->getGetter())
1228-
Var->addChild(constructFunctionNode(Ctx, Getter, SDKNodeKind::Getter, false));
1227+
Var->addChild(constructFunctionNode(Ctx, Getter, SDKNodeKind::Getter));
12291228
if (auto Setter = VAD->getSetter())
1230-
Var->addChild(constructFunctionNode(Ctx, Setter, SDKNodeKind::Setter, false));
1229+
Var->addChild(constructFunctionNode(Ctx, Setter, SDKNodeKind::Setter));
12311230
}
12321231
return Var;
12331232
}
@@ -1244,7 +1243,7 @@ static void addMembersToRoot(SDKContext &Ctx, SDKNode *Root,
12441243
if (shouldIgnore(Member))
12451244
continue;
12461245
if (auto Func = dyn_cast<FuncDecl>(Member)) {
1247-
Root->addChild(constructFunctionNode(Ctx, Func, SDKNodeKind::Function, true));
1246+
Root->addChild(constructFunctionNode(Ctx, Func, SDKNodeKind::Function));
12481247
} else if (auto CD = dyn_cast<ConstructorDecl>(Member)) {
12491248
Root->addChild(constructInitNode(Ctx, CD));
12501249
} else if (auto VD = dyn_cast<VarDecl>(Member)) {
@@ -1334,7 +1333,7 @@ class SwiftDeclCollector : public VisibleDeclConsumer {
13341333
return;
13351334

13361335
if (auto FD = dyn_cast<FuncDecl>(VD)) {
1337-
RootNode->addChild(constructFunctionNode(Ctx, FD, SDKNodeKind::Function, false));
1336+
RootNode->addChild(constructFunctionNode(Ctx, FD, SDKNodeKind::Function));
13381337
} else if (auto NTD = dyn_cast<NominalTypeDecl>(VD)) {
13391338
RootNode->addChild(constructTypeDeclNode(Ctx, NTD));
13401339
}

0 commit comments

Comments
 (0)