Skip to content

Commit

Permalink
fix: Add attribute nonnull_error if returning pointer and error
Browse files Browse the repository at this point in the history
Signed-off-by: jefft0 <[email protected]>
  • Loading branch information
jefft0 committed Oct 5, 2022
1 parent fa6bcb0 commit b50c057
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions bind/genobjc.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,11 @@ func (s *funcSummary) asSignature(g *ObjcGen) string {
}
params = append(params, fmt.Sprintf("%s:(%s)%s", key, g.objcType(p.typ)+"* _Nullable", p.name))
}
if len(params) > 0 && params[len(params)-1] == ":(NSError* _Nullable* _Nullable)error" &&
(s.ret == "NSData* _Nullable" || s.ret == "NSString* _Nullable") {
// Allow returning nil to Swift.
params = append(params, "__attribute__((swift_error(nonnull_error)))")
}
return strings.Join(params, " ")
}

Expand Down

0 comments on commit b50c057

Please sign in to comment.