mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Fix a bug in the casts optimizations.
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 r27265
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