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

Bug when using property inference and extending classes #646

Open
EotT123 opened this issue Dec 5, 2024 · 3 comments
Open

Bug when using property inference and extending classes #646

EotT123 opened this issue Dec 5, 2024 · 3 comments
Labels

Comments

@EotT123
Copy link
Contributor

EotT123 commented Dec 5, 2024

Describe the bug
When using manifold-props, the following code of produces an error:

public abstract class Parent {
    protected Object foo = null;

    public Object getFoo() {
        return foo;
    }
}

public class Child extends Parent{
    public Object getFoo() {
        if (foo == null) {
            foo = new Object(); // ERROR: Cannot assign read-only property 'foo '
        }
        return foo;
    }
}

The issue arises when attempting to set the foo field in the class Child, which is a (non private) field in the superclass Parent. Due to property inference, only a getter is available for foo, causing the assignment to result in the error: Cannot assign read-only property 'foo'.

If the getFoo() method is omitted from the Parent class, the issue does not occur. Removing manifold-props also resolves the problem.

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)
@EotT123
Copy link
Contributor Author

EotT123 commented Dec 5, 2024

I encountered this error in class javax.swing.text.JTextComponent:

public abstract class JTextComponent extends JComponent {
    ...
    public AccessibleContext getAccessibleContext() {
        if (accessibleContext == null) {
            accessibleContext = new AccessibleJTextComponent();
        }
        return accessibleContext;
    }
    ...
}

One of the parents of JTextComponent is java.awt.Component, which contains the accessibleContext field, and a getter method:

public abstract class Component {
    ...
    protected AccessibleContext accessibleContext = null;

    public AccessibleContext getAccessibleContext() {
        return accessibleContext;
    }
    ....
}

@EotT123 EotT123 changed the title Bug when using property interference and extending classes Bug when using property inference and extending classes Dec 6, 2024
@rsmckinney rsmckinney added the bug label Dec 8, 2024
@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 error when building with Maven.

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