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>).