|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338,
Visits: 890
|
|
Hi,
There's an enum:
public enum TopicType {
Content = 0,
BlogPost = 1 // etc
}
And there's an object Topic with property TopicType: TopicType (property name is equal to enum name).
When I try to execute OCL like: Topic.allinstances->select(TopicType = TopicType::Content)
it fails with error:
Borland.Eco.Internal.EBoldOCLError: 42:Unable to deduce type of expression
Operation: =
Arg 1: , Arg 2: TestApp.TopicType
Using deduce method: the two parameters must belong to the same domain (type, object, value)
at Borland.Eco.Internal.TBoldOclSemanticsVisitor.DeduceBoldType(TBoldOclOperation N)
at Borland.Eco.Internal.TBoldOclSemanticsVisitor.VisitTBoldOclOperation(TBoldOclOperation N)
at Borland.Eco.Internal.TBoldOclOperation.AcceptVisitor(TBoldOclVisitor V)
When I try to execute OCL like: Topic.allinstances->select(TopicType = #Content)
it fails with error:
Borland.Eco.Internal.EBoldOCLError: 42:Unable to deduce type of expression
Operation: =
Arg 1: , Arg 2:
Using deduce method: the two parameters must belong to the same domain (type, object, value)
at Borland.Eco.Internal.TBoldOclSemanticsVisitor.DeduceBoldType(TBoldOclOperation N)
at Borland.Eco.Internal.TBoldOclSemanticsVisitor.VisitTBoldOclOperation(TBoldOclOperation N)
at Borland.Eco.Internal.TBoldOclOperation.AcceptVisitor(TBoldOclVisitor V)
Isn't there a way to have enum and property with the same name?
It's Eco3, not sure how it behaves in Eco4-5.
Regards,
Dmitriy.
My Blog: http://dnagir.blogspot.com
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338,
Visits: 890
|
|
While ECO cannot resolve the property and type we can use workaround by explicitly using object:
Topic.allinstances->select(t | t.TopicType = TopicType::Content)
My Blog: http://dnagir.blogspot.com
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2012-01-26 14:59:09
Posts: 242,
Visits: 828
|
|
| I guess if you put it like this: Topic.allinstances->select(t | topicType = TopicType::Content) If you have name conflict between types and properties in OCL, you can resove it with context sensitivity: the first small letter for property, the first capital letter: for type. I'm not sure though if this rule of thumb will be used in ECO >4 versions too. BTW it's not specific for enumerations, but for all types.
/Efim
|
|
|
|
|
Supreme Being
      
Group: Forum Members
Last Login: 2010-08-11 16:02:44
Posts: 338,
Visits: 890
|
|
he first small letter for property, the first capital letter: for type
Interesting. I've tried and this and it seems this little trick works: Topic.allinstances->select(topicType = TopicType::Content)
Thanks for the tip.
My Blog: http://dnagir.blogspot.com
|
|
|
|