gradle-retrolambda
gradle-retrolambda copied to clipboard
Compilation issue when using a closure where one can't be used
I'm not sure if there's much that can be done about this or not. My understanding of how retrolambda works is pretty thin. Feel free to close as a "won't/can't fix!"
I had an instance where I had the following:
.callback(materialDialog -> mPresenter.onPositiveTapErrorDialog())
This worked correctly until another method was added to this class (no longer making it closure compatible). It required the following change:
.callback(new MaterialDialog.ButtonCallback() {
@Override
public void onPositive(MaterialDialog dialog) {
mPresenter.onPositiveTapErrorDialog();
}
})
Instead of getting an error pointing me to this issue, I got a somewhat vague message at compile time:
... ommitted
:app:patchAndroidJar
:app:_compileStagingDebugJava
error: incompatible types: ButtonCallback is not a functional interface
error: incompatible types: ButtonCallback is not a functional interface
error: incompatible types: ButtonCallback is not a functional interface
error: incompatible types: ButtonCallback is not a functional interface
When I navigated to the file (after figuring out where this type was... not super trivial since it was a part of a library), it was underlined in red correctly flagging the problem.
It'd be awesome if the error could point directly to a place in source.
(more info if desired - http://stackoverflow.com/questions/27951088/android-build-error-error-incompatible-types-buttoncallback-is-not-a-functi)
This is almost certainly output produced by retrolambda itself, you might want to check with that project to see if there is a way to make the error message more verbose/helpful.
Edit: I take that back, it's probably produced by the java 8 compiler before it even gets that far. I can look to see if I'm somehow missing something with how gradle reports javac errors, but I'm not sure I can do anything. Have you tried running with gradle --info or gradle --debug?
@evant I didn't get any helpful info with those commands.
Yeah, this is an area where I definitely don't completely understand what's going on under the hood.