Community
Participate
Working Groups
Build Identifier: I have a very strange problem after I upgraded from Xtend 2.0.1 to 2.1: In my xtend class called "Test" I cannot access the properties and methods of a simple Java interface. After copying the class to another project everything works fine. This problem occurs only with interfaces of EMFText. As this are just simple Java interfaces (generated by EMF) it's very weird. I know that this bug report is very imprecise, but I just don't have a clue what's going on here, so I decided to post it this way. The problem is not reproducible. Are there any chances to debug this issue? Reproducible: Sometimes
Created attachment 206322 [details] Xtend error
Please try to do an explicit refresh (F5) on the project. A restart may help, too (JDT caches or plugin dependencies seem to be outdated or something like that).
(In reply to comment #2) > Please try to do an explicit refresh (F5) on the project. A restart may help, > too (JDT caches or plugin dependencies seem to be outdated or something like > that). Hi Sebastian, refreshed, cleaned, restarted, closed/opened... it all didn't work. I just created a little project in order to reproduce the error, but it doesn't occur there. And I can not provide the whole project, because it's a customer project.
I've seen a similar problem with a property from a super class. I'd no time to analyse yet, but perhaps you can see some parallels. I have four classes in different project where the last extends them like this A extends B extends C extends Named A and B are in project pAB C is in project pC Named is in project pNamed pGen contains the Xtend file pAB depends on pC and reexport it pC depends on pNamed and reexport it pGEn depends on pAB The property from Named (lets call it name) can't be accessed without cast: a.name //<fails (a as Named).name //<works for me
(In reply to comment #4) > I've seen a similar problem with a property from a super class. I'd no time to > analyse yet, but perhaps you can see some parallels. I have four classes in > different project where the last extends them like this > > A extends B extends C extends Named > A and B are in project pAB > C is in project pC > Named is in project pNamed > pGen contains the Xtend file > > pAB depends on pC and reexport it > pC depends on pNamed and reexport it > pGEn depends on pAB > > The property from Named (lets call it name) can't be accessed without cast: > > a.name //<fails > (a as Named).name //<works for me That might be related as the comments getter is defined in a superinterface, too. I'm going to try the cast workaround tomorrow.
(In reply to comment #5) > (In reply to comment #4) > > I've seen a similar problem with a property from a super class. I'd no time to > > analyse yet, but perhaps you can see some parallels. I have four classes in > > different project where the last extends them like this > > > > A extends B extends C extends Named > > A and B are in project pAB > > C is in project pC > > Named is in project pNamed > > pGen contains the Xtend file > > > > pAB depends on pC and reexport it > > pC depends on pNamed and reexport it > > pGEn depends on pAB > > > > The property from Named (lets call it name) can't be accessed without cast: > > > > a.name //<fails > > (a as Named).name //<works for me > > That might be related as the comments getter is defined in a superinterface, > too. I'm going to try the cast workaround tomorrow. The cast workaround works for me... In my example the hierachy (all interfaces are defined in the same plugin) is: Block extends Member Member extends NamedElement NamedElement extends Commentable In Commentable getComments() is defined. Scenario 1: def test(Block block) { block.comments // works } Scenario 2: def test(Member member) { member.comments // doesn't work } Scenario 3: def test(NamedElement namedElement) { namedElement.comments // works } Scenario 4: def test(Commentable commentable) { commentable.comments // works } Only having a Member type doesn't work. I can cast as NamedElement or Commentable and it works... but I don't have a clue, what's special about the Method interface.
Created attachment 206468 [details] Example project for similar situation to the one mentioned above Example project where I see the same behavior, but in a different situation. Steps: 1. Import Project 2. open both gen.xtend and Block.java 3. remove the '2' from 'Block extends Dummy2, Member' in Block.java 4. The gen.xtend get an error marker because comment can't be reslved 5. explicit cast in gen.xtend solves the problem: (b as Commentable).comment This example is only valid until saving, but behaviar looks the same.
Created attachment 206863 [details] Patch of JvmDeclaredTypeImplCustom The calculation in internalGetAllFeaturesMap skips superTypes if they appear twice in different parents, but caches the results. Patch for calculating every parent once. P.S.: Yesterday the xtend-generator used a get-method (getName) inside the Xtend-file instead of the attribute name of a local variable. class A{ def a(NamedElement n){n.name} def getName(NamedElement n){"FooBar"} } leads once to a java file where getName(n) is called.
Created attachment 206922 [details] Reworked patch for corrected cycle detection I've reworked the patch to correct the cycle detection in class hierarchy. Now it works without instance variable and less complex code. Tomorrow I can test it against the wrong error message in the editor.
Cool, thank you!
Works also for the root problem in the editor here. No problem in compiler seen since update.
Thanks for the patch. Works like a charm. See repro in bug 363621
Closing all bugs that were set to RESOLVED before Neon.0