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

Delegation fails to automatically delegate getters/setters for interface properties. #644

Open
EotT123 opened this issue Nov 23, 2024 · 3 comments

Comments

@EotT123
Copy link
Contributor

EotT123 commented Nov 23, 2024

Describe the bug
When using interface properties with delegation, I am required to manually re-implement the getters and/or setters for those properties, rather than having them automatically delegated to the delegate object. Consider the following example:

public interface TestIntf {
   @var Object object;
}

public class Test implements TestIntf {
   @override @var Object object;
}

public class DelegationTest implements TestIntf {
   @link Test delegate;

   public DelegationTest(Test delegate){
      this.delegate = delegate;
   }
   // Error! I'm forced to implement the following methods.
   // @Override public Object getObject() { ... }
   // @Override public void setObject(Object value) {  ... }
}

I would expect the getter and setter methods to be automatically delegated to the delegate object, but instead, I am forced to implement them manually.

When replacing the interface properties with getter and setter methods, I'm not required anymore to implement them when using delegation.

public interface TestIntf {
   Object getObject();
   Object setObject(Object object);
}

public class DelegationTest implements TestIntf {
   @link Test delegate;

   public DelegationTest(Test delegate){
      this.delegate = delegate;
   }
   // No error!
}

Desktop (please complete the following information):

  • OS Type & Version: Windows 10 22H2
  • Java/JDK version: openjdk 23.0.1
  • IDE version (IntelliJ IDEA or Android Studio): IntelliJ IDEA 2024.3
  • Manifold version: 2024.1.42 (latest version)
  • Manifold IntelliJ plugin version: 2024.1.13 (latest version)
@rsmckinney
Copy link
Member

Note, this is just an IntelliJ limitation at the moment, your project will still compile. This will be fixed soon. Thanks for reporting.

rsmckinney added a commit that referenced this issue Dec 14, 2024
- disambiguate a reference to a property from the implementing class where the property field comes from both the interface and the super class. The property should always resolve through the super class not the interface
@rsmckinney
Copy link
Member

Fix available with release 2024.1.43

@EotT123
Copy link
Contributor Author

EotT123 commented Dec 14, 2024

Thanks for the fix. However, it doesn't seem to fix the problem. I'm still encountering the exact same issue.

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

No branches or pull requests

2 participants