Bug 254482 - QVTO: Disable implicit source resolution in ResolveExp
Summary: QVTO: Disable implicit source resolution in ResolveExp
Status: RESOLVED FIXED
Alias: None
Product: QVTo
Classification: Modeling
Component: Engine (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0 M4   Edit
Assignee: Alexander Igdalov CLA
QA Contact:
URL:
Whiteboard:
Keywords: Documentation, noteworthy
Depends on:
Blocks:
 
Reported: 2008-11-06 13:09 EST by Alexander Igdalov CLA
Modified: 2008-11-13 14:52 EST (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 Alexander Igdalov CLA 2008-11-06 13:09:59 EST
There have been many discussions about the necessity of resolving implicit source in ResolveExp. Currently, in case a source of the ResolveExp is not set explicitly the compiler tries to find it among implicit variables.
When implementing bug 252358 and bug 253051 I found that within (implicit) ObjectExps the target variable ('s' in the example below) must be put into the environment as an implicit variable. This is done to implement the idea (8.1.5): 

"object s:Schema {
  name := self.name;
  table := self.ownedElement->map class2table();
}

Within an object expression, the properties of the target variable ('s' in our example) can be accessed directly. Thus the assignment expression "name := self.name" means "s.name := self.name"."
However, in case resolve(resolveIn) expressions without source expression are used within object expressions they automatically get the implicit target variable as source.

Consider the example below:

mapping EPackage::myMapping() : EPackage {
	name := 'BBB' + resolveoneIn(EPackage::mySubmapping, EPackage).name;
}

Within the mapping implicit population section the compiler creates an implicit ObjectExp referring to the 'result' variable. The result variable is added to the environment as implicit in order to allow direct access to its properties and operations ('name' property in this example). As a consequence, resolveoneIn get the implicit source - the 'result' variable. Meanwhile, it is obvious that the script intends to use the ResolveInExp without source.

Solution: disable ResolveExp/ResolveInExp implicit source resolution. The spec doesn't mention this feature explicitly, it was implemented in similarity with properties and operations. However, after allowing direct access to properties/operations of the target variable in the ObjectExp body this facility becomes detrimental.
Comment 1 Sergey Boyko CLA 2008-11-07 11:09:57 EST
I don't see any pitfalls with disabling implicit source lookup for resolve() family. User always can explicitly specify source in case. 
Also .qvto script human readability will benefit from making resolve() call semantic context-insensitive.
Comment 2 Radomil Dvorak CLA 2008-11-10 05:02:52 EST
(In reply to comment #0)
We can't disable optional source object for resolveIn, which is mentioned by the spec explicitly.
For resolveIn, we do not have to use the same strategy for implicit source lookup as defined in lookup lookupImplicitSourceForOperation, etc.
The spec says explicitly how to handle the case if the source is missing.
Then we just have to check if we can safely handle the case with null source and document this as a breaking change.

Comment 3 Radomil Dvorak CLA 2008-11-10 05:05:12 EST
(In reply to comment #2)
BTW, resolve without a source is already guarded by a compilation error
Comment 4 Alexander Igdalov CLA 2008-11-13 13:55:53 EST
Fixed.