Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316583 - StackOverflow when trying to call a "super" template
Summary: StackOverflow when trying to call a "super" template
Status: CLOSED WONTFIX
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 enhancement
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-11 05:42 EDT by Pierre-Charles David CLA
Modified: 2016-03-21 06:44 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Pierre-Charles David CLA 2010-06-11 05:42:37 EDT
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
Comment 1 Laurent Goubet CLA 2016-03-21 06:44:58 EDT
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.