SIL: Use objc_method instruction for Objective-C protocol method calls

Fixes <rdar://problem/15933365>.
This commit is contained in:
Slava Pestov
2017-11-29 00:27:21 -08:00
parent a23d1fa0d7
commit 1ee0970934
31 changed files with 75 additions and 110 deletions

View File

@@ -2332,19 +2332,21 @@ public:
auto methodSelfType = getMethodSelfType(methodType);
auto operandType = OMI->getOperand()->getType();
auto operandInstanceType = operandType.getSwiftRValueType();
if (auto metatypeType = dyn_cast<MetatypeType>(operandInstanceType))
operandInstanceType = metatypeType.getInstanceType();
if (methodSelfType.isClassOrClassMetatype()) {
if (operandInstanceType.getClassOrBoundGenericClass()) {
auto overrideTy = TC.getConstantOverrideType(member);
requireSameType(
OMI->getType(), SILType::getPrimitiveObjectType(overrideTy),
"result type of objc_method must match abstracted type of method");
require(operandType.isClassOrClassMetatype(),
"operand must be of a class type");
require(methodSelfType.isClassOrClassMetatype(),
"method self type must be of a class type");
} else {
require(getDynamicMethodType(operandType, OMI->getMember())
.getSwiftRValueType()
->isBindableTo(OMI->getType().getSwiftRValueType()),
"result must be of the method's type");
require(isa<ArchetypeType>(operandInstanceType) ||
operandInstanceType->isObjCExistentialType(),
"operand type must be an archetype or self-conforming existential");
verifyOpenedArchetype(OMI, OMI->getType().getSwiftRValueType());
}