Lombok: (Regression) @Delegate overridden methods give "Duplicate method" compile error

Created on 14 Jul 2015  路  6Comments  路  Source: projectlombok/lombok

_Migrated from Google Code (issue 238)_

accepted enhancement

Most helpful comment

Any plans on implementing this?

All 6 comments

:bust_in_silhouette: adriano.dalpane   :clock8: Jul 17, 2011 at 16:08 UTC

What steps will reproduce the problem?

  1. Create class DelegateClass whith two methods: methodA(), methodB()
  2. Create class DelegatorClass, with a field of type DelegateClass and mark the field as @ Delegate.
  3. Override methodA() in DelegatorClass

What is the expected output? What do you see instead?
It is expect to allow both delegation and overriding in class DelegatorClass. Instead, overriding a method that comes from a field of type DelegateClass produces a "Duplicate method" compilation error

What version of the product are you using? On what operating system?
0.10.0-RC1 on linux eclipse

Please provide any additional information below.
Didn't happen with 0.10.0-BETA2

:bust_in_silhouette: pe.fips   :clock8: Jul 17, 2011 at 23:18 UTC

Actually this is how @ Delegate is supposed to behave for now.

Took me a while to find the commit:
https://github.com/rzwitserloot/lombok/commit/8c61bb0990a861ef481e2b9034b4c36df09e1061

rzwitserloot: "Changed how @ Delegate works in ecj - methods already present do NOT
preclude them from being generated, which means you get duplicate method errors.
excludes=Types has been added to counteract this. Once we figure out how to
resolve method sigs out of order we can go back to the original plan."

What you need to do is this:

  1. create an interface which contains all methods you want to delegate
  2. use @ Delegate(type=YourInterface.class)

:bust_in_silhouette: pe.fips   :clock8: Jul 17, 2011 at 23:21 UTC

I leave this issue open as a reminder that @ Delegate itself still does not work as planned.

_End of migration_

Any plans to implement this?

Any plans on implementing this?

Was this page helpful?
0 / 5 - 0 ratings