mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix the error message when a cast to a protocol type fails.
rdar://22936612
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user