From 81b23f92423b06c411b6bbb6987d3056aa1ff47e Mon Sep 17 00:00:00 2001 From: Sathya Gunasekaran Date: Tue, 14 Feb 2023 19:10:37 +0000 Subject: [PATCH] [typer][be] Add helper for checking type.kind --- compiler/forget/src/HIR/HIR.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/compiler/forget/src/HIR/HIR.ts b/compiler/forget/src/HIR/HIR.ts index 6f823d4057..50c8dd0242 100644 --- a/compiler/forget/src/HIR/HIR.ts +++ b/compiler/forget/src/HIR/HIR.ts @@ -691,20 +691,24 @@ function typeVarEquals(tA: Type, tB: Type): boolean { return false; } +function typeKindCheck(tA: Type, tb: Type, type: string): boolean { + return tA.kind === type && tb.kind === type; +} + function primitiveTypeEquals(tA: Type, tB: Type): boolean { - return tA.kind === "Primitive" && tB.kind === "Primitive"; + return typeKindCheck(tA, tB, "Primitive"); } function polyTypeEquals(tA: Type, tB: Type): boolean { - return tA.kind === "Poly" && tB.kind === "Poly"; + return typeKindCheck(tA, tB, "Poly"); } function objectTypeEquals(tA: Type, tB: Type): boolean { - return tA.kind === "Object" && tB.kind === "Object"; + return typeKindCheck(tA, tB, "Object"); } function funcTypeEquals(tA: Type, tB: Type): boolean { - return tA.kind === "Function" && tB.kind === "Function"; + return typeKindCheck(tA, tB, "Function"); } function phiTypeEquals(tA: Type, tB: Type): boolean {