mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -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 + "=";
|
||||
resultVar = resultVar.invokeVirtual("append", StringBuilder.class, pe.constant(fieldTitle));
|
||||
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);
|
||||
|
||||
index = next + 1;
|
||||
|
|
|
@ -38,7 +38,7 @@ public class RecordTest {
|
|||
|
||||
@Test
|
||||
public void toStringMethod() {
|
||||
String s = new A(2, "q").toString();
|
||||
String s = new B(2, "q", 3L).toString();
|
||||
|
||||
int index = 0;
|
||||
|
||||
|
@ -56,8 +56,19 @@ public class RecordTest {
|
|||
|
||||
index = s.indexOf("q", index);
|
||||
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 B(int x, String y, Long z) {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user