From 099cc87e944e8abd5796718936f564256a92a9ce Mon Sep 17 00:00:00 2001 From: Naitik Shah Date: Thu, 15 May 2025 21:43:42 +0400 Subject: [PATCH] allow for custom protocol implementations to skip Has* methods --- objc/protocol.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/objc/protocol.go b/objc/protocol.go index 0c66b018..d550e7fc 100644 --- a/objc/protocol.go +++ b/objc/protocol.go @@ -315,6 +315,11 @@ func respondsTo(goID uintptr, sel unsafe.Pointer) bool { if mi.required { return true } + // invalid hasFunc means no HasXXX method, but the XXX method does exist. + // this indicates the optional method is implemented by this implementation. + if !mi.hasFunc.IsValid() { + return true + } return mi.hasFunc.Call([]reflect.Value{v})[0].Bool() }