Skip to content

Conversation

@cherylEnkidu
Copy link
Contributor

Compared with the Android SDK implementation (reference: the linked commit), Android provides static functions such as Expression.rawFunction and BooleanExpression.rawFunction to create raw expressions. In the iOS SDK, both Expression and BooleanExpression are protocols, and we prefer not to introduce additional static factory methods. Instead, both use cases are covered by the FunctionExpression() constructor, which provides equivalent functionality without adding static APIs.

@gemini-code-assist
Copy link
Contributor

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

@google-oss-bot
Copy link

1 Warning
⚠️ Did you forget to add a changelog entry? (Add #no-changelog to the PR description to silence this warning.)

Generated by 🚫 Danger

@cherylEnkidu
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a significant and beneficial refactoring by changing BooleanExpression from a class to a protocol, which is more idiomatic in Swift. The new Expression.asBoolean() method provides a clean and type-safe way to perform conversions. The changes are well-implemented and include corresponding test updates. I have a couple of suggestions to enhance the code further, mainly regarding code style and ensuring the public API remains consistent.

Comment on lines 379 to 396
func asBoolean() -> BooleanExpression {
if let boolExpr = self as? BooleanExpression {
return boolExpr
}
if let constant = self as? Constant {
return BooleanConstant(constant)
}
if let field = self as? Field {
return BooleanField(field)
}
if let funcExpr = self as? FunctionExpression {
return BooleanFunctionExpression(funcExpr)
}
// This should be unreachable if all expression types are handled.
fatalError(
"Unknown expression type \(Swift.type(of: self)) cannot be converted to BooleanExpression"
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

low

For better readability and to follow Swift idioms, consider using a switch statement here instead of a chain of if-let statements. A switch statement makes the different cases clearer and is often more efficient for type casting.

  func asBoolean() -> BooleanExpression {
    switch self {
    case let boolExpr as BooleanExpression:
      return boolExpr
    case let constant as Constant:
      return BooleanConstant(constant)
    case let field as Field:
      return BooleanField(field)
    case let funcExpr as FunctionExpression:
      return BooleanFunctionExpression(funcExpr)
    default:
      // This should be unreachable if all expression types are handled.
      fatalError(
        "Unknown expression type \(Swift.type(of: self)) cannot be converted to BooleanExpression"
      )
    }
  }

cherylEnkidu and others added 3 commits November 26, 2025 16:29
…xpressions/BooleanExpression.swift

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…xpressions/BooleanExpression.swift

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants