Skip to content
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

Mixin methods loose generic types #73

Closed
lgrignon opened this issue Feb 20, 2016 · 3 comments
Closed

Mixin methods loose generic types #73

lgrignon opened this issue Feb 20, 2016 · 3 comments
Labels
Milestone

Comments

@lgrignon
Copy link
Collaborator

For instance in candy cordova--plugins-FileSystem-0.0.0-SNAPSHOT
jsweet.dom.Window has a mixin defining this method :

native public void requestFileSystem(double type, double size, java.util.function.Consumer<FileSystem> successCallback, java.util.function.Consumer<FileError> errorCallback);

but it seems that the signature added to jsweet.dom.Window is

native public void requestFileSystem(double type, double size, java.util.function.Consumer<Object> successCallback, java.util.function.Consumer<Object> errorCallback);

Note that the Consumers - callbacks - parameters are now typed with Object

The following code does not work, the compiler complains about the wrong Consumers parameter type:

import def.cordova.plugins.FileError;
import def.cordova.plugins.FileSystem;
// [...]
window.requestFileSystem(
                            window.PERSISTENT,
                            1000*1000,
                            (FileSystem fileSystem) -> {
                                console.log("FileSystem ready");
                            },
                            (FileError error) -> console.log("bad error", error));
@renaudpawlak renaudpawlak added this to the 1.1.0 milestone Feb 21, 2016
@renaudpawlak
Copy link
Contributor

I am surprised, but the solution should be Javassist's setGenericSignature: http://jboss-javassist.github.io/javassist/html/javassist/CtBehavior.html#setGenericSignature-java.lang.String-

@lgrignon
Copy link
Collaborator Author

okay, I have a fix thanks to your insight.

This "detail" fixes some signature problems so it may cause regression on some client code.

Related PR: #77

@renaudpawlak
Copy link
Contributor

Thanks Louis. The fix looks good (and simple) to me. If regression there is, it should be easy to fix for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants