Class-returning-function breaks nominal typing of instances
- 主要言語
- Rust
- スター
- 22.3k
- フォーク
- 1.9k
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Flow currently returns the same nominal type for functions returning fresh classes, e.g.
```js
function create() {
return class K {};
}
let K1 = create();
(create(): Class); // NG, but Flow yields a false positive
```
I currently have a memoizing polymorphic function that depends on this behavior, i.e.
```js
export class PointerList {
static _specials: { [hash: string]: Class> };
static of | BoolList>(_R: Class): Class> {
const hash = _R._hash();
const cached = this._specials[hash];
if (cached) {
return ((cached: any): Class>);
}
class List extends ByteAlignedList {
static _hash(): string {
return "L("+_R._hash()+")";
}
// ...
}
return this._specials[hash] = List;
}
}
```
Can I rely on this pattern?
コントリビューションガイド
評価
この issue はまだ評価されていません。