package TypeCheck; import java.util.List; import java.util.Objects; public class TypeCheckHelper { public String upperBound(String type1, String type2) throws Exception{ boolean type1Primitiv = Objects.equals(type1, "bool") || Objects.equals(type1, "int") || Objects.equals(type1, "char"); boolean type2Primitiv = Objects.equals(type2, "bool") || Objects.equals(type2, "int") || Objects.equals(type2, "char"); String result; if(type1Primitiv && type2Primitiv){ if(Objects.equals(type1, type2)){ result = type1; } throw new Exception("no upper bound"); }else if(type1Primitiv || type2Primitiv){ throw new Exception("no upper bound"); }else{ result = "class"; } return result; } public static boolean typeExists(String type, List typeslist) { if(type.equals("int") || type.equals("bool") || type.equals("char")){ return true; } return typeslist.contains(type); } }