JVM model inferrer comments out type reference [message #1730991] |
Sun, 01 May 2016 20:17 |
Scott Forbes Messages: 4 Registered: February 2016 |
Junior Member |
|
|
I'm using Xtext 2.9.2 and have come across an issue - if a generated class has a field or method parameter whose typeArgs refer to another generated class, then the type reference is correct, but is commented out and replaced with Object. The same code works fine in a method body. You can reproduce the issue with:
acceptor.accept(ele.toClass('main.Class1')
[
members += ele.toField('listField', typeRef(List, typeRef('main.Class2')))
members += ele.toConstructor
[
parameters += ele.toParameter('listParam', typeRef(List, typeRef('main.Class2')))
body = '''«typeRef(List, typeRef('main.Class2'))» listBody;'''
]
])
acceptor.accept(ele.toClass('main.Class2') [])
This will generate Class1:
package main;
import java.util.List;
import main.Class2;
@SuppressWarnings("all")
public class Class1
{
private /* List<main.Class2> */Object listField;
public Class1(final /* List<main.Class2> */Object listParam)
{
List<Class2> listBody;
}
}
Am I doing something wrong? I thought the toClass() initializer was called post indexing, or is something else going on?
I've just found that generating Class2 before Class1 works around the issue in this case, so it does seem to be something to do with indexing.
[Updated on: Sun, 01 May 2016 20:37] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04845 seconds