manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.43k stars 125 forks source link

[Bug] unintended behavior for manifold-prop annotation parameters #483

Closed CC007 closed 1 year ago

CC007 commented 1 year ago

Describe the bug When using @var, @val, @get and @set without parameter the resulting getter and/or setter is public by default. when you add PropOption.Private or PropOption.Package as an annotation parameter, the created method for the respective getter/setter will be private or package-private respectively. So far so good.

However for @get, @set and @var, when using PropOption.Public or PropOption.Protected, I get the following error:

java: 'get' attempting to assign weaker access privileges; was 'package'

If manifold were to follow the java standard and make the getters and setters package-private by default, I would understand this error, but since manifold makes these public by default, this error seems incorrect.

Also, for @val I get a different error:

java: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.tree.JCTree.getStartPosition()" because "tree" is null
java: java.lang.NullPointerException: Cannot invoke "com.sun.tools.javac.tree.JCTree.getStartPosition()" because "tree" is null

Workaround Marking the field as public solves the issue for all 4 cases and still properly makes the field private after compilation, but this seems redundant, since this should have been the default with Manifold.

To Reproduce Steps to reproduce the behavior:

  1. Build code from gist/picture

Expected behavior I expected the use of Public and Protected to work as well, with all 4 annotations.

Screenshots afbeelding

Desktop (please complete the following information):

Additional context Code: https://gist.github.com/CC007/afde6311db82c4f57cf8b0496f34c471

PS: sorry for posting so many issues in one day 😅

rsmckinney commented 1 year ago

Don't apologize for reporting bugs. It is the best way to improve the project! Thank you

rsmckinney commented 1 year ago

Fix available with release 2023.1.19. Thanks for reporting this!

CC007 commented 1 year ago

Fix confirmed