Skip to content

Compiler cannot unify types of a GADT #12390

Closed
@regiskuckaertz

Description

@regiskuckaertz

Compiler version

3.0.0-RC3

Minimized code

enum Func[-A, +B] {
  case Double extends Func[Int, Int]
  case ToString extends Func[Float, String]

  def run: A => B = this match {
    case Double => (x: Int) => x * 2
    case ToString => (x: Float) => x.toString
  }
}

Output

// The compiler complains at each case:
Found: Int
Required: B
// and
Fount: String
Required: B

Expectation

The compiler should be able to unify B with Int or String depending on the case being evaluated.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions