Skip to content

Conversation

andrewheard
Copy link
Contributor

Silenced the followed warning on on extension SafetyRating: Comparable:

Extension declares a conformance of imported type 'SafetyRating' to imported protocol 'Comparable'; this will not behave correctly if the owners of 'FirebaseVertexAI' introduce this conformance in the future

SafetyRating does not have a natural ordering because its property let category: SafetySetting.HarmCategory does not (e.g., dangerousContent can't be compared as being greater than or equal to harassment):

public enum HarmCategory: String, Sendable {
/// Unknown. A new server value that isn't recognized by the SDK.
case unknown = "HARM_CATEGORY_UNKNOWN"
/// Unspecified by the server.
case unspecified = "HARM_CATEGORY_UNSPECIFIED"
/// Harassment content.
case harassment = "HARM_CATEGORY_HARASSMENT"
/// Negative or harmful comments targeting identity and/or protected attributes.
case hateSpeech = "HARM_CATEGORY_HATE_SPEECH"
/// Contains references to sexual acts or other lewd content.
case sexuallyExplicit = "HARM_CATEGORY_SEXUALLY_EXPLICIT"
/// Promotes or enables access to harmful goods, services, or activities.
case dangerousContent = "HARM_CATEGORY_DANGEROUS_CONTENT"
}

For this reason, it is reasonable to assume that we will not add Comparable conformance to SafetyRating in the SDK and the warning can be ignored with Swift.Comparable in the unit-test.

Note: Swift.Comparable is equivalent to @retroactive Comparable but is supported prior to Swift 6 (see SE-0364 for more details).

#no-changelog

Copy link
Member

@ncooke3 ncooke3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice summary of the issue!

@andrewheard andrewheard merged commit e81ea8e into main Sep 13, 2024
32 checks passed
@andrewheard andrewheard deleted the ah/vertex-ext-warn branch September 13, 2024 18:56
@firebase firebase locked and limited conversation to collaborators Oct 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants