forked from JavaTX/JavaCompilerCore
Problem mit LocalVarDecl und setType behoben
This commit is contained in:
parent
eed860f43e
commit
25195440f0
@ -222,7 +222,6 @@ public class Constructor extends Method {
|
||||
|
||||
public ConstraintsSet TYPE(TypeAssumptions ass) {
|
||||
ConstraintsSet ret = new ConstraintsSet();
|
||||
|
||||
ret.add(this.methode.get_Block().TYPEStmt(ass));
|
||||
return ret;
|
||||
}
|
||||
|
@ -233,8 +233,8 @@ public class Block extends Statement
|
||||
for(int i= statements.size()-2; i >= 0; i--) {
|
||||
stmt = statements.elementAt(i);
|
||||
typinferenceLog.debug("Prozessing statement: "+stmt);
|
||||
if (!(stmt.getType() instanceof Void))
|
||||
if (this.getType() instanceof Void) {
|
||||
if (!(stmt.getReturnType() instanceof Void))
|
||||
if (this.getReturnType() instanceof Void) {
|
||||
//this.setTypeVariable(stmt.getTypeVariable());
|
||||
throw new TypeinferenceException("Block besitzt falschen Rückgabetyp (fehlendes return-stmt)", this);
|
||||
}
|
||||
|
@ -42,10 +42,12 @@ import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
|
||||
|
||||
import typinferenz.ConstraintsSet;
|
||||
import typinferenz.FreshTypeVariable;
|
||||
import typinferenz.JavaCodeResult;
|
||||
import typinferenz.ResultSet;
|
||||
import typinferenz.SingleConstraint;
|
||||
import typinferenz.TypeInsertable;
|
||||
import typinferenz.assumptions.LocalVarAssumption;
|
||||
import typinferenz.assumptions.TypeAssumptions;
|
||||
@ -474,8 +476,9 @@ public class LocalVarDecl extends Statement implements TypeInsertable
|
||||
this.setType(replaceType);
|
||||
}
|
||||
assumptions.addAssumption(new LocalVarAssumption(this, this.getType())); //Bevor der Typ auf Void gesetzt wird.
|
||||
ret.add(new SingleConstraint(this.getType(), this.getType()));
|
||||
//assumptions.remove(null); // falls Variable mit diesem Namen bereits vorhanden.
|
||||
this.setType(new Void(0)); //Return typ einer Variablendeklaration ist Void
|
||||
this.setReturnType(new Void(0)); //Return typ einer Variablendeklaration ist Void
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -152,5 +152,14 @@ public class Return extends Statement
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReturnType(Type t){
|
||||
this.setType(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getReturnType(){
|
||||
return this.getType();
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -149,5 +149,11 @@ public abstract class Statement extends SyntaxTreeNode implements IItemWithOffse
|
||||
return this.printJavaCode(new ResultSet(new Vector<Pair>())).toString();
|
||||
}
|
||||
|
||||
public void setReturnType(Type t){
|
||||
}
|
||||
|
||||
public Type getReturnType(){
|
||||
return new mycompiler.mytype.Void(-1);
|
||||
}
|
||||
}
|
||||
// ino.end
|
||||
|
@ -1,11 +1,7 @@
|
||||
class Overload{
|
||||
class ConstructorTest1{
|
||||
|
||||
void method( x ){
|
||||
String varS;
|
||||
Integer varI;
|
||||
|
||||
x.apply(varI);
|
||||
x.apply(varS);
|
||||
ConstructorTest1(){
|
||||
var;
|
||||
var = 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user