fix method overlaoding semantic check
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
Bruder John 2024-06-27 15:17:05 +02:00
parent a34c7ded50
commit 4d21d8e94e
4 changed files with 46 additions and 5 deletions

View File

@ -214,9 +214,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
@Override
public TypeCheckResult analyze(ParameterNode toCheck) {
return new TypeCheckResult(true, null);
return new TypeCheckResult(true, toCheck.type);
}
@Override
@ -517,7 +515,7 @@ public class SemanticAnalyzer implements SemanticVisitor {
for(int i = 0; i < method.getParameters().size(); i++){
var result1 = method.getParameters().get(i).accept(this);
var result2 = toCheck.parameters.get(i).accept(this);
if (Objects.equals(result1.getType(), result2.getType())) {
if (!Objects.equals(result1.getType(), result2.getType())) {
same = false;
}
}

View File

@ -0,0 +1,22 @@
// @expected: TypeMismatchException
public class Test{
public int i;
public boolean b;
public int test(){
return this.test(i);
}
public void test(int a){
}
public int test(boolean bool){
int ret = 1;
return ret;
}
}

View File

@ -5,7 +5,7 @@ public class Test{
public int test(){
return i;
return this.test(b);
}

View File

@ -0,0 +1,21 @@
public class Test{
public int i;
public boolean b;
public int test(){
return this.test(b);
}
public void test(int a){
}
public int test(boolean bool){
int ret = 1;
return ret;
}
}