[wip] Improve deduction of template parameters
diff --git a/examples/org.eclipse.ocl.examples.pivot/src/org/eclipse/ocl/examples/pivot/manager/MetaModelManager.java b/examples/org.eclipse.ocl.examples.pivot/src/org/eclipse/ocl/examples/pivot/manager/MetaModelManager.java
index 5e27ca5..b788475 100644
--- a/examples/org.eclipse.ocl.examples.pivot/src/org/eclipse/ocl/examples/pivot/manager/MetaModelManager.java
+++ b/examples/org.eclipse.ocl.examples.pivot/src/org/eclipse/ocl/examples/pivot/manager/MetaModelManager.java
@@ -888,7 +888,9 @@
if (secondTemplateParameter != null) {
ParameterableElement parameterableElement = bindings.get(secondTemplateParameter);
if (parameterableElement instanceof Type) {
- secondElementType = (Type) parameterableElement;
+ Type commonElementType = getCommonType((Type) parameterableElement, firstElementType, bindings);
+ bindings.put(secondTemplateParameter, commonElementType);
+ return true;
}
else if ((parameterableElement == null) && bindings.containsKey(secondTemplateParameter)) {
bindings.put(secondTemplateParameter, firstElementType);
diff --git a/examples/org.eclipse.ocl.examples.xtext.essentialocl/src/org/eclipse/ocl/examples/xtext/essentialocl/cs2as/EssentialOCLCSLeft2RightVisitor.java b/examples/org.eclipse.ocl.examples.xtext.essentialocl/src/org/eclipse/ocl/examples/xtext/essentialocl/cs2as/EssentialOCLCSLeft2RightVisitor.java
index 0e41d56..ea052da 100644
--- a/examples/org.eclipse.ocl.examples.xtext.essentialocl/src/org/eclipse/ocl/examples/xtext/essentialocl/cs2as/EssentialOCLCSLeft2RightVisitor.java
+++ b/examples/org.eclipse.ocl.examples.xtext.essentialocl/src/org/eclipse/ocl/examples/xtext/essentialocl/cs2as/EssentialOCLCSLeft2RightVisitor.java
@@ -1025,6 +1025,18 @@
}
Type behavioralType = PivotUtil.getType(operation);
Type returnType = behavioralType != null ? metaModelManager.getSpecializedType(behavioralType, templateBindings) : null;
+ if (operation instanceof Iteration) {
+ List<Parameter> formalIterators = ((Iteration)operation).getOwnedIterator();
+ List<Variable> actualIterators = ((LoopExp)callExp).getIterator();
+ int iMax = Math.min(formalIterators.size(), actualIterators.size());
+ for (int i = 0; i < iMax; i++) {
+ Parameter iterator = formalIterators.get(i);
+ Variable actualVariable = actualIterators.get(i);
+ Type behavioralIteratorType = PivotUtil.getType(iterator);
+ Type iteratorType = behavioralIteratorType != null ? metaModelManager.getSpecializedType(behavioralIteratorType, templateBindings) : null;
+ actualVariable.setType(iteratorType);
+ }
+ }
//
// The flattening of collect() and consequently implicit-collect is not modelled accurately so we need to code it.
//