Bug 330263 - [engine] No multiple dispatch when calling queries
Summary: [engine] No multiple dispatch when calling queries
Status: NEW
Alias: None
Product: Acceleo
Classification: Modeling
Component: Core (show other bugs)
Version: 3.0.0   Edit
Hardware: PC Linux
: P5 enhancement
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-15 11:47 EST by Mikaël Barbero CLA
Modified: 2016-03-29 05:51 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mikaël Barbero CLA 2010-11-15 11:47:24 EST
Hi guys,

I got a strange behavior. It seems that only the compile time type is taken into account when calling queries. It is a different behavior than the one with templates. Here is a sample:

[template public gen(e : EStructuralFeature)]
// [eType.q()/]
[if (eType.oclIsKindOf(EDataType))]
// [eType.oclAsType(EDataType).q()/] <-- MUST be the same as the first call to q(), but it is NOT.
[/if]

// --

// [eType.t()/]
[if (eType.oclIsKindOf(EDataType))]
// [eType.oclAsType(EDataType).t()/] <-- MUST be the same as the first call to t(), and it IS.
[/if]	
[/template]


[template public t(e : EDataType)]t(EDataType)[/template]
[template public t(e : EClass)]t(EClass)[/template]

[query public q(e : EDataType) : String =  'q(EDataType)' /]
[query public q(e : EClass) : String = 'q(EClass)' /]

Regards,
Mikael
Comment 1 Stephane Begaudeau CLA 2011-06-24 09:12:43 EDT
This subject needs to be carefully analyzed, for example, can a call to a query be dispatched to a template if the template and the query can both be called?
Comment 2 Laurent Goubet CLA 2016-03-29 05:51:56 EDT
A query and a template of the same name cannot be created ("module element already exists"), so this shouldn't be an issue.

However, dynamically dispatching to the proper query according to the argument's runtime type seems too major a change for a maintenance version. Should only be considered if we ever switch to Acceleo 4 (i.e. for a major version bump).