mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-27 08:18:03 +00:00
Update TypedMethod and TypedReturn and ClassCanBeTyped
This commit is contained in:
parent
8b5ec63e4b
commit
6b89cd0958
@ -67,7 +67,7 @@ public class TypedMethod implements TypedNode {
|
||||
@Override
|
||||
public Type typeCheck(TypedClass clas) {
|
||||
if(returnType != Type.VOID){
|
||||
if(typedBlock.typeCheck(clas) != returnType){
|
||||
if(typedBlock.typeCheck(clas).getKind() != returnType.getKind()){
|
||||
throw new RuntimeException("Method " + name + " must return " + returnType);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,11 @@ public class TypedReturn implements TypedStatement {
|
||||
|
||||
public void convertToTypedReturn(TypedClass clas, Return unTypedReturn) {
|
||||
ret = convertExpression(clas, unTypedReturn.ret());
|
||||
type = ret.getType();
|
||||
if(ret == null){
|
||||
type = Type.VOID;
|
||||
}else{
|
||||
type = ret.getType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -3,6 +3,7 @@ public class ClassCanBeTyped {
|
||||
int x;
|
||||
int y;
|
||||
ClassCanBeTyped b;
|
||||
ClassCanBeTyped c;
|
||||
public ClassCanBeTyped(int x) {
|
||||
this.x = x;
|
||||
}
|
||||
@ -16,6 +17,8 @@ public class ClassCanBeTyped {
|
||||
b = new ClassCanBeTyped(x);
|
||||
b.x = 10 + a;
|
||||
b.y = 20;
|
||||
b.c.x = 20 + a;
|
||||
b.c.b.y = b.x;
|
||||
|
||||
return b;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user