-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integer types should be converted to unified integer type (long) for java module function calls #369
Comments
The Change the binding type is a simple solution |
While this is true for simple
now if we put |
I know this could be solved by using |
@beleon you can use But you are right, maybe the engine can take care of it to simplify the usage. I will consider it in next release, thanks. |
Right, that would be cleaner. Thanks for considering it! |
A somewhat related issue I noticed is that when calling an overloaded function (like the print function in the PrintModule class) with nil, that depending on which types of overloaded functions are defined different methods will be called, e.g. if we define the three methods of the example ( |
Then again, this would probably mess with normal methods that are not overloaded, so this is probably not a good idea after all. |
@beleon Release 5.2.5 https://github.com/killme2008/aviatorscript/releases/tag/aviator-5.2.5 I may add |
Thank you! I'll test it soon. Adding a |
Can verify that it works 👍 closing the issue |
Given a Java module
the following problem occurs:
will result in
java.lang.ClassCastException: Cannot cast java.lang.Integer to java.lang.Long
because variable x is a Java Integer.we could try to add a method to the PrintModule:
but this will now result in
java.lang.ClassCastException: Cannot cast java.lang.Long to java.lang.Integer
because the second print.print call is done with a10
inside Aviator which is a long. Even though we provided a definition forprint(Long value)
this definition is ignored, as Aviator consider int and long to be the same type and therefore Aviator picksprint(Integer value)
overprint(Long value)
.I think it would be best to automatically convert all integer types (byte, short, int, ...) to the unified integer type long before calling a java module function. This would be analogous to converting all integer types to long when doing arithmetic, e.g.
will result in a long even if x is a Java Integer. I think the same conversion should be done when calling a java module function.
The text was updated successfully, but these errors were encountered: