Fix generation of meta method when its discriminator class denotes array type

This commit is contained in:
Alexey Andreev 2017-02-12 00:23:53 +03:00
parent 19e8e06446
commit edb3d2ff48
3 changed files with 13 additions and 2 deletions

View File

@ -107,7 +107,7 @@ public class MetaprogrammingDependencyListener extends AbstractDependencyListene
ValueType type = usageEntry.getKey();
String typeName = type instanceof ValueType.Object
? ((ValueType.Object) type).getClassName()
: type.toString();
: type.toString().replace('/', '.');
choice.option(typeName, () -> {
MethodReference implMethod = usageEntry.getValue();
ValueEmitter[] castParamVars = new ValueEmitter[paramVars.length];

View File

@ -94,7 +94,6 @@ public class MethodDescriber {
int classParamIndex = -1;
for (int i = 0; i < method.parameterCount(); ++i) {
ValueType proxyParam = meta.parameterType(i + paramOffset);
ValueType param = method.parameterType(i);
if (proxyParam.isObject(ReflectClass.class)) {
if (classParamIndex == -1) {
classParamIndex = i;

View File

@ -414,6 +414,18 @@ public class MetaprogrammingTest {
private static int counter = 0;
@Test
public void arrayTypeSelected() {
assertEquals(String[].class, createInstance(String.class, 1).getClass());
assertEquals(String[][].class, createInstance(String[].class, 1).getClass());
}
@Meta
private static native Object createInstance(Class<?> cls, int size);
private static void createInstance(ReflectClass<?> cls, Value<Integer> size) {
exit(() -> cls.createArray(size.get()));
}
static class Context {
public int a;
public int b;