diff --git a/src/main/java/dev/latvian/mods/rhino/Context.java b/src/main/java/dev/latvian/mods/rhino/Context.java index d98b924f..53930fca 100644 --- a/src/main/java/dev/latvian/mods/rhino/Context.java +++ b/src/main/java/dev/latvian/mods/rhino/Context.java @@ -1461,10 +1461,6 @@ protected Object internalJsToJava(Object from, TypeInfo target) { Object unwrappedValue = Wrapper.unwrapped(from); - if (unwrappedValue instanceof TypeWrapperFactory f) { - return f.wrap(this, unwrappedValue, target); - } - var typeWrapper = factory.getTypeWrappers().getWrapperFactory(unwrappedValue, target); if (typeWrapper != null) { @@ -1580,6 +1576,10 @@ protected Object internalJsToJava(Object from, TypeInfo target) { } protected Object internalJsToJavaLast(Object from, TypeInfo target) { + if (target instanceof TypeWrapperFactory f) { + return f.wrap(this, from, target); + } + return reportConversionError(from, target); }