<div dir="ltr"><div dir="ltr">On Wed, Mar 29, 2023 at 1:58 AM Red IO <<a href="mailto:redio.development@gmail.com">redio.development@gmail.com</a>> wrote:</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">The possibility to add This regardless of the Enum class should still be considered though.</div></blockquote><div><br></div><div>Can I say "me too"?? :) I've always wanted to be able to declare an instance method whose return type is the same type as the instance. In fluent API's, it would eliminate a bunch of override methods that are only there to narrow the return type.<br></div><div><br></div><div>On the enum question...<br></div><div><br></div><div>When I was programming Java before there were enums, I would homebrew my own enums.</div><div><br></div><div>When enums were invented, I thought "Great! The compiler will do all that stuff for me". I could clearly see that it was just a matter of the compiler automatically doing a transformation I was already doing manually.<br></div><div><br></div><div>Today when I want a generic enum type, I go back to homebrewing my own enums just like before, with generic parameter(s) as needed.</div><div><br></div><div>So from a practical perspective most developers probably don't understand why this shouldn't be "easy". If a developer can do it manually, the compiler should be able to do it automatically.<br></div><div><br></div><div>Also, it's kind of perplexing that the show-stopping barrier here is not with the Enum type itself, but with the EnumSet/EnumMap utility classes.</div><div><br></div><div>Regarding that problem, would it work to just add "workaround" methods like this?</div><div><br></div><div>        public static <T extends Enum<T>> EnumSet<T> noneOfGeneric(Class<? extends T> klass)</div><div><br></div><div>Even though klass has type Class<? extends T>, at compile time, you're not going to be able to specify any Class constant other than the top enum class, so no problem there, and at runtime, this method could do introspection to find the top enum class (if necessary; unlikely) and then use that.<br></div><div><br></div><div>-Archie<br></div></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">Archie L. Cobbs<br></div></div>