Skip to content

Drop the [Any, Any] type arguments from assertEquals - #76

Merged
halotukozak merged 1 commit into
mainfrom
munit-union-compare
Oct 5, 2026
Merged

halotukozak merged 1 commit into
mainfrom
munit-union-compare

Conversation

@halotukozak

@halotukozak halotukozak commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Tests no longer need assertEquals[Any, Any] to compare union types (for example X | Null under -Yexplicit-nulls).

munit derives Compare[A, B] from compareSubtypeWithSupertype[A, B](using A <:< B). Resolving a given with a nested using for a union type makes -Winfer-union warn, even with explicit type arguments, although nothing is inferred there. That looks like a compiler false positive.

The new UnionSafeCompare test trait provides the same two instances through type bounds (A <: B / B <: A), which compile without the warning. The subtype instance lives in a subtrait so that it wins when both apply. Comparing unrelated types still fails to compile with munit's "Can't compare".

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Improved test coverage for union-result matching, including comparisons where expected and actual values have related types. This helps verify that matching results are compared correctly.

munit's Compare instances take an `A <:< B` given, and resolving one for a union type
trips -Winfer-union. A UnionSafeCompare test trait gives the same instances through
type bounds, which compile without the warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: cd27e330-e533-47a7-a278-8ecf8aca161c
📥 Commits

Reviewing files that changed from the base of the PR and between 343e241 and 7290c9a.

📒 Files selected for processing (2)
  • test/mrpc/UnionSafeCompare.scala
  • test/mrpc/derive/MatchSuite.scala
 ___________________________________
< Tom & Jerry level of bug chasing. >
 -----------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@halotukozak
halotukozak enabled auto-merge October 5, 2026 07:23
@halotukozak
halotukozak merged commit 77ad946 into main Oct 5, 2026
8 of 9 checks passed
@halotukozak
halotukozak deleted the munit-union-compare branch October 5, 2026 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant