diff --git a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java index 132fa3995..055f8041a 100755 --- a/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java +++ b/src/de/dhbwstuttgart/syntaxtree/statement/LambdaExpression.java @@ -22,9 +22,11 @@ import de.dhbwstuttgart.syntaxtree.type.RefType; import de.dhbwstuttgart.syntaxtree.type.SuperWildcardType; import de.dhbwstuttgart.syntaxtree.type.Type; import de.dhbwstuttgart.syntaxtree.type.TypePlaceholder; +import de.dhbwstuttgart.syntaxtree.type.WildcardType; import de.dhbwstuttgart.typeinference.ConstraintsSet; import de.dhbwstuttgart.typeinference.FunN; import de.dhbwstuttgart.typeinference.JavaCodeResult; +import de.dhbwstuttgart.typeinference.OderConstraint; import de.dhbwstuttgart.typeinference.ResultSet; import de.dhbwstuttgart.typeinference.SingleConstraint; import de.dhbwstuttgart.typeinference.Typeable; @@ -158,12 +160,32 @@ public class LambdaExpression extends Expr{ TypePlaceholder tph = TypePlaceholder.fresh(this); tphParamTypes.add(tph); // PN < TPH PN - ret.add(new SingleConstraint(tph.TYPE(assumptions, this), pT.TYPE(assumptions, this))); + if(pT instanceof WildcardType){ + ret.add(new SingleConstraint(tph.TYPE(assumptions, this), pT.TYPE(assumptions, this))); + }else{ + OderConstraint orCons = new OderConstraint(); + SuperWildcardType superpT = new SuperWildcardType(pT.getOffset(), (ObjectType) pT); + SingleConstraint cons1 = new SingleConstraint(tph.TYPE(assumptions, this), superpT.TYPE(assumptions, this)); + SingleConstraint cons2 = new SingleConstraint(tph.TYPE(assumptions, this), pT.TYPE(assumptions, this)); + orCons.addConstraint(cons1); + orCons.addConstraint(cons2); + ret.add(orCons); + } } Type retType = method_body.getType(); Type tphRetType = TypePlaceholder.fresh(this); // PN < TPH PN - ret.add(new SingleConstraint(retType.TYPE(assumptions, this), tphRetType.TYPE(assumptions, this))); + if(retType instanceof WildcardType){ + ret.add(new SingleConstraint(retType.TYPE(assumptions, this), tphRetType.TYPE(assumptions, this))); + }else{ + OderConstraint orCons = new OderConstraint(); + SuperWildcardType superretType = new SuperWildcardType(retType.getOffset(), (ObjectType) retType); + SingleConstraint cons1 = new SingleConstraint(tphRetType.TYPE(assumptions, this), superretType.TYPE(assumptions, this)); + SingleConstraint cons2 = new SingleConstraint(tphRetType.TYPE(assumptions, this), retType.TYPE(assumptions, this)); + orCons.addConstraint(cons1); + orCons.addConstraint(cons2); + ret.add(orCons); + } ret.add(new SingleConstraint(new FunN(tphRetType, tphParamTypes).TYPE(assumptions, this),this.getType().TYPE(assumptions, this))); return ret; diff --git a/test/plugindevelopment/TypeInsertTests/BoundedGenericTest.jav b/test/plugindevelopment/TypeInsertTests/BoundedGenericTest.jav index 68703a121..2fbcc715a 100755 --- a/test/plugindevelopment/TypeInsertTests/BoundedGenericTest.jav +++ b/test/plugindevelopment/TypeInsertTests/BoundedGenericTest.jav @@ -1,6 +1,6 @@ -class BoundedGenericTest{ +class BoundedGenericTest{ var = "test"; - B methode(){ + methode(){ return var; } } \ No newline at end of file