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,
|
||||
targetType->Protocols,
|
||||
destExistential->getWitnessTables())) {
|
||||
return _fail(src, srcType, targetType, flags);
|
||||
return _fail(srcDynamicValue, srcDynamicType, targetType, flags);
|
||||
}
|
||||
|
||||
auto object = *(reinterpret_cast<HeapObject**>(srcDynamicValue));
|
||||
@@ -953,7 +953,7 @@ static bool _dynamicCastToExistential(OpaqueValue *dest,
|
||||
if (!_conformsToProtocols(srcDynamicValue, srcDynamicType,
|
||||
targetType->Protocols,
|
||||
destExistential->getWitnessTables()))
|
||||
return _fail(src, srcType, targetType, flags);
|
||||
return _fail(srcDynamicValue, srcDynamicType, targetType, flags);
|
||||
|
||||
// Fill in the type and value.
|
||||
destExistential->Type = srcDynamicType;
|
||||
@@ -977,7 +977,7 @@ static bool _dynamicCastToExistential(OpaqueValue *dest,
|
||||
if (!_conformsToProtocols(srcDynamicValue, srcDynamicType,
|
||||
targetType->Protocols,
|
||||
&errorWitness))
|
||||
return _fail(src, srcType, targetType, flags);
|
||||
return _fail(srcDynamicValue, srcDynamicType, targetType, flags);
|
||||
|
||||
BoxPair destBox = swift_allocError(srcDynamicType, errorWitness,
|
||||
srcDynamicValue,
|
||||
|
||||
@@ -36,6 +36,10 @@ class ObjCClass2 : NSObject { }
|
||||
% objectTypes.append(['NSDateFormatter', 'NSNumberFormatter'])
|
||||
// non-Swift Objective-C class
|
||||
|
||||
% protocolTypes.append('a.Proto1')
|
||||
% protocolTypes.append('a.Proto2')
|
||||
protocol Proto1 { }
|
||||
protocol Proto2 { }
|
||||
% protocolTypes.append('NSURLSessionDelegate')
|
||||
// non-Swift Objective-C protocol
|
||||
|
||||
|
||||
Reference in New Issue
Block a user