Incendo / Incendo/cloud

bug: `Command.Builder<C>.senderType` must narrow the sender type down

Open
#793 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
548
Forks
60
PR merge metrics
No merged PRs in 30d

Description

As can be seen from this line:
https://github.com/Incendo/cloud/blob/3c83f9a680609299894406a2de2502209c16f113/cloud-kotlin/cloud-kotlin-extensions/src/main/kotlin/org/incendo/cloud/kotlin/extension/CommandBuildingExtensions.kt#L81
The type is not being narrowed, even though the Java version of the method for both Class and TypeToken overloads does narrow it down. This could be fixed in the following way:

public fun <C : Any, N : C> Command.Builder<C>.senderType(type: KClass<out N>): Command.Builder<N> =
    senderType(type.java)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at cloud-kotlin/cloud-kotlin-extensions/src/main/kotlin/org/incendo/cloud/kotlin/extension/CommandBuildingExtensions.kt:81 and compare the Java Class and TypeToken overloads mentioned in the issue. Confirm that the KClass overload narrows Command.Builder to Command.Builder for KClass, and verify that the resulting Kotlin API has the expected inferred sender type.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.