mirror of
https://github.com/apple/pkl.git
synced 2026-04-20 15:31:28 +02:00
Fix Function.toString (#1411)
Fixes an issue where the underlying default Java toString() is leaking through
This commit is contained in:
@@ -181,4 +181,10 @@ public final class VmFunction extends VmObjectLike {
|
||||
public int hashCode() {
|
||||
return System.identityHashCode(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@TruffleBoundary
|
||||
public String toString() {
|
||||
return VmValueRenderer.singleLine(Integer.MAX_VALUE).render(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2026 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -34,8 +34,13 @@ public final class VmValueRenderer {
|
||||
private final String interiorNewline;
|
||||
private final String indent;
|
||||
private String currIndent = "";
|
||||
private static final VmValueRenderer maxSingleLine =
|
||||
new VmValueRenderer(Integer.MAX_VALUE, " ", "; ", "");
|
||||
|
||||
public static VmValueRenderer singleLine(int lengthLimit) {
|
||||
if (lengthLimit == Integer.MAX_VALUE) {
|
||||
return maxSingleLine;
|
||||
}
|
||||
return new VmValueRenderer(lengthLimit, " ", "; ", "");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user