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

@var etc doesnt work for a non public classes. #359

Closed gochev closed 1 year ago

gochev commented 2 years ago

Describe the bug

if you just define your class as internal in the same package as main the @var will not work - the compile will fail, and if you run it with the intellij plugin you will get NPE.

To Reproduce

import manifold.ext.props.rt.api.override;
import manifold.ext.props.rt.api.val;
import manifold.ext.props.rt.api.var;

public class Mainjava {
    public static void main(String[] args) {
        User u = new User();
        u.name = "dabe-usere"; //even this wont work.
        System.out.println(u.name); / and this
//        u.title = "neshto";

    }
}

class User {
    private String name;
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @var
    String title;
}

Expected behavior To work also for classes defined like this one.

Screenshots On maven compile image On Run image

Desktop (please complete the following information):

Additional context If I move this into a PUBLIC class like this it works

package user;

import manifold.ext.props.rt.api.var;

public class User {
    private String name;
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @var
    String title;
}

it is not because of the default package.. also tried to move the main and internal class into a package (instead of empty) its the same.

Still AMAZING work :) LOVE IT !

rsmckinney commented 2 years ago

Hi @gochev. It looks like your use-case involves a package class in the same file as the main class, right? That case appears to be broken. However, the general case of a package-private class with properties works as it should. I'll take a deeper dive into the former case. Thanks for reporting this!

rsmckinney commented 2 years ago

I've verified the general case of a package-private class with properties works as it should. The only case that does not work is when the class is a top-level class that resides in another top-level class' file. Manifold generally ignores that case everywhere; it is not likely to get fixed. Sorry.

rsmckinney commented 2 years ago

I suppose what should be done is to produce a compile error instead of causing an NPE. Expect that soon.

rsmckinney commented 1 year ago

Fixed with release 2022.1.32