fix: correctly update proto chain

This commit is contained in:
TopchetoEU 2024-04-02 18:14:55 +03:00
parent 11ecd8c68f
commit ece9cf68dc
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4

View File

@ -289,15 +289,18 @@ public class NativeWrapperProvider implements WrapperProvider {
private void updateProtoChain(Class<?> clazz, ObjectValue proto, FunctionValue constr) {
var parent = clazz;
while (true) {
parent = parent.getSuperclass();
if (parent == null) return;
while (parent != null) {
var parentProto = getProto(parent);
var parentConstr = getConstr(parent);
if (parentProto != null) Values.setPrototype(Context.NULL, proto, parentProto);
if (parentConstr != null) Values.setPrototype(Context.NULL, constr, parentConstr);
if (parentProto != null && parentConstr != null) {
Values.setPrototype(Context.NULL, proto, parentProto);
Values.setPrototype(Context.NULL, constr, parentConstr);
return;
}
parent = parent.getSuperclass();
}
}