mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Runtime checking for associated types conforming to invertible protocols
Emit metadata for runtime checks of conformances of associated types to invertible protocols, e.g., `T.Assoc: Copyable`. This allows us to correctly handle, e.g., dynamic casting involving conditional conformances that have such constraints. The model we use here is to emit an invertible-protocol constraint that leaves only the specific bit clear in the invertible protocol set.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "swift/SILOptimizer/Utils/CastOptimizer.h"
|
||||
#include "swift/AST/ExistentialLayout.h"
|
||||
#include "swift/AST/GenericSignature.h"
|
||||
#include "swift/AST/Module.h"
|
||||
#include "swift/AST/SubstitutionMap.h"
|
||||
@@ -1472,6 +1473,10 @@ static bool optimizeStaticallyKnownProtocolConformance(
|
||||
if (Conformance.isInvalid())
|
||||
return false;
|
||||
|
||||
auto layout = TargetType->getExistentialLayout();
|
||||
if (layout.getProtocols().size() != 1)
|
||||
return false;
|
||||
|
||||
SILBuilderWithScope B(Inst);
|
||||
SmallVector<ProtocolConformanceRef, 1> NewConformances;
|
||||
NewConformances.push_back(Conformance);
|
||||
|
||||
Reference in New Issue
Block a user