This commit is contained in:
Andreas Stadelmeier 2024-04-10 01:14:59 +02:00
parent 931b65fa14
commit a000b0b13b

View File

@ -1,6 +1,6 @@
package unify.algorithm
import unify.model.{BotType, ConstraintSet, EqualsDot, ExtendsRelations, LessDot, RefType, TypeVariable, UnifySolution, Wildcard, WildcardBound, WildcardEnvironment, emptyWCs}
import unify.model.{BotType, ConstraintSet, EqualsDot, ExtendsRelations, LessDot, RefType, TypeVariable, UnifySolution, WTypeVariable, Wildcard, WildcardBound, WildcardEnvironment, emptyWCs}
import java.util.concurrent.{CompletableFuture, ExecutorService, Future}
import scala.collection.mutable
@ -46,7 +46,7 @@ class Unify {
case LessDot(RefType(w, n, p), TypeVariable(a), _) => true
case _ => false
}).map(cons => cons match {
case LessDot(RefType(w, n, p), TypeVariable(a), _) => {
case LessDot(RefType(w, n, p), TypeVariable(a), _) =>
//Same rule
//TODO
@ -74,28 +74,29 @@ class Unify {
cs4.add(LessDot(newSuperType, cons.right))
ret.add(cs4)
}
}
case _ => {}
})
cs.getALessDotCCons.map(cons => cons match {
case LessDot(TypeVariable(a), RefType(wc, n, ps), _) => {
cs.getALessDotBCons.find(c => c.left.equals(TypeVariable(a))).map(_.right).map(b => {
//Lower rule:
val csLower: ConstraintSet = cs.copy()
csLower.remove(LessDot(TypeVariable(a), RefType(wc, n, ps)))
csLower.add(LessDot(b, RefType(wc, n, ps)))
ret.add(csLower)
//Raise rule:
val csRaise: ConstraintSet = cs.copy()
csRaise.remove(LessDot(TypeVariable(a), b))
csRaise.add(LessDot(RefType(wc, n, ps), b))
ret.add(csRaise)
})
case LessDot(RefType(w, n, p), WTypeVariable(a), _) => {
//TODO: SameW
}
case _ => {}
})
cs.getALessDotCCons.map(cons => cons match {
case LessDot(TypeVariable(a), RefType(wc, n, ps), _) => {
cs.getALessDotBCons.find(c => c.left.equals(TypeVariable(a))).map(_.right).map(b => {
//Lower rule:
val csLower: ConstraintSet = cs.copy()
csLower.remove(LessDot(TypeVariable(a), RefType(wc, n, ps)))
csLower.add(LessDot(b, RefType(wc, n, ps)))
ret.add(csLower)
//Raise rule:
val csRaise: ConstraintSet = cs.copy()
csRaise.remove(LessDot(TypeVariable(a), b))
csRaise.add(LessDot(RefType(wc, n, ps), b))
ret.add(csRaise)
})
}
case _ => {}
})
/*
cs.getALessDotCCons().filter(cons => !cs.fv(cons.right).isEmpty).map(cons => {
//Force