add swap
This commit is contained in:
parent
66a3ca7b91
commit
0181ab942a
@ -7,6 +7,9 @@ import unify.model.*
|
||||
class Rules(cs: ConstraintSet, wildcardEnvironment: WildcardEnvironment, fc: ExtendsRelations):
|
||||
def applyRules(tvFactory: TypeVariableFactory, fc: ExtendsRelations): Unit = {
|
||||
cs.getEqualsDotCons.foreach(cons => { //Hint: cannot be executed in parallel!
|
||||
cons match { //TODO:
|
||||
case EqualsDot(t: Type, WTypeVariable(a)) => {}
|
||||
}
|
||||
if (cons.left.equals(cons.right)) { //erase rule
|
||||
cs.remove(cons)
|
||||
} else if(cons.left.isInstanceOf[TypeVariable] && cons.right.wtvs().isEmpty){ //Subst rule
|
||||
@ -23,10 +26,9 @@ class Rules(cs: ConstraintSet, wildcardEnvironment: WildcardEnvironment, fc: Ext
|
||||
} else if(cons.left.isInstanceOf[WTypeVariable]){ // Subst-WC rule
|
||||
cs.remove(cons)
|
||||
cs.substitute(cons.right, cons.left)
|
||||
}
|
||||
else if (cons.left.isInstanceOf[Wildcard] && !cons.right.isInstanceOf[WTypeVariable]) { //Tame rule:
|
||||
} else if (cons.left.isInstanceOf[Wildcard] && !cons.right.isInstanceOf[WTypeVariable]) { //Tame rule:
|
||||
tameRule(cons, cs)
|
||||
}else if(cons.left.isInstanceOf[RefType] && cons.right.isInstanceOf[RefType]){
|
||||
}else if(cons.left.isInstanceOf[RefType] && cons.right.isInstanceOf[RefType]){ //equals rule
|
||||
val left = cons.left.asInstanceOf[RefType]
|
||||
val right = cons.right.asInstanceOf[RefType]
|
||||
if(left.params.size == right.params.size && left.name == right.name){
|
||||
@ -37,6 +39,15 @@ class Rules(cs: ConstraintSet, wildcardEnvironment: WildcardEnvironment, fc: Ext
|
||||
}else{
|
||||
//TODO: insolvable constraint set!
|
||||
}
|
||||
} else if(cons.right.isInstanceOf[Wildcard]) { //swap
|
||||
cs.remove(cons)
|
||||
cs.add(EqualsDot(cons.right, cons.left))
|
||||
} else if(cons.right.isInstanceOf[WTypeVariable]) { //swap
|
||||
cs.remove(cons)
|
||||
cs.add(EqualsDot(cons.right, cons.left))
|
||||
} else if(cons.right.isInstanceOf[TypeVariable]) {
|
||||
cs.remove(cons)
|
||||
cs.add(EqualsDot(cons.right, cons.left))
|
||||
}
|
||||
/*
|
||||
else if (cons.left.isInstanceOf[RefType] && cons.right.isInstanceOf[Wildcard]) {
|
||||
|
Loading…
Reference in New Issue
Block a user