mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix generation of meta method when its discriminator class denotes array type
This commit is contained in:
parent
19e8e06446
commit
edb3d2ff48
|
@ -107,7 +107,7 @@ public class MetaprogrammingDependencyListener extends AbstractDependencyListene
|
||||||
ValueType type = usageEntry.getKey();
|
ValueType type = usageEntry.getKey();
|
||||||
String typeName = type instanceof ValueType.Object
|
String typeName = type instanceof ValueType.Object
|
||||||
? ((ValueType.Object) type).getClassName()
|
? ((ValueType.Object) type).getClassName()
|
||||||
: type.toString();
|
: type.toString().replace('/', '.');
|
||||||
choice.option(typeName, () -> {
|
choice.option(typeName, () -> {
|
||||||
MethodReference implMethod = usageEntry.getValue();
|
MethodReference implMethod = usageEntry.getValue();
|
||||||
ValueEmitter[] castParamVars = new ValueEmitter[paramVars.length];
|
ValueEmitter[] castParamVars = new ValueEmitter[paramVars.length];
|
||||||
|
|
|
@ -94,7 +94,6 @@ public class MethodDescriber {
|
||||||
int classParamIndex = -1;
|
int classParamIndex = -1;
|
||||||
for (int i = 0; i < method.parameterCount(); ++i) {
|
for (int i = 0; i < method.parameterCount(); ++i) {
|
||||||
ValueType proxyParam = meta.parameterType(i + paramOffset);
|
ValueType proxyParam = meta.parameterType(i + paramOffset);
|
||||||
ValueType param = method.parameterType(i);
|
|
||||||
if (proxyParam.isObject(ReflectClass.class)) {
|
if (proxyParam.isObject(ReflectClass.class)) {
|
||||||
if (classParamIndex == -1) {
|
if (classParamIndex == -1) {
|
||||||
classParamIndex = i;
|
classParamIndex = i;
|
||||||
|
|
|
@ -414,6 +414,18 @@ public class MetaprogrammingTest {
|
||||||
|
|
||||||
private static int counter = 0;
|
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 {
|
static class Context {
|
||||||
public int a;
|
public int a;
|
||||||
public int b;
|
public int b;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user