Skip to content

Commit bf599b7

Browse files
committed
[Serialization] Form protocol's inherited types based on deserialized protocols
1 parent 85179e0 commit bf599b7

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3214,6 +3214,21 @@ class DeclDeserializer {
32143214
decl.get<ExtensionDecl *>()->setInherited(inherited);
32153215
}
32163216

3217+
void handleInherited(ProtocolDecl *P,
3218+
ArrayRef<ProtocolDecl *> inherited) {
3219+
SmallVector<InheritedEntry, 2> inheritedTypes;
3220+
llvm::transform(inherited, std::back_inserter(inheritedTypes), [](auto *I) {
3221+
return InheritedEntry(TypeLoc::withoutLoc(I->getDeclaredInterfaceType()),
3222+
/*isUnchecked=*/false,
3223+
/*isRetroactive=*/false,
3224+
/*isPreconcurrency=*/false);
3225+
});
3226+
3227+
P->setInherited(ctx.AllocateCopy(inheritedTypes));
3228+
ctx.evaluator.cacheOutput(InheritedProtocolsRequest{P},
3229+
ctx.AllocateCopy(inherited));
3230+
}
3231+
32173232
public:
32183233
DeclDeserializer(ModuleFile &MF, Serialized<Decl *> &declOrOffset)
32193234
: MF(MF), ctx(MF.getContext()), declOrOffset(declOrOffset) {}
@@ -4499,8 +4514,8 @@ class DeclDeserializer {
44994514
SmallVector<ProtocolDecl *, 2> inherited;
45004515
if (!MF.readInheritedProtocols(inherited))
45014516
return MF.diagnoseFatal();
4502-
ctx.evaluator.cacheOutput(InheritedProtocolsRequest{proto},
4503-
ctx.AllocateCopy(inherited));
4517+
4518+
handleInherited(proto, inherited);
45044519

45054520
auto genericParams = MF.maybeReadGenericParams(DC);
45064521
assert(genericParams && "protocol with no generic parameters?");

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,19 @@
107107
"genericSig": "<τ_0_0 : cake.P1, τ_0_0 : cake.P2>",
108108
"sugared_genericSig": "<Self : cake.P1, Self : cake.P2>",
109109
"conformances": [
110-
{
111-
"kind": "Conformance",
112-
"name": "P2",
113-
"printedName": "P2",
114-
"usr": "s:4cake2P2P",
115-
"mangledName": "$s4cake2P2P"
116-
},
117110
{
118111
"kind": "Conformance",
119112
"name": "P1",
120113
"printedName": "P1",
121114
"usr": "s:4cake2P1P",
122115
"mangledName": "$s4cake2P1P"
116+
},
117+
{
118+
"kind": "Conformance",
119+
"name": "P2",
120+
"printedName": "P2",
121+
"usr": "s:4cake2P2P",
122+
"mangledName": "$s4cake2P2P"
123123
}
124124
]
125125
},

test/api-digester/Outputs/cake.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,19 @@
105105
"moduleName": "cake",
106106
"genericSig": "<Self : cake.P1, Self : cake.P2>",
107107
"conformances": [
108-
{
109-
"kind": "Conformance",
110-
"name": "P2",
111-
"printedName": "P2",
112-
"usr": "s:4cake2P2P",
113-
"mangledName": "$s4cake2P2P"
114-
},
115108
{
116109
"kind": "Conformance",
117110
"name": "P1",
118111
"printedName": "P1",
119112
"usr": "s:4cake2P1P",
120113
"mangledName": "$s4cake2P1P"
114+
},
115+
{
116+
"kind": "Conformance",
117+
"name": "P2",
118+
"printedName": "P2",
119+
"usr": "s:4cake2P2P",
120+
"mangledName": "$s4cake2P2P"
121121
}
122122
]
123123
},

0 commit comments

Comments
 (0)