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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the change required? What's wrong with the original implementation?
I think if this test is broken, it would be broken for users too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It all comes to how the implicit are resolved, in short let's start with a description from PR:
In shapeless there is defined a given method creating both
K0.Instances
andK0.ProductInstances
Under the old implicit rule, we were getting granted the most specific available type, in our case that's ProductInstances, so even though there exists
inline given mkInstances[F[_], T](using gen: Generic[T]): Instances[F, T]
it would never be picked, instead, the compiler would always chooseinline given mkProductInstances[F[_], T](using gen: ProductGeneric[T]): ProductInstances[F, T]
Now, since 3.6 when asked for
K0.Instances
and when having an access to instance of this type directly, compiler would choose it instead of using it's more specific subtype.Because of this single change, the result of the summon has changed. We no longer have access to
ProductInstances
but to theInstances
. Now in the next few lines when we try to usefoldLeft
on transformed values, we get to the clue of the problem - there is no instance ofFoldable
instance defined forK0.Instances
so the compilation files with type mismatch.Overall it's very similar to the case from the PR's snippert:
In the case of shapeless the only difference was that both
ProductInstances
andCoproductInstances
could have never been constructed at the same time, which allowed for compilation.Probably using method similar to
K0.mkInstances[?, ?]
after making ittransparent inline
but notgiven
should be a decent workaround instead of usingsummon[K0.Instances[?, ?]]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, thanks -
foldLeft
is missing fromInstances
. That's fine.