new file: ../../AllgemeinTest/Assign.jav

modified:   ../../AllgemeinTest/Pair.jav
	modified:   ../../AllgemeinTest/UseWildcardPair.jav
	modified:   ../../../src/main/java/de/dhbwstuttgart/parser/SyntaxTreeGenerator/TypeGenerator.java
? extends Object nochmals angepasst

	modified:   ../../../src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java
	modified:   ../../../src/test/java/AllgemeinTest.java
This commit is contained in:
pl@gohorb.ba-horb.de 2023-03-07 16:34:34 +01:00
parent 1c31b6d769
commit 506fd0dc0e
6 changed files with 30 additions and 12 deletions

View File

@ -0,0 +1,10 @@
class Assign {
assign(x, y) {
x = y;
}
assign2(x, y) {
assign(x,y);
}
}

View File

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

View File

@ -6,7 +6,7 @@ class UseWildcardPair{
void m(Pair<?, ?> p, Vector<?> b) void m(Pair<?, ?> p, Vector<?> b)
{ {
p.compare(p); //1, type incorrect p.compare(p); //1, type incorrect
p.compare(p.make(b)); //2, OK p.compare(p.make(b)); //2, OK
} }
} }

View File

@ -170,7 +170,7 @@ public class TypeGenerator {
return new SuperWildcardType(convert(wildcardContext.wildcardBounds().referenceType(), reg, generics), wildcardContext.getStart()); return new SuperWildcardType(convert(wildcardContext.wildcardBounds().referenceType(), reg, generics), wildcardContext.getStart());
} }
}else{ }else{
return new ExtendsWildcardType(new RefType(new JavaClassName("java.lang.Object"), new NullToken()), wildcardContext.getStart()); return new ExtendsWildcardType(ASTFactory.createObjectType(), wildcardContext.getStart());
} }
} }

View File

@ -171,7 +171,8 @@ public class TYPEStmt implements StatementVisitor{
methodCall.receiver.accept(this); methodCall.receiver.accept(this);
//Overloading: //Overloading:
Set<Constraint<Pair>> methodConstraints = new HashSet<>(); Set<Constraint<Pair>> methodConstraints = new HashSet<>();
for(MethodAssumption m : this.getMethods(methodCall.name, methodCall.arglist, info)){ for(MethodAssumption m :
this.getMethods(methodCall.name, methodCall.arglist, info)){
GenericsResolver resolver = getResolverInstance(); GenericsResolver resolver = getResolverInstance();
Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(methodCall, m, info, resolver); Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(methodCall, m, info, resolver);
methodConstraints.addAll(oneMethodConstraints); methodConstraints.addAll(oneMethodConstraints);

View File

@ -52,8 +52,9 @@ public class AllgemeinTest {
//String className = "VectorNotObject"; //String className = "VectorNotObject";
//String className = "WildcardCaptureConversionTest"; //String className = "WildcardCaptureConversionTest";
//String className = "CaptureConversion"; //String className = "CaptureConversion";
String className = "Pair"; //String className = "Pair";
//String className = "UseWildcardPair"; //String className = "UseWildcardPair";
String className = "Assign";
//PL 2019-10-24: genutzt fuer unterschiedliche Tests //PL 2019-10-24: genutzt fuer unterschiedliche Tests
path = System.getProperty("user.dir")+"/resources/AllgemeinTest/" + className + ".jav"; path = System.getProperty("user.dir")+"/resources/AllgemeinTest/" + className + ".jav";
//path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav"; //path = System.getProperty("user.dir")+"/src/test/resources/AllgemeinTest/Overloading_Generics.jav";