@@ -113,6 +113,12 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
113
113
if (!bridgingFunc)
114
114
return nullptr ;
115
115
116
+ auto paramTypes = bridgingFunc->getLoweredFunctionType ()->getParameters ();
117
+ (void )paramTypes;
118
+ assert (paramTypes[0 ].getConvention () ==
119
+ ParameterConvention::Direct_Guaranteed &&
120
+ " Parameter should be @guaranteed" );
121
+
116
122
CanType CanBridgedTy = BridgedTargetTy->getCanonicalType ();
117
123
SILType silBridgedTy = SILType::getPrimitiveObjectType (CanBridgedTy);
118
124
@@ -181,19 +187,15 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
181
187
auto BridgedProto =
182
188
mod.getASTContext ().getProtocol (KnownProtocolKind::ObjectiveCBridgeable);
183
189
auto Conf = *mod.getSwiftModule ()->lookupConformance (target, BridgedProto);
184
-
185
- auto ParamTypes = bridgingFunc->getLoweredFunctionType ()->getParameters ();
190
+ // Add substitutions
191
+ auto SubMap = SubstitutionMap::getProtocolSubstitutions (Conf.getRequirement (),
192
+ target, Conf);
186
193
187
194
auto *FuncRef = Builder.createFunctionRef (Loc, bridgingFunc);
188
195
189
196
auto MetaTy = MetatypeType::get (target, MetatypeRepresentation::Thick);
190
197
auto SILMetaTy = F->getTypeLowering (MetaTy).getLoweredType ();
191
198
auto *MetaTyVal = Builder.createMetatype (Loc, SILMetaTy);
192
- SmallVector<SILValue, 1 > Args;
193
-
194
- // Add substitutions
195
- auto SubMap = SubstitutionMap::getProtocolSubstitutions (Conf.getRequirement (),
196
- target, Conf);
197
199
198
200
// Temporary to hold the intermediate result.
199
201
AllocStackInst *Tmp = nullptr ;
@@ -211,13 +213,10 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
211
213
InOutOptionalParam = Dest;
212
214
}
213
215
214
- (void )ParamTypes;
215
- assert (ParamTypes[0 ].getConvention () == ParameterConvention::Direct_Guaranteed &&
216
- " Parameter should be @guaranteed" );
217
-
218
216
// Emit a retain.
219
217
Builder.createRetainValue (Loc, srcOp, Builder.getDefaultAtomicity ());
220
218
219
+ SmallVector<SILValue, 1 > Args;
221
220
Args.push_back (InOutOptionalParam);
222
221
Args.push_back (srcOp);
223
222
Args.push_back (MetaTyVal);
0 commit comments