Skip to content

Contravariance prevents proper type derivation in Scala 2.13.0 #11570

Open
@swachter

Description

@swachter
// if using Scala 2.13.0 then a compile error results in marked line below
// ("found Step[B with A]; required Step[A]")
// if using Dotty then it compiles fine
// after removing the contravariance from Step[E] it compiles also under Scala 2.13

// a Step requires some environment
type Step[-E]

// providing a 'p' allows to transform a step that requires an environment with P into a step that does no more require a P
def provide[E, P](p: P): Step[E with P] => Step[E] = ???

trait A
trait B

val step: Step[A with B] = ???

val b: B = ???

// the compile error occurs here
val s: Step[A] = provide(b)(step)

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)typer

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions