Can generating an implementation of a public interface create public methods?

Issue #1464 new
Aidan Harding created an issue

If I write a public interface e.g.

public interface Function {
    Object call(Object o);
}

And then add a private inner class to implement it:

public class GenerateImplementation {

    private class MyFunction implements Function {
    }

}

Then, use the IDE to “Implement Methods”, the visibility of the new method matches the enclosing class:

public class GenerateImplementation {

    private class MyFunction implements Function {
        private Object call(Object o) {
            return null;
        }
    }
}

This is not actually valid Apex, as the methods implementation a public interface must themselves be public.

It’s easy enough to fix, but it’s something I regularly forget to do until I push/deploy and get an error back from the server. It would be really nice to have it generate as public.

Comments (1)

  1. Theodoor van Donge

    Yes indeed, a implementation of a method in a private (inner) class should be at least always public

  2. Log in to comment