Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/abstractSyntaxTree/Program.java
This commit is contained in:
Jochen Seyfried 2024-06-28 18:44:47 +02:00
commit 34f4f307f3

View File

@ -43,9 +43,12 @@ public class MethodDecl implements Node {
TypeCheckResult result = new TypeCheckResult();
codeBlock.thisClass = classThatContainsMethod;
String CodeBlockType = codeBlock.typeCheck(methodContext, typeContext, localVars).type;
if(!Objects.equals(this.returnType, CodeBlockType))
throw new TypeCheckException("Method returns " + CodeBlockType + ", but should return " + this.returnType + ". ");
String codeBlockType = codeBlock.typeCheck(methodContext, typeContext, localVars).type;
if(Objects.equals(this.name, classThatContainsMethod))
codeBlockType = null;
if(!Objects.equals(this.returnType, codeBlockType))
throw new TypeCheckException("Method returns " + codeBlockType + ", but should return " + this.returnType + ". ");
result.type = codeBlock.returnType;
return result;
}