Mixin
Mixin copied to clipboard
Accessor merging should use the widest visibility level of all accessors
Let's say you have two mixins from two mods:
// mod 1
@Mixin(Foo.class)
public interface FooAccessor {
@Accessor
Bar getBar(); // public
}
// mod 2
@Mixin(Foo.class)
public abstract class FooMixin {
@Accessor
abstract Bar getBar(); // package-private
void doSomething() {
Bar bar = getBar();
// ...
}
}
it could happen that after accessor merging, the package-private version of the accessor is the one that is created, rather than the public one. This means that when mod 1 tries to use the accessor from a different class, it can generate an IllegalAccessError. Mixin should use the least restrictive visibility level of all accessors when merging them to avoid this issue (or just always make them public).