facebook / facebook/flow

Support for recursive type bounds

Open
#3,437 0 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
Rust
Stars
22.3k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

It would be nice to support recursive type bounds.

I was trying to do something like the following:

```swift
interface Vector {
subVectors(a :VT, b :VT) :VT;
}

class VecRange> {
create() :VectorT {
throw new Error("abstract");
}

constructor(min :VectorT, max :VectorT) {
this.gamut = this.create().subVectors(max, min);
}
}
```

but such fanciness appears not to be supported. This sort of thing is quite common in Java &c where you might do something like:

```java
interface Vector {
public VT sub (VT a, VT b);
}

abstract class VecRange> {
public abstract VectorT create();
public VectorT gamut (VectorT max, VectorT min) {
return this.create().sub(max, min);
}
}

class Vector3 implements Vector {
public Vector3 sub (Vector3 a, Vector3 b) { return null; /*stub*/ }
}

class VecRange3 extends VecRange {
public Vector3 create() {
return new Vector3();
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.