modified: ../../../main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java
This commit is contained in:
parent
dabe7f269c
commit
0c9612a2ea
@ -207,9 +207,10 @@ public class TYPEStmt implements StatementVisitor{
|
||||
Set<Constraint<Pair>> methodConstraints = new HashSet<>();
|
||||
for(MethodAssumption m : this.getMethods(methodCall.name, methodCall.arglist, info)){
|
||||
GenericsResolver resolver = getResolverInstance();
|
||||
Constraint<Pair> oneMethodConstraint = generateConstraint(methodCall, m, info, resolver);
|
||||
methodConstraints.add(oneMethodConstraint);
|
||||
Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(methodCall, m, info, resolver);
|
||||
methodConstraints.addAll(oneMethodConstraints);
|
||||
|
||||
/* pl 2023-01-20: in generateConstraint bereits umgesetzt
|
||||
Constraint<Pair> extendsOneMethodConstraint = oneMethodConstraint.stream()
|
||||
.map(x -> (x.TA1 instanceof TypePlaceholder &&
|
||||
x.GetOperator() == PairOperator.EQUALSDOT &&
|
||||
@ -220,6 +221,7 @@ public class TYPEStmt implements StatementVisitor{
|
||||
oneMethodConstraint.setExtendConstraint(extendsOneMethodConstraint);
|
||||
extendsOneMethodConstraint.setExtendConstraint(oneMethodConstraint);
|
||||
methodConstraints.add(extendsOneMethodConstraint);
|
||||
*/
|
||||
}
|
||||
if(methodConstraints.size()<1){
|
||||
throw new TypeinferenceException("Methode "+methodCall.name+" ist nicht vorhanden!",methodCall.getOffset());
|
||||
@ -616,9 +618,12 @@ public class TYPEStmt implements StatementVisitor{
|
||||
METHOD CALL Section:
|
||||
*/
|
||||
|
||||
protected Constraint<Pair> generateConstraint(MethodCall forMethod, MethodAssumption assumption,
|
||||
protected Set<Constraint<Pair>> generateConstraint(MethodCall forMethod, MethodAssumption assumption,
|
||||
TypeInferenceBlockInformation info, GenericsResolver resolver){
|
||||
Constraint<Pair> methodConstraint = new Constraint<>(assumption.isInherited());
|
||||
Constraint<Pair> methodConstraint, extendsMethodConstraint;
|
||||
methodConstraint = new Constraint<>(assumption.isInherited());
|
||||
extendsMethodConstraint = new Constraint<>(assumption.isInherited());// PL 2023-01-24: Ersetzt die Dopplung in visit(MethodCall)
|
||||
|
||||
ClassOrInterface receiverCl = assumption.getReceiver();
|
||||
/*
|
||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
||||
@ -630,20 +635,30 @@ public class TYPEStmt implements StatementVisitor{
|
||||
RefTypeOrTPHOrWildcardOrGeneric receiverType = new RefType(assumption.getReceiver().getClassName(), params, forMethod.getOffset());
|
||||
*/
|
||||
|
||||
RefTypeOrTPHOrWildcardOrGeneric retType = assumption.getReceiverType(resolver);
|
||||
methodConstraint.add(new Pair(forMethod.receiver.getType(), retType,
|
||||
PairOperator.EQUALSDOT));//PL 2020-03-17 SMALLERDOT in EQUALSDOT umgewandelt, weil alle geerbten Methoden in den jeweilen Klassen enthalten sind.
|
||||
|
||||
RefTypeOrTPHOrWildcardOrGeneric receiverType = assumption.getReceiverType(resolver);
|
||||
methodConstraint.add(new Pair(forMethod.receiver.getType(), receiverType, PairOperator.EQUALSDOT));//PL 2020-03-17 SMALLERDOT in EQUALSDOT umgewandelt, weil alle geerbten Methoden in den jeweilen Klassen enthalten sind.
|
||||
|
||||
//PL 2023-01-24: dafuer ? extends receiverType noch ergaenzt
|
||||
extendsMethodConstraint.add(new Pair(forMethod.receiver.getType(), new ExtendsWildcardType(receiverType, receiverType.getOffset()), PairOperator.EQUALSDOT));
|
||||
|
||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ANFANG
|
||||
//methodConstraint.add(new Pair(forMethod.receiverType, retType,
|
||||
// PairOperator.EQUALSDOT));
|
||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
||||
|
||||
|
||||
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
|
||||
PairOperator.EQUALSDOT));
|
||||
methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver));
|
||||
return methodConstraint;
|
||||
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT));
|
||||
extendsMethodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT));
|
||||
|
||||
Set<Pair> parameterContraints = generateParameterConstraints(forMethod, assumption, info, resolver);
|
||||
|
||||
methodConstraint.addAll(parameterContraints);
|
||||
extendsMethodConstraint.addAll(parameterContraints);
|
||||
|
||||
Set<Constraint<Pair>> ret = new HashSet<>();
|
||||
ret.add(methodConstraint);
|
||||
ret.add(extendsMethodConstraint);
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected Set<Pair> generateParameterConstraints(MethodCall foMethod, MethodAssumption assumption,
|
||||
|
Loading…
Reference in New Issue
Block a user