Fix GenIso.fields compilation after IsoFields wildcard change#1601
Closed
mbovel wants to merge 1 commit into
Closed
Fix GenIso.fields compilation after IsoFields wildcard change#1601mbovel wants to merge 1 commit into
mbovel wants to merge 1 commit into
Conversation
PR optics-dev#1574 changed IsoFields.apply to return PIso[S, S, ? <: Tuple, ? <: Tuple], but the fallback arm of GenIso._fields passes that expression to whitebox[A](e: Expr[Iso[S, A]]), and the wildcard type cannot unify with Iso[S, A]. Widen whitebox to accept Expr[PIso[S, S, ?, ?]], which all three match arms conform to; the cast it performs is unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
Author
|
This fix is the minimal change; but I think we can do better and instead completely remove |
Contributor
Author
|
Closing in favor of #1602. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CI on
masteris failing since #1574 with:#1574 changed
IsoFields.applyto returnPIso[S, S, ? <: Tuple, ? <: Tuple], but the fallback arm ofGenIso._fieldspasses that expression towhitebox[A](e: Expr[Iso[S, A]]), and the wildcard type cannot unify withIso[S, A](which requires both type parameters to be the sameA).Fix
Widen
whiteboxto acceptExpr[PIso[S, S, ?, ?]]. All three match arms conform to it (Expris covariant andIso[S, A] = PIso[S, S, A, A]), and the cast it performs is unchanged. SinceGenIso.fieldsistransparent inline, the precise type is still inferred at call sites.Verification
sbt '++ 3' macrosJVM/test: compiles, 130/130 tests pass, includingGenIso.fieldson a two-field case class which exercises the fixed fallback arm.sbt '++ 3' macrosJVM/scalafmtCheck: passes.🤖 Generated with Claude Code