Fix Tph4-6

This commit is contained in:
Victorious3 2022-08-09 12:59:23 +02:00
parent 2af59d1e1f
commit edf85dca7f
2 changed files with 20 additions and 1 deletions

View File

@ -1,5 +1,6 @@
package de.dhbwstuttgart.target.generate;
import com.google.j2objc.annotations.LoopTranslation;
import de.dhbwstuttgart.bytecode.funN.FunNGenerator;
import de.dhbwstuttgart.core.JavaTXCompiler;
import de.dhbwstuttgart.parser.NullToken;
@ -145,7 +146,7 @@ public class ASTToTargetAST {
findTypeVariables(field.getType(), typeVariablesOfFields);
}
findTypeVariables(method.getReturnType(), typeVariables);
//findTypeVariables(method.getReturnType(), typeVariables);
for (var arg : method.getParameterList().getFormalparalist()) {
findTypeVariables(arg.getType(), typeVariables);
}
@ -155,6 +156,15 @@ public class ASTToTargetAST {
public void visit(LocalVarDecl localVarDecl) {
findTypeVariables(localVarDecl.getType(), typeVariables);
}
@Override
public void visit(MethodCall methodCall) {
super.visit(methodCall);
findTypeVariables(methodCall.getType(), typeVariables);
}
@Override
public void visit(Assign assign) {}
});
// Type variables with bounds that are also type variables of the method
@ -221,6 +231,7 @@ public class ASTToTargetAST {
for (var pair2 : simplifiedConstraints) {
if (!(pair2.right.equals(tph2) && pair2.left.equals(type)))
continue;
if (tph.equals(tph2)) continue;
var newPair = new PairTPHsmallerTPH(tph, tph2);
newPairs.add(newPair);
@ -572,6 +583,8 @@ public class ASTToTargetAST {
for (var i = 0; i < pars.size(); i++) {
var type1 = convert(pars.get(i).getType());
var type2 = convert(arguments.get(i).getType());
if (type2 instanceof TargetGenericType && type1 instanceof TargetGenericType)
return true;
if (!type1.equals(type2)) return false;
}

View File

@ -349,6 +349,12 @@ public class TestComplete {
var instance = classFiles.get("Tph3").getDeclaredConstructor().newInstance();
}
@Test
public void tph4Test() throws Exception {
var classFiles = generateClassFiles("Tph4.jav", new ByteArrayClassLoader());
var instance = classFiles.get("Tph4").getDeclaredConstructor().newInstance();
}
@Test
public void tph5Test() throws Exception {
var classFiles = generateClassFiles("Tph5.jav", new ByteArrayClassLoader());