mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Perform a dynamic method call if a class has objc ancestry in speculative devirt as fallback.
If a class has an @objc ancestry this class can be dynamically overridden and therefore we don't know the default case even if we see the full class hierarchy. rdar://23228386
This commit is contained in:
@@ -217,6 +217,13 @@ static bool isDefaultCaseKnown(ClassHierarchyAnalysis *CHA,
|
||||
if (CD->isFinal())
|
||||
return true;
|
||||
|
||||
// If the class has an @objc ancestry it can be dynamically subclassed and we
|
||||
// can't therefore statically know the default case.
|
||||
auto Ancestry = CD->checkObjCAncestry();
|
||||
if (Ancestry != ObjCClassKind::NonObjC &&
|
||||
Ancestry != ObjCClassKind::ObjCMembers)
|
||||
return false;
|
||||
|
||||
// Without an associated context we cannot perform any
|
||||
// access-based optimizations.
|
||||
if (!DC)
|
||||
|
||||
Reference in New Issue
Block a user