SIL: Casts that may be to NSError must use indirect cast instructions.

checked_cast_br promises to maintain RC identity, but a cast from an ErrorType-conforming class to NSError may change the RC identity by bridging. Make sure that potential class-to-NSError casts go through the indirect cast entry points for now. The runtime implementation still needs to be fixed to handle the class-to-NSError case, but this is part of rdar://problem/21116814.

Swift SVN r29089
This commit is contained in:
Joe Groff
2015-05-27 22:50:37 +00:00
parent d4448b5c6d
commit 9c0695875e
11 changed files with 86 additions and 34 deletions

View File

@@ -1452,7 +1452,8 @@ emitSerialCastOperand(SILGenFunction &SGF, SILLocation loc,
bool requiresAddress = false;
for (auto &row : rows) {
CanType targetType = getTargetType(row);
if (!canUseScalarCheckedCastInstructions(sourceType, targetType)) {
if (!canUseScalarCheckedCastInstructions(SGF.SGM.M,
sourceType, targetType)) {
requiresAddress = true;
break;
}