mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
IRGen: fix how metadata is loaded for fast class casting
Pass the correct type to `emitHeapMetadataRefForHeapObject()`. Fixes a runtime crash in case a class protocol is cast to a final swift class, where the actual object is an ObjectiveC class instance. rdar://99626888
This commit is contained in:
@@ -1108,7 +1108,7 @@ llvm::Value *irgen::emitFastClassCastIfPossible(IRGenFunction &IGF,
|
||||
|
||||
// Load the isa pointer.
|
||||
llvm::Value *objMetadata = emitHeapMetadataRefForHeapObject(IGF, instance,
|
||||
targetFormalType, GenericSignature(), /*suppress cast*/ true);
|
||||
sourceFormalType, GenericSignature(), /*suppress cast*/ true);
|
||||
llvm::Value *rhs = IGF.Builder.CreateBitCast(objMetadata, IGF.IGM.Int8PtrTy);
|
||||
|
||||
// return isa_ptr == metadata_ptr ? instance : nullptr
|
||||
|
||||
Reference in New Issue
Block a user