Filter a <. b constraints at end of Unify. Create T <. Object constraints in TYPEMethod for ret and param types

This commit is contained in:
Andreas Stadelmeier 2022-03-10 22:49:01 +01:00
parent 16dbfbc957
commit 607405920d
2 changed files with 9 additions and 4 deletions

View File

@ -52,7 +52,8 @@ object TYPE {
private def TYPEMethod(method: Method, thisType: RefType, ast: List[Class]) = {
val (rty, cons) = TYPEExpr(method.retExpr, List((thisType, "this")) ++ method.params, ast)
LessDot(rty, method.retType) :: cons
LessDot(rty, method.retType) :: LessDot(method.retType, RefType("Object", List())) ::
cons ++ method.params.map(_._1).map(LessDot(_, RefType("Object", List())))
}
private def TYPEExpr(expr: Expr, localVars: List[(Type, String)], ast: List[Class]) : (Type, List[Constraint]) =expr match {

View File

@ -37,16 +37,20 @@ object Unify {
def removeALessdotB(eq: Set[UnifyConstraint]): Set[UnifyConstraint] = {
var ret = eq
val alessdotb = eq.filter(_ match{
val alessdotb:Set[UnifyConstraint] = eq.filter(_ match{
case UnifyLessDot(UnifyTV(a), UnifyTV(b)) => true
case _ => false
})
ret = ret.filter(it => !alessdotb.contains(it))
alessdotb.foreach(it => ret = subst(it.left.asInstanceOf[UnifyTV], it.right, ret))
ret.filter(_ match{
/*
.filter(_ match{
case UnifyEqualsDot(UnifyTV(a), UnifyTV(b)) => a != b
case UnifyLessDot(UnifyTV(_), UnifyTV(_)) => false
case _ => true
}) ++ alessdotb.map(_ match {case UnifyLessDot(a, b) => UnifyEqualsDot(a,b)})
})
*/
ret ++ alessdotb.map(_ match {case UnifyLessDot(a, b) => UnifyEqualsDot(a,b)})
}
def unifyIterative(orCons: Set[Set[Set[UnifyConstraint]]], fc: FiniteClosure) : Set[Set[UnifyConstraint]] = {