-
Notifications
You must be signed in to change notification settings - Fork 38
null == operand
causes ambiguous feature call error.
#300
Comments
My question is: what is the best way to support the failing case? Is possible to define an operator_equals function and specifying that this function is usable when the left argument is null? Should I define operator_equals(Object left, Number right)? In this case, the type compiler of Xbase hould be fixed to avoid the ambiguous feature call error. |
@szarnekow any idea? |
To me the declaration is indeed ambigous. Can you answer the question, which extension method should be called for |
For me it should be Of course the question becomes more complex if you consider that |
What does Java do if you have three static imports for your extension methods and the overload for Object, Object? |
If there is multiple function with a right parameter with type I think we could keep the error message from Xbase (this is not the problem at all), but with a small change into the text for this special case. We could add into the error message something like: "We recommend to use the operator === when the left operand is null"? What do you think? |
I'm not totally keen on having a special case for one scenario because the (expected and correctly detected) ambiguity is present to other operators and extension methods, too. |
Closed as wont-fix. Feel free to reopen at github.com/eclipse/xtext |
I have defined several extension methods (which are implicitly imported):
The following lines are compiled without error:
But, the following lines cause a compilation error (ambiguous feature call):
As you could see, the operands of the
==
operator are switched.Semantically, both definitions are equivalent.
Both should compile without error.
The text was updated successfully, but these errors were encountered: