[typer] Reuse PolyType objects

This commit is contained in:
Sathya Gunasekaran
2022-12-20 13:38:08 +00:00
parent 2c3e572566
commit 6f06b0e08a
+8 -5
View File
@@ -317,12 +317,15 @@ class Unifier {
objectType.kind === "Object" &&
objectType.properties.has(name[0])
) {
const newType: Type = {
kind: "Poly",
};
let type = objectType.properties.get(name[0])!;
if (type.kind === "Poly") {
return type;
}
objectType.properties.set(name[0], newType);
return newType;
type = { kind: "Poly" };
objectType.properties.set(name[0], type);
return type;
}
return null;