@samitouri / QOS-React-2 / commits / 81b23f9242

[typer][be] Add helper for checking type.kind

Sathya Gunasekaran committed Feb 14, 2023 at 19:10 UTC 81b23f92423b06c411b6bbb6987d3056aa1ff47e
1 file changed +8 -4
compiler/forget/src/HIR/HIR.ts
+8 -4
@@ -691,20 +691,24 @@ function typeVarEquals(tA: Type, tB: Type): boolean {
691 return false;
692 }
693
694 +function typeKindCheck(tA: Type, tb: Type, type: string): boolean {
695 + return tA.kind === type && tb.kind === type;
696 +}
697 +
698 function primitiveTypeEquals(tA: Type, tB: Type): boolean {
695 - return tA.kind === "Primitive" && tB.kind === "Primitive";
699 + return typeKindCheck(tA, tB, "Primitive");
700 }
701
702 function polyTypeEquals(tA: Type, tB: Type): boolean {
699 - return tA.kind === "Poly" && tB.kind === "Poly";
703 + return typeKindCheck(tA, tB, "Poly");
704 }
705
706 function objectTypeEquals(tA: Type, tB: Type): boolean {
703 - return tA.kind === "Object" && tB.kind === "Object";
707 + return typeKindCheck(tA, tB, "Object");
708 }
709
710 function funcTypeEquals(tA: Type, tB: Type): boolean {
707 - return tA.kind === "Function" && tB.kind === "Function";
711 + return typeKindCheck(tA, tB, "Function");
712 }
713
714 function phiTypeEquals(tA: Type, tB: Type): boolean {