Fork me on GitHub
#clojure
<
2023-08-20
>
ericdallo23:08:57

Is there already a issue in Clojure's Jira where I can follow about implementations of interfaces with gen-class not generating default methods?

Alex Miller (Clojure team)00:08:00

Why would you need that? Do you mean methods that override default methods?

Alex Miller (Clojure team)00:08:34

I guess, I don’t understand what you’re trying to do

ericdallo00:08:34

when using gen-class https://github.com/clojure-lsp/clojure-lsp-intellij/blob/master/src/main/clojure/com/github/clojure_lsp/intellij/extension/commenter.clj#L15 for example, if I don't implement getLineCommentPrefixes which is a default method https://github.com/JetBrains/intellij-community/blob/idea/232.8660.185/platform/core-api/src/com/intellij/lang/Commenter.java#L36, I get a UnsuportedOperationException when that generated class is used (and calls that method)

ericdallo00:08:17

to workaround that, I implement the default method and do the same is done in the default interface

ericdallo00:08:58

I thought that was a known issue

Alex Miller (Clojure team)01:08:15

Doesn’t ring a bell, ask Clojure question welcome

👍 2
lread02:08:59

fwiw, I just tend to write a little .java when I find myself wrestling with gen-class.

ericdallo02:08:55

I prefer use gen-class when I need to call other clojure namespaces, but yeah, gen-class is tricky

👍 4
ericdallo01:08:18

Hey @U064X3EF3, just to let you know, I took a look at Clojure code and managed to create a test + a possible one line fix :) From what I understood from the contribution guidelines I should wait for the vetted + release scheduling to provide a dev patch right? (already signed the contributor agreement) LMK if I'm missing anything, would love to contribute to Clojure :)

Alex Miller (Clojure team)02:08:17

you can supply a patch now, per https://clojure.org/dev/dev#_becoming_a_contributor - there's a link there to request a contributor account

ericdallo02:08:47

Attached the patch, thanks!

ericdallo15:08:06

Hey @U064X3EF3 I hope it's ok to ask here, any tips on how to fill this https://github.com/ericdallo/Clojure/blob/CLJ-2794/src/clj/clojure/genclass.clj#L419 local, I want to know if the user defined a function for that genclass, but not sure I can use a resolve or something there (I hope I don't need to use the GeneratorAdapter instructions, that looks complex 😅) I know I can (var-name mname) to the the var name, but how to check if that is really bound in user's code

ericdallo15:08:16

Yeah, I think it will be required to add a instruction that checks if the var isBound and then add or not the method

Alex Miller (Clojure team)15:08:43

don't have time to look atm, if you get stuck, just update the ticket with where you're stuck

ericdallo15:08:53

Sure, thanks!

ericdallo19:08:02

I managed to make it work and attached the patch, thanks!

Alex Miller (Clojure team)19:08:56

thx, will probably not look at it until after 1.12 as we are trying to start closing things down towards a release

ericdallo19:08:44

no problem, glad I helped somehow :)

gratitude 2