QVTo constructor behavior when extending transformations [message #1688375] |
Fri, 20 March 2015 11:20  |
Eclipse User |
|
|
|
Hi,
I observed the following behavior for constructors, which I didn't expect:
I have two transformations A, and B. B extends A. A contains a constructor (ConsA). A also contains a mapping which uses ConsA (mappingA). I intended to overwrite this constructor in B and hence added a new implementation of ConsA in B. B utilizes mappingA. Much to my surprise the constructor from A is called rather from B. If I surround the constructor in a mapping which I also overwrite in transformation B the new constructor is used.
In pseudo code:
transformation A();
...
mapping mappingA()
{
new ConsA();
}
ConsA::ConsA(inp:String) // The to be created object is named ConsA for this example.
{
log("Constructor from mapping A");
}
transformation B() extends transformation A();
...
mapping X()
{
map mappingA();
}
ConsA::ConsA(inp:String) // The to be created typeis named ConsA for this example.
{
log("Constructor from mapping B");
}
Logs: Constructor from mapping A.
Overwriting mappingA in transformation B will result in: Constructor from mapping B.
The QVTo spec states:
Quote:
1) A constructor may be defined as an operation of the class to be constructed or may be owned by a module that plays a role of factory for the class.
2) An access import behaves as a traditional package import, whereas extension semantics combines package import and class inheritance paradigm.
Is the current behavior correct? Can I make my constructor be owned by the class rather than the module?
Kind regards,
Teun
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03224 seconds