Skip to content

Commit bb64446

Browse files
committed
[CoreFoundation] _CFObject: Provide default implementation for _hash(into:)
Without this change, the Hashable synthesizer attempts to add _hash(into:) methods directly on CF types, which (somewhat unsurprisingly) fails with the following assert: Assertion failed: (!decl->isForeign() && "Use getForeignMetadataLayout()"), function getClassMetadataLayout, file /Users/lorentey/Swift/swift/lib/IRGen/MetadataLayout.cpp, line 86. 0 swift 0x0000000108e28b08 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40 1 swift 0x0000000108e29216 SignalHandler(int) + 694 2 libsystem_platform.dylib 0x00007fff587aef5a _sigtramp + 26 3 libsystem_platform.dylib 0x0000000000003628 _sigtramp + 2810529512 4 libsystem_c.dylib 0x00007fff585571ae abort + 127 5 libsystem_c.dylib 0x00007fff5851f1ac basename_r + 0 6 swift 0x0000000105a2a460 swift::irgen::IRGenModule::getClassMetadataLayout(swift::ClassDecl*) + 96 7 swift 0x0000000105970dc8 swift::irgen::emitVirtualMethodValue(swift::irgen::IRGenFunction&, llvm::Value*, swift::SILDeclRef, swift::CanTypeWrapper<swift::SILFunctionType>) + 184 8 swift 0x000000010597121d swift::irgen::emitVirtualMethodValue(swift::irgen::IRGenFunction&, llvm::Value*, swift::SILType, swift::SILDeclRef, swift::CanTypeWrapper<swift::SILFunctionType>, bool) + 685 9 swift 0x0000000105a01482 swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 36562 10 swift 0x00000001059f4e4f (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 6863 11 swift 0x00000001059f2e1b swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 1371 12 swift 0x00000001058fccab swift::irgen::IRGenerator::emitLazyDefinitions() + 1051 13 swift 0x00000001059cf676 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1366 14 swift 0x00000001059cfc5e swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, unsigned int, llvm::GlobalVariable**) + 94 15 swift 0x000000010586d2a9 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 15337 16 swift 0x0000000105868715 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2869 17 swift 0x000000010581f300 main + 2832 18 libdyld.dylib 0x00007fff584ab015 start + 1
1 parent 73af8ff commit bb64446

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

stdlib/public/SDK/CoreFoundation/CoreFoundation.swift

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ extension _CFObject {
1717
public var hashValue: Int {
1818
return Int(bitPattern: CFHash(self))
1919
}
20+
public func _hash(into hasher: _UnsafeHasher) -> _UnsafeHasher {
21+
return hasher.appending(self.hashValue)
22+
}
2023
public static func ==(left: Self, right: Self) -> Bool {
2124
return CFEqual(left, right)
2225
}

0 commit comments

Comments
 (0)