Community
Participate
Working Groups
Build Identifier: 20100603-0907 I have types A and B, B a subtype of A, and the following template on A: [template public genText(a : A)] text for A [/template] I want to create a new template of the same name on B, and in that template, call the code for genText(a : A). I tried: [template public genText(b : B)] [b.A::genText()/] text for B [/template] expecting to force a static resolution of the actual template to invoke by using the full classified name, but this raises a StackOverflowException, as b.A::genText() seems to resolve the template on the dynamic type of b and call genText(b : B). Marking as enhancement as I'm not sure what the spec says. Reproducible: Always
Acceleo will always call the most specific template. [b.A::genText()/] will result in the same as [b.oclAsType(A).genText()/]. The compiled template invocation indeed points to calling the "genText(A)" version, but at runtime we always check whether there's a more specific template we can call; so these two are exactly the same as calling directly [b.genText()/] in the present case. The specification says nothing about which template to call in case of multiple templates sharing the same name but having distinct parameters. A workaround in this case would be to create a third template and calling it from both : [template public genText(a : A)] [a.commonText()/] [/template] [template public genText(b : B)] [b.commonText()/] text for B [/template] [template public commonText(a : A)] text for A [/template] Marking as won't fix as this behavior is not planned to be changed.