Xtend2, dispatch end inject extension [message #725420] |
Wed, 14 September 2011 17:31 |
Eclipse User |
|
|
|
Originally posted by:
Hi,
I'm trying to get a combination of dispatch methods and injection of
extension methods to work.
I have a "main" xtend class named GenX that defines a dispatch method
foo(X, Y) and calls it with x.foo(y). X has n subclasses X1..Xn and for
each of these I have an xtend class GenXn that defines a dispatch method
foo(Xn, Y). Each of these are injected into GenX with
@Inject extension GenXn. However, the foo methods in the GenXn classes
do not seem to be noticed/used by GenX. The generated Java code only
includes the dispatch method in GenX, not the ones in GenXn. From
reading
http://www.eclipse.org/Xtext/documentation/2_0_0/02-Xtend_Classes_Functions.php#Functions
I got the impression that this should work.
Hallvard
|
|
|
|
|
Re: Xtend2, dispatch end inject extension [message #725474 is a reply to message #725429] |
Wed, 14 September 2011 21:14 |
Eclipse User |
|
|
|
Originally posted by:
On 14.09.11 20.34, Christian Dietrich wrote:
>
> For a set of visible dispatch functions in the current type hierarchy,
> the compiler infers a common signature using the common super type of
> all declared arguments and generates a Java method made up of if-else
> cascades.
> So it can Be in supertypes of the Class too.
Yes, I read that. But the docs also says: "Generally function binding
works just like method binding in Java. That is function calls are bound
based on the static types of arguments. Sometimes this is not what you
want. Especially in the context of extension methods one would like to
have polymorphic behavior." This gives me the impression that extension
functions are also considered. Perhaps it refers to the case where you
want to extend several classes with the same method?
I can't see the reason for not allowing combining a dispatch method with
dispatch methods in an extension class.
Hallvard
|
|
|
|
Powered by
FUDForum. Page generated in 0.03015 seconds