@@ -166,7 +166,6 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
166166 SILInstruction *Inst = dynamicCast.getInstruction ();
167167 bool isConditional = dynamicCast.isConditional ();
168168 SILValue Dest = dynamicCast.getDest ();
169- CanType BridgedTargetTy = dynamicCast.getBridgedTargetType ();
170169 SILBasicBlock *SuccessBB = dynamicCast.getSuccessBlock ();
171170 SILBasicBlock *FailureBB = dynamicCast.getFailureBlock ();
172171 auto *F = Inst->getFunction ();
@@ -186,9 +185,6 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
186185 ParameterConvention::Direct_Guaranteed &&
187186 " Parameter should be @guaranteed" );
188187
189- CanType CanBridgedTy = BridgedTargetTy->getCanonicalType ();
190- SILType silBridgedTy = SILType::getPrimitiveObjectType (CanBridgedTy);
191-
192188 SILBuilderWithScope Builder (Inst, builderContext);
193189
194190 // If this is a conditional cast:
@@ -215,6 +211,8 @@ CastOptimizer::optimizeBridgedObjCToSwiftCast(SILDynamicCastInst dynamicCast) {
215211 SILValue load =
216212 Builder.createLoad (Loc, src, LoadOwnershipQualifier::Unqualified);
217213
214+ SILType silBridgedTy = *dynamicCast.getLoweredBridgedTargetObjectType ();
215+
218216 // If type of the source and the expected ObjC type are equal, there is no
219217 // need to generate the conversion from ObjCTy to
220218 // _ObjectiveCBridgeable._ObjectiveCType.
0 commit comments