Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

SFlux Element Type Should be Declared as Covariant Type #54

Closed
jpork opened this issue May 26, 2020 · 4 comments · Fixed by #55
Closed

SFlux Element Type Should be Declared as Covariant Type #54

jpork opened this issue May 26, 2020 · 4 comments · Fixed by #55

Comments

@jpork
Copy link
Contributor

jpork commented May 26, 2020

In order to get SFlux's element types right for proper inheritance the element type should be declared covariant as it's usually done for container- or collection types in scala. See e.g. immutable.List:

sealed abstract class List[+A]

Currently SFlux's element type is declared invariant:

trait SFlux[T]

Which lets the following code fail for SFlux but not for List:

  trait Component

  trait Container{
    def component: Component

    def components: List[Component]

    def componentsFlux: SFlux[Component]
  }

  trait ComponentExt extends Component

  trait ContainerExt extends Container{
    def component: ComponentExt

    def components: List[ComponentExt]

    def componentsFlux: SFlux[ComponentExt]
  }
@sinwe
Copy link
Contributor

sinwe commented May 26, 2020

Thank you @jpork.
If you happen to have PR, feel free to raise. Otherwise I'll work on it soon

@sinwe
Copy link
Contributor

sinwe commented May 27, 2020

@jpork The reason it is using invariant is because it relies on the underlying Java reactor library. As we know Java generic type is invariant.
If you know any easy way to make it compatible with scala invariant, feel free to suggest

@jpork
Copy link
Contributor Author

jpork commented May 28, 2020

I've got SMono compile clean. But there are still lot of places to change. This will keep my busy a few moments.

@sinwe
Copy link
Contributor

sinwe commented May 28, 2020

Thanks @jpork. I'm intrigue to see.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

2 participants