Fix the error message when a cast to a protocol type fails.

rdar://22936612
This commit is contained in:
Greg Parker
2015-11-17 01:04:38 -08:00
parent 752649a711
commit e09027ca04
2 changed files with 7 additions and 3 deletions

View File

@@ -934,7 +934,7 @@ static bool _dynamicCastToExistential(OpaqueValue *dest,
if (!_conformsToProtocols(srcDynamicValue, srcDynamicType, if (!_conformsToProtocols(srcDynamicValue, srcDynamicType,
targetType->Protocols, targetType->Protocols,
destExistential->getWitnessTables())) { destExistential->getWitnessTables())) {
return _fail(src, srcType, targetType, flags); return _fail(srcDynamicValue, srcDynamicType, targetType, flags);
} }
auto object = *(reinterpret_cast<HeapObject**>(srcDynamicValue)); auto object = *(reinterpret_cast<HeapObject**>(srcDynamicValue));
@@ -953,7 +953,7 @@ static bool _dynamicCastToExistential(OpaqueValue *dest,
if (!_conformsToProtocols(srcDynamicValue, srcDynamicType, if (!_conformsToProtocols(srcDynamicValue, srcDynamicType,
targetType->Protocols, targetType->Protocols,
destExistential->getWitnessTables())) destExistential->getWitnessTables()))
return _fail(src, srcType, targetType, flags); return _fail(srcDynamicValue, srcDynamicType, targetType, flags);
// Fill in the type and value. // Fill in the type and value.
destExistential->Type = srcDynamicType; destExistential->Type = srcDynamicType;
@@ -977,7 +977,7 @@ static bool _dynamicCastToExistential(OpaqueValue *dest,
if (!_conformsToProtocols(srcDynamicValue, srcDynamicType, if (!_conformsToProtocols(srcDynamicValue, srcDynamicType,
targetType->Protocols, targetType->Protocols,
&errorWitness)) &errorWitness))
return _fail(src, srcType, targetType, flags); return _fail(srcDynamicValue, srcDynamicType, targetType, flags);
BoxPair destBox = swift_allocError(srcDynamicType, errorWitness, BoxPair destBox = swift_allocError(srcDynamicType, errorWitness,
srcDynamicValue, srcDynamicValue,

View File

@@ -36,6 +36,10 @@ class ObjCClass2 : NSObject { }
% objectTypes.append(['NSDateFormatter', 'NSNumberFormatter']) % objectTypes.append(['NSDateFormatter', 'NSNumberFormatter'])
// non-Swift Objective-C class // non-Swift Objective-C class
% protocolTypes.append('a.Proto1')
% protocolTypes.append('a.Proto2')
protocol Proto1 { }
protocol Proto2 { }
% protocolTypes.append('NSURLSessionDelegate') % protocolTypes.append('NSURLSessionDelegate')
// non-Swift Objective-C protocol // non-Swift Objective-C protocol