From 0c9612a2ea114d11567ff77a8e2eb1f89bc40484 Mon Sep 17 00:00:00 2001 From: "pl@gohorb.ba-horb.de" Date: Tue, 31 Jan 2023 11:18:52 +0100 Subject: [PATCH] modified: ../../../main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java --- .../typeinference/typeAlgo/TYPEStmt.java | 39 +++++++++++++------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java index 803e0df1..ef84fad9 100644 --- a/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java +++ b/src/main/java/de/dhbwstuttgart/typeinference/typeAlgo/TYPEStmt.java @@ -207,9 +207,10 @@ public class TYPEStmt implements StatementVisitor{ Set> methodConstraints = new HashSet<>(); for(MethodAssumption m : this.getMethods(methodCall.name, methodCall.arglist, info)){ GenericsResolver resolver = getResolverInstance(); - Constraint oneMethodConstraint = generateConstraint(methodCall, m, info, resolver); - methodConstraints.add(oneMethodConstraint); + Set> oneMethodConstraints = generateConstraint(methodCall, m, info, resolver); + methodConstraints.addAll(oneMethodConstraints); + /* pl 2023-01-20: in generateConstraint bereits umgesetzt Constraint 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 generateConstraint(MethodCall forMethod, MethodAssumption assumption, + protected Set> generateConstraint(MethodCall forMethod, MethodAssumption assumption, TypeInferenceBlockInformation info, GenericsResolver resolver){ - Constraint methodConstraint = new Constraint<>(assumption.isInherited()); + Constraint 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 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 parameterContraints = generateParameterConstraints(forMethod, assumption, info, resolver); + + methodConstraint.addAll(parameterContraints); + extendsMethodConstraint.addAll(parameterContraints); + + Set> ret = new HashSet<>(); + ret.add(methodConstraint); + ret.add(extendsMethodConstraint); + return ret; } protected Set generateParameterConstraints(MethodCall foMethod, MethodAssumption assumption,