mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-26 18:10:29 +00:00
Fix class cast exception with ObjectSource
We were generating methods with the original object, rather than the extra one. Updated our tests to actually catch this. Unfortunately the only places we use this interface is in HTTP responses and transferred files, neither of which show up in the Lua-side tests.
This commit is contained in:
parent
d351bc33c6
commit
9ea7f45fa7
@ -76,7 +76,7 @@ final class MethodSupplierImpl<T> implements MethodSupplier<T> {
|
|||||||
for (var extra : source.getExtra()) {
|
for (var extra : source.getExtra()) {
|
||||||
var extraMethods = getMethods(extra.getClass());
|
var extraMethods = getMethods(extra.getClass());
|
||||||
if (!extraMethods.isEmpty()) hasMethods = true;
|
if (!extraMethods.isEmpty()) hasMethods = true;
|
||||||
for (var method : extraMethods) consumer.accept(object, method.name(), method.method(), method);
|
for (var method : extraMethods) consumer.accept(extra, method.name(), method.method(), method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public class MethodTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testExtra() {
|
public void testExtra() {
|
||||||
ComputerBootstrap.run("assert(extra.go, 'go')\nassert(extra.go2, 'go2')",
|
ComputerBootstrap.run("assert(extra.go() == nil, 'go')\nassert(extra.go2() == 456, 'go2')",
|
||||||
x -> x.addApi(new ExtraObject()),
|
x -> x.addApi(new ExtraObject()),
|
||||||
50);
|
50);
|
||||||
}
|
}
|
||||||
@ -163,7 +163,8 @@ public class MethodTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@LuaFunction
|
@LuaFunction
|
||||||
public final void go2() {
|
public final int go2() {
|
||||||
|
return 456;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user