Skip to content

Premature incompatibily errors in generic classes definitions #3711

@Gozala

Description

@Gozala

Here is simplified example:

class Task <x, a> {
  static spawn: <b> (task:Task<empty, b>) => Task<empty, b>
  spawn <b> ():Task<empty, b> {
    return Task.spawn(this)
  }
}

Here flow reports following error:

  6:     return Task.spawn(this)
                ^^^^^^^^^^^^^^^^ call of method `spawn`
  3: class Task <x, a> {
                 ^ x. This type is incompatible with
  4:   static spawn: <a, b> (task:Task<empty, a>) => Task<empty, b>
                                       ^^^^^ empty

What I actually expect is for flow to report type error when task.spawn() is called on tasks that can fail (Task<error, value>) and report no errors when called on tasks that can not fail (Task<empty, value>).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions