Merge branch 'targetBytecode' of gohorb.ba-horb.de:/bahome/projekt/git/JavaCompilerCore into targetBytecode

This commit is contained in:
pl@gohorb.ba-horb.de 2023-03-08 16:02:50 +01:00
commit 034faf1f66
3 changed files with 40 additions and 2 deletions

View File

@ -0,0 +1,32 @@
import java.util.Vector;
import java.lang.Boolean;
import java.lang.Object;
class Pair<U, T> {
U a;
T b;
make(x) {
var ret = new Pair<>();
ret.a = x.elementAt(0);
ret.b = x.elementAt(1);
return ret;
}
/*
eq(a, b) {
b = a;
return a == b;
}
compare( p) {
return eq(p.a, p.b);
//return p.a == p.b;
}
void m(Pair<?, ?> p, List<? extends Eq> b)
{
//this.compare(p); //1, type incorrect
this.compare(this.make(b)); //2, OK
}
*/
}

View File

@ -445,7 +445,6 @@ public class ASTToTargetAST {
addToPairs(result, minimalPair);
}
// All unbounded type variables (bounds not in method)
outer:
for (var typeVariable : typeVariables) {
@ -482,7 +481,8 @@ public class ASTToTargetAST {
typeVariablesOfClass.add((TypePlaceholder) pair.getLeft());
}
typeVariables.addAll(findTypeVariables(method.getReturnType(), equality));
if (!(method instanceof Constructor))
typeVariables.addAll(findTypeVariables(method.getReturnType(), equality));
for (var arg : method.getParameterList().getFormalparalist()) {
typeVariables.addAll(findTypeVariables(arg.getType(), equality));
}

View File

@ -598,4 +598,10 @@ public class TestComplete {
var classFiles = generateClassFiles("OLFun2.jav", new ByteArrayClassLoader());
var instance = classFiles.get("OLFun2").getDeclaredConstructor().newInstance();
}
@Test
public void pairTest() throws Exception {
var classFiles = generateClassFiles("Pair.jav", new ByteArrayClassLoader());
var instance = classFiles.get("Pair").getDeclaredConstructor().newInstance();
}
}