Fix API match for type composition, Equatable, and Sendable#219
Merged
marcprux merged 2 commits intoskiptools:mainfrom Apr 4, 2026
Merged
Fix API match for type composition, Equatable, and Sendable#219marcprux merged 2 commits intoskiptools:mainfrom
marcprux merged 2 commits intoskiptools:mainfrom
Conversation
Contributor
Author
|
Flaky CI, but the core tests are passing. |
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.
I was working on adding support for
onGeometryChange, and I ran into what I believe is a bug in the transpiler, which this PR attempts to fix.(While I was working on it, @marcprux worked around this issue in an entirely different way in skiptools/skip-ui#364, making this PR technically no longer required. But, it seems best to file the PR anyway.)
We start with a test of the issue. My signature for
onGeometryChangelooked like this:That's a complex declaration, including the use of
EquatableandSendableas generic constraints, and, sure enough, it didn't wanna transpile properly, so I used a// SKIP DECLAREto transpile it.The bug is that, when I used
Boolas myT, and tried to use it in a playground, the API failed to match, and so the transpiler didn't add the.Compose(composectx)tail call that would make theComposeBuildervalid.I added this as a failing test in
SwiftUITests.swift.During matching,
Twas replaced with(Equatable & Sendable).Type, whichBoolfailed to match in three different ways:(X & Y).TypeEquatablein KotlinSendableSo, I also added a new test,
CompatibiltyScoreTests.swift, which is basically a snapshot test of the current compatibility scores. I added a bunch of regression tests (which I assumed had correct results), and I added four failing tests:Then, I fixed those tests.
I added support for
strippedTargetcase .namedincompatibilityScore:That fixed the first two failing tests in
CompatibiltyScoreTests.swift.I added support for
strippedTargetcase .composition, delegating toinheritanceCompatibilityScore, and, ininheritanceCompatibilityScore, incase .composition, I calledcompatibilityScoreon each of the composedprotocolTypes. If any of them werenil, we returnnil, and otherwise we take the average of the results. (Is that the right thing to do??) That then fixed the other two failing tests inCompatibiltyScoreTests.swift, as well as the SwiftUI test.Skip Pull Request Checklist:
swift testCursor assisted me in autogenerating
CompatibilityScoreTests.swift, which I then manually tweaked and read very carefully. It also attempted a fix for the tests, but I then rewrote the solution by hand, once I understood what was wrong.This is my very first attempt to work on the transpiler. I added a lot of tests, but I don't feel confident that I know what I'm doing.