diff --git a/src/mycompiler/myclass/Constructor.java b/src/mycompiler/myclass/Constructor.java index b019affb0..767a683f0 100644 --- a/src/mycompiler/myclass/Constructor.java +++ b/src/mycompiler/myclass/Constructor.java @@ -14,6 +14,7 @@ import mycompiler.mytypereconstruction.replacementlistener.CReplaceTypeEvent; import typinferenz.ConstraintsSet; import typinferenz.JavaCodeResult; import typinferenz.ResultSet; +import typinferenz.SingleConstraint; import typinferenz.assumptions.TypeAssumptions; public class Constructor extends Method { @@ -222,10 +223,11 @@ public class Constructor extends Method { this.methode.set_Method_Name(string); } - @Override public ConstraintsSet TYPE(TypeAssumptions ass) { - - return this.methode.TYPE(ass); + ConstraintsSet ret = new ConstraintsSet(); + + ret.add(this.methode.get_Block().TYPEStmt(ass)); + return ret; } @Override diff --git a/src/mycompiler/myclass/Method.java b/src/mycompiler/myclass/Method.java index 38035d345..f2465cc48 100755 --- a/src/mycompiler/myclass/Method.java +++ b/src/mycompiler/myclass/Method.java @@ -203,9 +203,6 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith ((TypePlaceholder)type).addReplacementListener(this); } // this.returntype = type; //auskommentiert von Andreas Stadelmeier (a10023) - //Der ReturnType der Methode ist der Returntype des Methodenblocks: - if(block!=null) - this.block.setType(type); this.returntype = type; } // ino.end @@ -314,8 +311,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith // ino.end // ino.method.getReturnType.23569.body { - return this.block.getType(); - //return this.returntype; //auskommentiert von Andreas Stadelmeier (a10023) + return this.returntype; //auskommentiert von Andreas Stadelmeier (a10023) } // ino.end @@ -688,7 +684,7 @@ public class Method extends Field implements ITypeReplacementListener, IItemWith @Override public Type getType(){ //Methode und Block teilen sich einen ReturnType: - return this.block.getType(); + return this.returntype; } public static Method createEmptyMethod(String withSignature, Class parent){ diff --git a/src/typinferenz/assumptions/LocalVarAssumption.java b/src/typinferenz/assumptions/LocalVarAssumption.java index 94340d546..bde1c70a1 100644 --- a/src/typinferenz/assumptions/LocalVarAssumption.java +++ b/src/typinferenz/assumptions/LocalVarAssumption.java @@ -1,9 +1,19 @@ package typinferenz.assumptions; +import mycompiler.mytype.Type; + import mycompiler.mystatement.LocalVarDecl; public class LocalVarAssumption extends Assumption { + private LocalVarDecl localVar; + public LocalVarAssumption(LocalVarDecl localVar){ super(localVar); + this.localVar = localVar; + } + + @Override + public Type getAssumedType() { + return this.localVar.getDeclType(); } } diff --git a/test/mycompiler/test/lambda/testResults/LambdaTest.log b/test/mycompiler/test/lambda/testResults/LambdaTest.log index 47cc141d6..f4fd14841 100644 --- a/test/mycompiler/test/lambda/testResults/LambdaTest.log +++ b/test/mycompiler/test/lambda/testResults/LambdaTest.log @@ -1,5 +1,5 @@ Class DEBUG [Typeinference] Erstellte Assumptions: this: WhileTestMethod Assumptions: -[typinferenz.assumptions.MethodAssumption@757828eb, typinferenz.assumptions.MethodAssumption@23c6988d] +[typinferenz.assumptions.MethodAssumption@33e8c1e4, typinferenz.assumptions.MethodAssumption@76117a5b] FieldVar Assumptions: [] LocalVar Assumptions: @@ -8,19 +8,34 @@ Parameter Assumptions: [] Block DEBUG [Typeinference] Prozessing statement: no type [var] -Block DEBUG [Typeinference] Prozessing statement: WHILE null { [(var = mycompiler.mystatement.StringLiteral@7bec09b0)] -Block DEBUG [Typeinference] Prozessing statement: (var = mycompiler.mystatement.StringLiteral@7bec09b0) -Block DEBUG [Typeinference] Prozessing statement: void(var: void = mycompiler.mystatement.StringLiteral@7bec09b0) -Block DEBUG [Typeinference] Prozessing statement: WHILE void { [void(var: void = mycompiler.mystatement.StringLiteral@7bec09b0)] +Block DEBUG [Typeinference] Prozessing statement: WHILE null { [(var = mycompiler.mystatement.StringLiteral@25cc8345)] +Block DEBUG [Typeinference] Prozessing statement: (var = mycompiler.mystatement.StringLiteral@25cc8345) +Block DEBUG [Typeinference] Prozessing statement: void(var: TPH C = mycompiler.mystatement.StringLiteral@25cc8345) +Block DEBUG [Typeinference] Prozessing statement: WHILE void { [void(var: TPH C = mycompiler.mystatement.StringLiteral@25cc8345)] Block DEBUG [Typeinference] Prozessing statement: TPH C [var] Class DEBUG [Typeinference] Erstellte Constraints: boolean < boolean -String < void -void < TPH D +String < TPH C +TPH C < TPH D void < TPH A -void < TPH B -SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(boolean <. boolean), (String <. void), (void <. TPH D), (void <. TPH A), (void <. TPH B)]] -SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [] +SourceFile DEBUG [Typeinference] Karthesisches Produkt der Constraints: [[(boolean <. boolean), (String <. TPH C), (TPH C <. TPH D), (void <. TPH A)]] +SourceFile DEBUG [Typeinference] Unifiziertes Ergebnis: [[(TPH D = String), (TPH C = String), (TPH A = void)]] SourceFile DEBUG [Typeinference] JavaFiles: +SourceFile DEBUG [Typeinference] JavaFile für ResultSet Unified Constraints: [(TPH D = String), (TPH C = String), (TPH A = void)] + +SourceFile DEBUG [Typeinference] class WhileTest extends Object +{ +void method() +{ +String var; +while(true){ +var = "String"; +} +} +B WhileTest() +{ +} +} +