mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix two bugs related to the casts optimizations.
The protocol_lookup the testcase from Interpreter test-cases exposed two bugs, once I tried to compiler with with -O: - SILCloner was generating an open_existential_ref from an open_existential_metatype instruction during cloning even if the existential in question was not a class existential. - DynamicCasts was not considering the fact that subclasses of a given class may implement a protocol, even if the class does not implement it. Swift SVN r27260
This commit is contained in:
@@ -130,6 +130,13 @@ classifyDynamicCastToProtocol(CanType source,
|
||||
if (auto *CD = source.getClassOrBoundGenericClass()) {
|
||||
if (canClassOrSuperclassesHaveExtensions(CD, isWholeModuleOpts))
|
||||
return DynamicCastFeasibility::MaySucceed;
|
||||
// Derived types may conform to the protocol.
|
||||
if (!CD->isFinal()) {
|
||||
// TODO: If it is a private type or internal type and we
|
||||
// can prove that there are no derived types conforming to a
|
||||
// protocol, then we can still return WillFail.
|
||||
return DynamicCastFeasibility::MaySucceed;
|
||||
}
|
||||
}
|
||||
|
||||
// If the source type is private or target protocol is private,
|
||||
|
||||
Reference in New Issue
Block a user