mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[be] Clean up null -> PolyType in ObjectShape
---
Question - should the unifier ignore `PolyType` for now?
```js
class Unifier {
// ...
bindVariableTo(v: TypeVar, type: Type) {
if (type.kind === "Poly") {
return;
}
// ...
```
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
IdentifierId,
|
||||
makeIdentifierId,
|
||||
ObjectType,
|
||||
PolyType,
|
||||
ValueKind,
|
||||
} from "./HIR";
|
||||
import { Hook } from "./Hooks";
|
||||
@@ -84,7 +85,7 @@ export class Environment {
|
||||
getPropertyType(
|
||||
receiver: ObjectType | FunctionType,
|
||||
property: string
|
||||
): BuiltInType | null {
|
||||
): BuiltInType | PolyType | null {
|
||||
const { shapeId } = receiver;
|
||||
if (shapeId !== null) {
|
||||
// If an object or function has a shapeId, it must have been assigned
|
||||
|
||||
@@ -38,7 +38,7 @@ function createAnonId(): string {
|
||||
*/
|
||||
export function addFunction(
|
||||
registry: ShapeRegistry,
|
||||
properties: Iterable<[string, BuiltInType | null]>,
|
||||
properties: Iterable<[string, BuiltInType | PolyType]>,
|
||||
fn: FunctionSignature
|
||||
): FunctionType {
|
||||
const shapeId = createAnonId();
|
||||
@@ -58,7 +58,7 @@ export function addFunction(
|
||||
export function addObject(
|
||||
registry: ShapeRegistry,
|
||||
id: string | null,
|
||||
properties: Iterable<[string, BuiltInType | null]>
|
||||
properties: Iterable<[string, BuiltInType | PolyType]>
|
||||
): ObjectType {
|
||||
const shapeId = id ?? createAnonId();
|
||||
addShape(registry, shapeId, properties, null);
|
||||
@@ -71,7 +71,7 @@ export function addObject(
|
||||
function addShape(
|
||||
registry: ShapeRegistry,
|
||||
id: string,
|
||||
properties: Iterable<[string, BuiltInType | null]>,
|
||||
properties: Iterable<[string, BuiltInType | PolyType]>,
|
||||
functionType: FunctionSignature | null
|
||||
): ObjectShape {
|
||||
const shape: ObjectShape = {
|
||||
@@ -110,7 +110,7 @@ export type FunctionSignature = {
|
||||
* are both represented by {@link ObjectShape.functionType}.
|
||||
*/
|
||||
export type ObjectShape = {
|
||||
properties: Map<string, BuiltInType | null>;
|
||||
properties: Map<string, BuiltInType | PolyType>;
|
||||
functionType: FunctionSignature | null;
|
||||
};
|
||||
|
||||
|
||||
@@ -236,6 +236,11 @@ class Unifier {
|
||||
}
|
||||
|
||||
bindVariableTo(v: TypeVar, type: Type): void {
|
||||
if (type.kind === "Poly") {
|
||||
// Ignore PolyType, since we don't support polymorphic types correctly.
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.substitutions.has(v.id)) {
|
||||
this.unify(this.substitutions.get(v.id)!, type);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user