A =. A substitute loop error fix. Cleanup
This commit is contained in:
parent
8b4bfa0f47
commit
d96364318d
@ -6,7 +6,7 @@ class CartesianProduct[A](private val setOfSets: List[List[A]]){
|
||||
private var max: Long = 1
|
||||
private var i: Long = 0
|
||||
|
||||
def this(setOfSets: Set[Set[A]]){
|
||||
def this(setOfSets: Set[Set[A]]) {
|
||||
this(setOfSets.map(_.toList).toList)
|
||||
var base: Long = 1
|
||||
sizes = this.setOfSets.map(_.size)
|
||||
@ -15,16 +15,6 @@ class CartesianProduct[A](private val setOfSets: List[List[A]]){
|
||||
base = base * size
|
||||
})
|
||||
max = base
|
||||
/*
|
||||
sizes = constraints.stream().map(OderConstraint::getSize).collect(Collectors.toList());
|
||||
long base = 1;
|
||||
for(int size : sizes){
|
||||
bases.add(base);
|
||||
base *= size;
|
||||
}
|
||||
i = 0;
|
||||
max = estimateSize() - 1;
|
||||
*/
|
||||
}
|
||||
|
||||
def hasNext() = i < max
|
||||
@ -38,14 +28,4 @@ class CartesianProduct[A](private val setOfSets: List[List[A]]){
|
||||
i = i + 1
|
||||
ret.toSet
|
||||
}
|
||||
/*
|
||||
private Set<Pair> get(long num){
|
||||
Set<Pair> ret = new HashSet<>();
|
||||
Iterator<Long> baseIt = bases.iterator();
|
||||
for(OderConstraint constraint : constraints){
|
||||
ret.addAll(constraint.get((int) ((num/baseIt.next())%constraint.getSize())));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ object Unify {
|
||||
while(iterator.hasNext && circle.isEmpty){
|
||||
val newAdd = iterator.next()
|
||||
if(newAdd.right.equals(graph.head.left)){
|
||||
circle = graph ++ List(newAdd)
|
||||
circle = graph :+ newAdd
|
||||
}else{
|
||||
circle = findCircle(graph ++ List(newAdd))
|
||||
}
|
||||
@ -194,7 +194,7 @@ object Unify {
|
||||
}).isDefined
|
||||
def substStep(eq: Set[UnifyConstraint]) = eq.find(c => c match {
|
||||
case UnifyEqualsDot(TypeVariable(a), RefType(n, p)) => !paramsContain(TypeVariable(a), RefType(n,p))
|
||||
case UnifyEqualsDot(TypeVariable(a), TypeVariable(b)) => true
|
||||
case UnifyEqualsDot(TypeVariable(a), TypeVariable(b)) => !a.equals(b)
|
||||
case _ => false
|
||||
}).map(c => (subst(c.left.asInstanceOf[TypeVariable], c.right, eq), Some(c))).getOrElse((eq, None))
|
||||
|
||||
|
@ -27,4 +27,14 @@ class IntegrationTest extends FunSuite {
|
||||
println(result.map(Main.prettyPrint(_)))
|
||||
}
|
||||
|
||||
test("IdentCallExample"){
|
||||
val result = FJTypeinference.typeinference("class Test extends Object{\n\n m(a,b){return this.m(a);\n}\nm(a){return a;}\n}")
|
||||
println(result.map(Main.prettyPrint(_)))
|
||||
}
|
||||
|
||||
test("IdentRecursive"){
|
||||
val result = FJTypeinference.typeinference("class Test extends Object{\n\nm(a){\nreturn this.m(a);\n}\n}")
|
||||
println(result.map(Main.prettyPrint(_)))
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user