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<>();
|
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();
|
||||||
Constraint<Pair> oneMethodConstraint = generateConstraint(methodCall, m, info, resolver);
|
Set<Constraint<Pair>> oneMethodConstraints = generateConstraint(methodCall, m, info, resolver);
|
||||||
methodConstraints.add(oneMethodConstraint);
|
methodConstraints.addAll(oneMethodConstraints);
|
||||||
|
|
||||||
|
/* pl 2023-01-20: in generateConstraint bereits umgesetzt
|
||||||
Constraint<Pair> extendsOneMethodConstraint = oneMethodConstraint.stream()
|
Constraint<Pair> extendsOneMethodConstraint = oneMethodConstraint.stream()
|
||||||
.map(x -> (x.TA1 instanceof TypePlaceholder &&
|
.map(x -> (x.TA1 instanceof TypePlaceholder &&
|
||||||
x.GetOperator() == PairOperator.EQUALSDOT &&
|
x.GetOperator() == PairOperator.EQUALSDOT &&
|
||||||
@ -220,6 +221,7 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
oneMethodConstraint.setExtendConstraint(extendsOneMethodConstraint);
|
oneMethodConstraint.setExtendConstraint(extendsOneMethodConstraint);
|
||||||
extendsOneMethodConstraint.setExtendConstraint(oneMethodConstraint);
|
extendsOneMethodConstraint.setExtendConstraint(oneMethodConstraint);
|
||||||
methodConstraints.add(extendsOneMethodConstraint);
|
methodConstraints.add(extendsOneMethodConstraint);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
if(methodConstraints.size()<1){
|
if(methodConstraints.size()<1){
|
||||||
throw new TypeinferenceException("Methode "+methodCall.name+" ist nicht vorhanden!",methodCall.getOffset());
|
throw new TypeinferenceException("Methode "+methodCall.name+" ist nicht vorhanden!",methodCall.getOffset());
|
||||||
@ -616,9 +618,12 @@ public class TYPEStmt implements StatementVisitor{
|
|||||||
METHOD CALL Section:
|
METHOD CALL Section:
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected Constraint<Pair> generateConstraint(MethodCall forMethod, MethodAssumption assumption,
|
protected Set<Constraint<Pair>> generateConstraint(MethodCall forMethod, MethodAssumption assumption,
|
||||||
TypeInferenceBlockInformation info, GenericsResolver resolver){
|
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();
|
ClassOrInterface receiverCl = assumption.getReceiver();
|
||||||
/*
|
/*
|
||||||
List<RefTypeOrTPHOrWildcardOrGeneric> params = new ArrayList<>();
|
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 receiverType = new RefType(assumption.getReceiver().getClassName(), params, forMethod.getOffset());
|
||||||
*/
|
*/
|
||||||
|
|
||||||
RefTypeOrTPHOrWildcardOrGeneric retType = assumption.getReceiverType(resolver);
|
RefTypeOrTPHOrWildcardOrGeneric receiverType = assumption.getReceiverType(resolver);
|
||||||
methodConstraint.add(new Pair(forMethod.receiver.getType(), retType,
|
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.
|
||||||
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
|
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ANFANG
|
||||||
//methodConstraint.add(new Pair(forMethod.receiverType, retType,
|
//methodConstraint.add(new Pair(forMethod.receiverType, retType,
|
||||||
// PairOperator.EQUALSDOT));
|
// PairOperator.EQUALSDOT));
|
||||||
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
//Fuer Bytecodegenerierung PL 2020-03-09 wird derzeit nicht benutzt ENDE
|
||||||
|
|
||||||
|
|
||||||
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(),
|
methodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT));
|
||||||
PairOperator.EQUALSDOT));
|
extendsMethodConstraint.add(new Pair(assumption.getReturnType(resolver), forMethod.getType(), PairOperator.EQUALSDOT));
|
||||||
methodConstraint.addAll(generateParameterConstraints(forMethod, assumption, info, resolver));
|
|
||||||
return methodConstraint;
|
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,
|
protected Set<Pair> generateParameterConstraints(MethodCall foMethod, MethodAssumption assumption,
|
||||||
|
Loading…
Reference in New Issue
Block a user