Outliner: Add comment explaining that getBridgeTo/FromObjectiveC returns an invalid SILDeclRef to signal that the type does not conform to the bridgeable protocol

This commit is contained in:
Arnold Schwaighofer
2019-12-11 10:35:06 -08:00
parent a6168a93bb
commit c4256e7992

View File

@@ -491,6 +491,8 @@ static bool matchSwitch(SwitchInfo &SI, SILInstruction *Inst,
auto NativeType = Apply->getType().getASTType();
auto *BridgeFun = FunRef->getInitiallyReferencedFunction();
auto *SwiftModule = BridgeFun->getModule().getSwiftModule();
// Not every type conforms to the ObjectiveCBridgeable protocol in such a case
// getBridgeFromObjectiveC returns SILDeclRef().
auto bridgeWitness = getBridgeFromObjectiveC(NativeType, SwiftModule);
if (bridgeWitness == SILDeclRef() ||
BridgeFun->getName() != bridgeWitness.mangle())
@@ -809,6 +811,8 @@ BridgedArgument BridgedArgument::match(unsigned ArgIdx, SILValue Arg,
auto NativeType = BridgedValue->getType().getASTType();
auto *BridgeFun = FunRef->getInitiallyReferencedFunction();
auto *SwiftModule = BridgeFun->getModule().getSwiftModule();
// Not every type conforms to the ObjectiveCBridgeable protocol in such a case
// getBridgeToObjectiveC returns SILDeclRef().
auto bridgeWitness = getBridgeToObjectiveC(NativeType, SwiftModule);
if (bridgeWitness == SILDeclRef() ||
BridgeFun->getName() != bridgeWitness.mangle())