Skip to content

Type inference issues when using intersection types #18226

Closed
@IndiscriminateCoding

Description

@IndiscriminateCoding

Compiler version

3.3.0

Minimized code

trait F[-R]

trait Row[A]

def eliminateInt[R](f: F[R & Row[Int]]): F[R] = new F[R] {}

val x = new F[Row[Int] & Row[String]] {}

val _ = eliminateInt[Row[String]](x) // compiles OK when given explicit type
val _ = eliminateInt(x) // error!

Output

Found:    (app.x : app.F[app.Row[Int] & app.Row[String]])
Required: app.F[app.Row[Int]]

Expectation

I expect compiler to be able to infer [R] instantiation based on a type of a passed value.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions