Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseRenderContext.eventHandler(...) has unsafe variance for PropsT and OutputT #891

Open
RBusarow opened this issue Oct 27, 2022 · 0 comments

Comments

@RBusarow
Copy link
Collaborator

When compiling against Kotlin 1.7.x, this code produces warnings:

public interface BaseRenderContext<out PropsT, StateT, in OutputT> {

  // ...

  public fun eventHandler(
    name: () -> String = { "eventHandler" },
    update: WorkflowAction<PropsT, StateT, OutputT>.Updater.() -> Unit
  ): () -> Unit {
    return {
      actionSink.send(action(name, update))
    }
  }

  // ...

}
Type parameter PropsT is declared as 'out' but occurs in 'in' position in type WorkflowAction<PropsT, StateT, OutputT>.Updater.() -> Unit. This will become an error in Kotlin 1.9

All of the evenHandler() functions are the same.

Changing the variance in BaseRenderContext then requires changing it in RealRenderContext, but that's the only side effect within Workflow. That change does affect the public API, though.

@rjrjr rjrjr modified the milestone: ui-1.0 Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants