Enumeration arguments in operations [message #479846] |
Wed, 12 August 2009 17:16 |
Eclipse User |
|
|
|
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 |
Dimitrios Kolovos 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 |
Dimitrios Kolovos 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
|
|
|
Powered by
FUDForum. Page generated in 0.03323 seconds