mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix issue in record toString method generator
This commit is contained in:
parent
b6837340e5
commit
3571917a2f
|
@ -171,6 +171,9 @@ public class ObjectMethodsSubstitutor implements BootstrapMethodSubstitutor {
|
||||||
String fieldTitle = (index == 0 ? "" : ", ") + fieldName + "=";
|
String fieldTitle = (index == 0 ? "" : ", ") + fieldName + "=";
|
||||||
resultVar = resultVar.invokeVirtual("append", StringBuilder.class, pe.constant(fieldTitle));
|
resultVar = resultVar.invokeVirtual("append", StringBuilder.class, pe.constant(fieldTitle));
|
||||||
ValueEmitter thisField = InvokeDynamicUtil.invoke(pe, getter, thisVar);
|
ValueEmitter thisField = InvokeDynamicUtil.invoke(pe, getter, thisVar);
|
||||||
|
if (!(getter.getValueType() instanceof ValueType.Primitive)) {
|
||||||
|
thisField = thisField.cast(Object.class);
|
||||||
|
}
|
||||||
resultVar = resultVar.invokeVirtual("append", StringBuilder.class, thisField);
|
resultVar = resultVar.invokeVirtual("append", StringBuilder.class, thisField);
|
||||||
|
|
||||||
index = next + 1;
|
index = next + 1;
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class RecordTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void toStringMethod() {
|
public void toStringMethod() {
|
||||||
String s = new A(2, "q").toString();
|
String s = new B(2, "q", 3L).toString();
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
|
||||||
|
@ -56,8 +56,19 @@ public class RecordTest {
|
||||||
|
|
||||||
index = s.indexOf("q", index);
|
index = s.indexOf("q", index);
|
||||||
assertTrue(index > 0);
|
assertTrue(index > 0);
|
||||||
|
++index;
|
||||||
|
|
||||||
|
index = s.indexOf("z", index);
|
||||||
|
assertTrue(index > 0);
|
||||||
|
++index;
|
||||||
|
|
||||||
|
index = s.indexOf("3", index);
|
||||||
|
assertTrue(index > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
record A(int x, String y) {
|
record A(int x, String y) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
record B(int x, String y, Long z) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user