feat: improve type safety when combining unis with limited concurrency #1736
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.
As discussed in #1735, this PR adds method overriding of the
usingConcurrencyOf(int)
to the classesUniAndGroup2
,UniAndGroup3
,UniAndGroup4
and similar classes.Currently,
usingConcurrencyOf(int)
is implemented only in their common parent classUniAndGroupIterable
which return anUniAndGroupIterable
object, resulting in a loss of type information.For example:
In this example, we must use
.with(List<T1>)
ofUniAndGroupIterable
which lacks specific type information about each uni. As a result, we nee to cast each list element to its expected type, which may easily introduce new errors.With this PR, the
usingConcurrencyOf
method in each typedUniAndGroupX
class returns the appropriate typedUniAndGroupX
instance. This allows the use of the corresponding.with
method directly, simplifying the example as follows:This solution maintains the source API without breaking any existing test. However, Revapi flags it as a binary incompatibility issue due to a covariant return type change (see https://revapi.org/revapi-java/0.28.1/differences.html#java.method.returnTypeChangedCovariantly).