Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Enumeration arguments in operations
Enumeration arguments in operations [message #479846] Wed, 12 August 2009 17:16 Go to next message
Eclipse UserFriend
Originally posted by: nyoescape.gmail.com

Hello all,

I've defined an operation which takes an enumeration literal as a
parameter. Oddly enough, it doesn't work when I declare it as such. It
does work when I declare that parameter to be of type Any.

For testing, I've defined an Ecore model whose Emfatic source looks like
this:

@namespace(uri="testEnumArgs", prefix="ea")
package EnumArgs;

enum Color {
RED;
BLUE;
}

If I run the following EOL script against an empty model which conforms
to the previous metamodel, the first call works, but the second reports
"Type 'Color' not found":

toggle(Color#RED).println('Color A: ');
brokenToggle(Color#RED).println('Color A: ');

operation toggle(color : Any) {
if (color = Color#RED) {
return Color#BLUE;
} else {
return Color#RED;
}
}

operation brokenToggle(color : Color) {
if (color = Color#RED) {
return Color#BLUE;
} else {
return Color#RED;
}
}

Is this a bug, or am I doing something wrong?

Just in case, I've submitted a bug with a sample project which
reproduces the issue:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=286412

Regards,
Antonio
Re: Enumeration arguments in operations [message #479887 is a reply to message #479846] Wed, 12 August 2009 22:04 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Antonio,

Sounds like a bug indeed. Many thanks for submitting the bug report and
this concise example that reproduces it!

Cheers,
Dimitris

Antonio García Domínguez wrote:
> Hello all,
>
> I've defined an operation which takes an enumeration literal as a
> parameter. Oddly enough, it doesn't work when I declare it as such. It
> does work when I declare that parameter to be of type Any.
>
> For testing, I've defined an Ecore model whose Emfatic source looks like
> this:
>
> @namespace(uri="testEnumArgs", prefix="ea")
> package EnumArgs;
>
> enum Color {
> RED;
> BLUE;
> }
>
> If I run the following EOL script against an empty model which conforms
> to the previous metamodel, the first call works, but the second reports
> "Type 'Color' not found":
>
> toggle(Color#RED).println('Color A: ');
> brokenToggle(Color#RED).println('Color A: ');
>
> operation toggle(color : Any) {
> if (color = Color#RED) {
> return Color#BLUE;
> } else {
> return Color#RED;
> }
> }
>
> operation brokenToggle(color : Color) {
> if (color = Color#RED) {
> return Color#BLUE;
> } else {
> return Color#RED;
> }
> }
>
> Is this a bug, or am I doing something wrong?
>
> Just in case, I've submitted a bug with a sample project which
> reproduces the issue:
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=286412
>
> Regards,
> Antonio
Re: Enumeration arguments in operations [message #574022 is a reply to message #479846] Wed, 12 August 2009 22:04 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Antonio,

Sounds like a bug indeed. Many thanks for submitting the bug report and
this concise example that reproduces it!

Cheers,
Dimitris

Antonio García Domínguez wrote:
> Hello all,
>
> I've defined an operation which takes an enumeration literal as a
> parameter. Oddly enough, it doesn't work when I declare it as such. It
> does work when I declare that parameter to be of type Any.
>
> For testing, I've defined an Ecore model whose Emfatic source looks like
> this:
>
> @namespace(uri="testEnumArgs", prefix="ea")
> package EnumArgs;
>
> enum Color {
> RED;
> BLUE;
> }
>
> If I run the following EOL script against an empty model which conforms
> to the previous metamodel, the first call works, but the second reports
> "Type 'Color' not found":
>
> toggle(Color#RED).println('Color A: ');
> brokenToggle(Color#RED).println('Color A: ');
>
> operation toggle(color : Any) {
> if (color = Color#RED) {
> return Color#BLUE;
> } else {
> return Color#RED;
> }
> }
>
> operation brokenToggle(color : Color) {
> if (color = Color#RED) {
> return Color#BLUE;
> } else {
> return Color#RED;
> }
> }
>
> Is this a bug, or am I doing something wrong?
>
> Just in case, I've submitted a bug with a sample project which
> reproduces the issue:
>
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=286412
>
> Regards,
> Antonio
Previous Topic:Enumeration arguments in operations
Next Topic:ClassCastException when assigning enum literal to attribute
Goto Forum:
  


Current Time: Fri Apr 19 20:41:18 GMT 2024

Powered by FUDForum. Page generated in 0.04482 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top