mirror of
https://github.com/JonathanFleischmann/CompilerULTIMATE.git
synced 2024-12-28 01:38:03 +00:00
update the typeCheck of TypedReturn
This commit is contained in:
parent
e49691ff29
commit
31d57c8ba9
@ -28,18 +28,14 @@ public class TypedReturn implements TypedStatement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
|
public Type typeCheck(Map<String, Type> localVar, TypedClass clas) {
|
||||||
//TODO: not localvar
|
if(clas.isCurrentMethodPresent()){
|
||||||
for(var typedMethod : clas.getTypedMethods()) {
|
if(clas.getCurrentMethod().getReturnType().getKind() != this.type.getKind()){
|
||||||
if(localVar.containsKey(typedMethod.getName())) {
|
StringBuilder exp = new StringBuilder();
|
||||||
if(typedMethod.getReturnType().getKind() != this.type.getKind()) {
|
exp.append("\nMismatched return type: ");
|
||||||
//TODO: exception auslagern
|
exp.append("\nExpected: ").append(clas.getCurrentMethod().getReturnType().getKind());
|
||||||
StringBuilder exp = new StringBuilder();
|
exp.append("\nActual: ").append(this.type.getKind());
|
||||||
exp.append("\nMismatched return type: ");
|
exp.append("\nMethod name: ").append(clas.getCurrentMethod().getName());
|
||||||
exp.append("\nExpected: ").append(typedMethod.getReturnType().getKind());
|
throw new RuntimeException(exp.toString());
|
||||||
exp.append("\nActual: ").append(this.type.getKind());
|
|
||||||
exp.append("\nMethod name: ").append(typedMethod.getName());
|
|
||||||
throw new RuntimeException(exp.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
|
Loading…
Reference in New Issue
Block a user