Skip to content

Commit e9ab6b9

Browse files
committed
fix: Add attribute nonnull_error if returning pointer and error
Signed-off-by: jefft0 <[email protected]>
1 parent aaac322 commit e9ab6b9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: bind/genobjc.go

+5
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ func (s *funcSummary) asSignature(g *ObjcGen) string {
582582
}
583583
params = append(params, fmt.Sprintf("%s:(%s)%s", key, g.objcType(p.typ)+"* _Nullable", p.name))
584584
}
585+
if params[len(params)-1] == ":(NSError* _Nullable* _Nullable)error" &&
586+
(s.ret == "NSData* _Nullable" || s.ret == "NSString* _Nullable") {
587+
// Allow returning nil to Swift.
588+
params = append(params, "__attribute__((swift_error(nonnull_error)))")
589+
}
585590
return strings.Join(params, " ")
586591
}
587592

0 commit comments

Comments
 (0)