From 622851aaaa14840c3f3a2c08d959e8f8dc0005fc Mon Sep 17 00:00:00 2001 From: Johanna Stuber Date: Sun, 31 Jan 2021 17:41:27 +0100 Subject: [PATCH] Implement TypeInfererLet::getLetConstraints() --- .../java/edu/kit/typicalc/model/TypeInfererLet.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/edu/kit/typicalc/model/TypeInfererLet.java b/src/main/java/edu/kit/typicalc/model/TypeInfererLet.java index 0241f5b..8bed6f4 100644 --- a/src/main/java/edu/kit/typicalc/model/TypeInfererLet.java +++ b/src/main/java/edu/kit/typicalc/model/TypeInfererLet.java @@ -33,10 +33,18 @@ public class TypeInfererLet extends TypeInferer { * C := { αi = σ(αi) | σ defined for αi } * * @return the constraints needed in the outer inference + * @throws IllegalStateException if the method is called despite missing mgu */ public List getLetConstraints() { - return new ArrayList<>(); - // TODO + if (this.getMGU().isEmpty()) { + throw new IllegalStateException("getLetConstraints() should never be called when no mgu was found"); + } + List letConstraints = new ArrayList<>(); + for (Substitution substitution : this.getMGU().get()) { + Constraint constraint = new Constraint(substitution.getVariable(), substitution.getType()); + letConstraints.add(constraint); + } + return letConstraints; } }