@@ -2178,6 +2178,11 @@ InitExistentialAddrInst *InitExistentialAddrInst::create(
2178
2178
SILDebugLocation Loc, SILValue Existential, CanType ConcreteType,
2179
2179
SILType ConcreteLoweredType, ArrayRef<ProtocolConformanceRef> Conformances,
2180
2180
SILFunction *F) {
2181
+ #ifndef NDEBUG
2182
+ auto layout = Existential->getType ().getASTType ().getExistentialLayout ();
2183
+ assert (layout.getProtocols ().size () == Conformances.size ());
2184
+ #endif
2185
+
2181
2186
SILModule &Mod = F->getModule ();
2182
2187
SmallVector<SILValue, 8 > TypeDependentOperands;
2183
2188
collectTypeDependentOperands (TypeDependentOperands, *F, ConcreteType);
@@ -2196,6 +2201,11 @@ InitExistentialValueInst *InitExistentialValueInst::create(
2196
2201
SILDebugLocation Loc, SILType ExistentialType, CanType ConcreteType,
2197
2202
SILValue Instance, ArrayRef<ProtocolConformanceRef> Conformances,
2198
2203
SILFunction *F) {
2204
+ #ifndef NDEBUG
2205
+ auto layout = ExistentialType.getASTType ().getExistentialLayout ();
2206
+ assert (layout.getProtocols ().size () == Conformances.size ());
2207
+ #endif
2208
+
2199
2209
SILModule &Mod = F->getModule ();
2200
2210
SmallVector<SILValue, 8 > TypeDependentOperands;
2201
2211
collectTypeDependentOperands (TypeDependentOperands, *F, ConcreteType);
@@ -2212,6 +2222,11 @@ InitExistentialRefInst *InitExistentialRefInst::create(
2212
2222
SILDebugLocation Loc, SILType ExistentialType, CanType ConcreteType,
2213
2223
SILValue Instance, ArrayRef<ProtocolConformanceRef> Conformances,
2214
2224
SILFunction *F, ValueOwnershipKind forwardingOwnershipKind) {
2225
+ #ifndef NDEBUG
2226
+ auto layout = ExistentialType.getASTType ().getExistentialLayout ();
2227
+ assert (layout.getProtocols ().size () == Conformances.size ());
2228
+ #endif
2229
+
2215
2230
SILModule &Mod = F->getModule ();
2216
2231
SmallVector<SILValue, 8 > TypeDependentOperands;
2217
2232
collectTypeDependentOperands (TypeDependentOperands, *F, ConcreteType);
@@ -2232,6 +2247,11 @@ InitExistentialMetatypeInst::InitExistentialMetatypeInst(
2232
2247
TypeDependentOperands,
2233
2248
existentialMetatypeType),
2234
2249
NumConformances(conformances.size()) {
2250
+ #ifndef NDEBUG
2251
+ auto layout = existentialMetatypeType.getASTType ().getExistentialLayout ();
2252
+ assert (layout.getProtocols ().size () == conformances.size ());
2253
+ #endif
2254
+
2235
2255
std::uninitialized_copy (conformances.begin (), conformances.end (),
2236
2256
getTrailingObjects<ProtocolConformanceRef>());
2237
2257
}
0 commit comments