gradle-retrolambda icon indicating copy to clipboard operation
gradle-retrolambda copied to clipboard

Compilation issue when using a closure where one can't be used

Open loeschg opened this issue 10 years ago • 2 comments
trafficstars

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)

loeschg avatar Jan 14 '15 20:01 loeschg

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 avatar Jan 14 '15 21:01 evant

@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.

loeschg avatar Jan 14 '15 23:01 loeschg