Typen werden vor dem Unifizieren nochmals kontrolliert

This commit is contained in:
JanUlrich 2014-04-28 08:26:11 +02:00
parent 1a655943ed
commit 6a98115361
3 changed files with 25 additions and 1 deletions

View File

@ -728,6 +728,27 @@ public class SourceFile
*/
//Erst die Unifizierung erstellen:
Vector<Pair> constraintsClone = (Vector<Pair>)constraints.clone();
//Typen kontrollieren:
for(Pair p : constraintsClone){
Type t = p.TA1;
//TypeCheck, falls es sich um einen RefType handelt:
if(t!=null && (t instanceof RefType)&&
!(t instanceof mycompiler.mytype.Void)){
Type replaceType = null;
replaceType = globalAssumptions.getTypeFor((RefType)t);
if(!(replaceType == null))p.TA1 = replaceType;
}
t = p.TA2;
//TypeCheck, falls es sich um einen RefType handelt:
if(t!=null && (t instanceof RefType)&&
!(t instanceof mycompiler.mytype.Void)){
Type replaceType = null;
replaceType = globalAssumptions.getTypeFor((RefType)t);
if(!(replaceType == null))p.TA2 = replaceType;
}
}
Vector<Vector<Pair>> unifyResult = Unify.unify(constraintsClone, finiteClosure);
//Dann den Ergebnissen anfügen
result.addAll(unifyResult);

View File

@ -61,7 +61,9 @@ public class FormalParameter extends SyntaxTreeNode implements ITypeReplacementL
if(!(object instanceof FormalParameter))return false;
FormalParameter equals = (FormalParameter)object;
if((this.type==null)!=(equals.type == null))return false;
if(this.type != null)return this.type.equals(equals.type);
if(this.type != null){
return this.type.equals(equals.type);
}
return true;
}

View File

@ -132,6 +132,7 @@ public class TypeAssumptions {
Vector<MethodAssumption> ret = new Vector<MethodAssumption>();
for(MethodAssumption ass : this.methodAssumptions){
if(ass.getMethodName().equals(methodName) && ass.getParaCount() == parameterCount){
ret.add(ass);
}
}