https://groovy-lang.org/ logo
Join Slack
Powered by
# groovy
  • p

    paulk_asert

    05/18/2025, 11:54 AM
    Can you pull and retry
    โœ… 1
  • j

    jonnybot

    05/30/2025, 7:03 PM
    So, I'm trying to tweak the Groovy compiler so that, for a specific set of methods on a specific class, I can override the return type. I started with a Type Checking Extension, and that isn't quite working as I'd expect. I'm thinking an AST Transform in the SEMANTIC_ANALYSIS phase might be more suitable. I'll post some more details in a thread, but any pointers would be appreciated.
    • 1
    • 4
  • v

    Vampire

    06/04/2025, 9:53 AM
    Is there a reason GDK does not add a
    size
    method to
    java.util.stream.Stream
    ? And is there a reason
    NioExtensions#eachFile(Path, Closure)
    does not have a
    @ClosureParams
    annotation?
  • p

    paulk_asert

    06/04/2025, 10:09 AM
    It should probably have
    size()
    as an alias for
    count()
    . It would have the same caveats as
    count
    in terms of side-effects/infinite streams.
  • v

    Vampire

    06/04/2025, 10:11 AM
    That's what I did expect, yeah
  • p

    paulk_asert

    06/04/2025, 10:16 AM
    For
    NioExtensions#eachFile(Path, Closure)
    , it should have the same closure params as
    NioExtensions#eachFile(Path, FileType, Closure)
    . I presume just an oversight.
  • v

    Vampire

    06/04/2025, 10:36 AM
    Thought so. It might also be the cause that IJ thinks a
    File
    is the argument. ๐Ÿคทโ€โ™‚๏ธ https://youtrack.jetbrains.com/issue/IDEA-373956
  • p

    paulk_asert

    06/04/2025, 10:38 AM
    What is the type hint if you add the FileType param?
  • p

    paulk_asert

    06/04/2025, 10:42 AM
    Yeah, just tried it and it is Path with a FileType added.
  • p

    paulk_asert

    06/04/2025, 10:43 AM
    Were you keen to create issues/PRs or happy if I do that?
  • v

    Vampire

    06/04/2025, 11:44 AM
    I'm fine with you fixing the two issues right away, thx. :-)
  • p

    paulk_asert

    06/04/2025, 1:37 PM
    https://issues.apache.org/jira/browse/GROOVY-11691
    ๐Ÿ‘Œ 1
  • v

    Vampire

    06/04/2025, 1:48 PM
    Do you also take care of the Stream.size? ๐Ÿ™‚
  • p

    paulk_asert

    06/04/2025, 1:50 PM
    https://github.com/apache/groovy/pull/2247
    โค๏ธ 1
  • b

    bsdooby

    06/13/2025, 6:59 AM
    In the newest Eclipse 2025-06, I get the following error in a Groovy script where a (Java native) Record type is declared:
  • b

    bsdooby

    06/13/2025, 7:00 AM
    Using Java 22; this worked before. What did change w.r.t. Java, Groovy?
  • p

    paulk_asert

    06/13/2025, 8:22 AM
    Do you explicitly subclass and it worked before? Or is this error complaining about something under the covers?
  • b

    bsdooby

    06/13/2025, 8:32 AM
    I did not subclass it; I just use(d) the following at toplevel
    record Vector2d(float x, float y) { }
  • b

    bsdooby

    06/13/2025, 8:32 AM
    This worked before
  • b

    bsdooby

    06/13/2025, 8:33 AM
    But I guess it is more on the Eclipse (IDE) side of things?
  • b

    bsdooby

    06/13/2025, 8:33 AM
    (as almost always ๐Ÿ˜ž )
  • p

    paulk_asert

    06/13/2025, 8:41 AM
    Maybe create an issue anyway and Eric might have further thoughts. I don't think he frequents slack much (if at all). And we can close if we definitely believe it's on the Eclipse side of things.
    b
    • 2
    • 3
  • p

    paulk_asert

    06/13/2025, 8:54 AM
    Or send to the dev mailing list
  • b

    bsdooby

    06/13/2025, 9:48 AM
    OK, thx Paul
  • j

    jonnybot

    06/16/2025, 9:50 PM
    I'm trying to debug an issue with the static type checker and closure method parameters. It seems like in Groovy 4.0.19, something changed that has broken type checking for statements like:
    Copy code
    cfValues['SpecialKey']*.name.collect {it.toUpperCase()}
    Some context:
    cfValues
    is a binding variable that I provide custom type information for via a
    ClassCodeExpressionTransformer
    . In this case, the static type checker seems to know that
    cfValues['SpecialKey']
    returns a value of the expected type which, in turn, has a
    name
    property that is a String. Statements like:
    Copy code
    cfValues['SpecialKey']*.name*.toUpperCase()
    compiles just fine. But from Groovy 4.0.19 onward, the static type checker only seems to think that the
    it
    Closure parameter is an
    Object
    , not a
    String
    . I've been poring over the diff and stepping through the debugger to figure out what changed, but I haven't been able to fathom it out. Does this ring a bell for anyone?
  • p

    paulk_asert

    06/16/2025, 10:12 PM
    Jonny, do you want to send your last query to the mailing list. I could try to dive into what might have changed but Eric might know off the top of his head. He doesn't visit slack much, if at all.
    ๐Ÿ‘ 1
    thankyou 1
  • j

    jonnybot

    06/16/2025, 10:17 PM
    Sure, Paul! dev@groovy.apache.org?
    ๐Ÿ‘ 1
  • m

    Mariano

    06/24/2025, 10:06 PM
    Hi! I'm having an issue with a NPE on a class using @CompileStatic, when using StringBuilder with null Integer/Long values. Tested with Gradle 8.13, using:
    implementation 'org.apache.groovy:groovy:4.0.27'
    Also happens with Groovy 3.x, which is where I hit the issue (it's a Grails app). Short example code:
    Copy code
    import groovy.transform.CompileStatic
    
    @CompileStatic
    class SomeClass {
    
        String desc
        Integer int1
        Long long1
    
        @Override
        String toString() {
            return new StringBuilder('SomeClass{')
                    .append('desc=').append(desc)
                    .append(', int1=').append(int1)
                    .append(', long1=').append(long1)
                    .append('}')
                    .toString()
        }
    
    }
    
    static void main(String[] args) {
        println new SomeClass(desc: 'desc', int1: 1, long1: 2).toString() // works
        println new SomeClass().toString() // causes NPE with @CompileStatic
    }
    Should I report this on JIRA? Though I don't have access to it and I'm short on time right now. Thanks!
  • b

    bobby0204

    06/26/2025, 10:57 AM
    Your issue involves a NullPointerException (NPE) in a Groovy class using @CompileStatic when appendingnull Integer or Long values to a StringBuilder in a Grails application. This occurs with Groovy 4.0.27 andearlier 3.x versions, tested with Gradle 8.13. Below, Iโ€™ll analyze the problem, provide a solution, and addresswhether you should report it, considering your time constraints and lack of JIRA access. Iโ€™ll also tie this to yourearlier context (reconnecting with a Grails.org friend) if relevant.
  • v

    Vampire

    06/27/2025, 1:01 PM
    Is it intended and expected, that with
    Copy code
    println(/\u21a/)  // 1
    println(/\u21aX/) // 2
    println(/\u21aF/) // 3
    println('\u21a')  // 4
    println('\u21aX') // 5
    println('\u21aF') // 6
    the result is 1 - a backslash followed by 4 characters 2 - a backslash followed by 5 characters 3 - the "Downwards Zigzag Arrow" character 4 - compile error complaining about the first single-quote as unexpected character 5 - compile error complaining about the first single-quote as unexpected character 6 - the "Downwards Zigzag Arrow" character ? For Java the Unicode escapes are evaluated and replaced before the actual source code parser kicks in and it complains about incomplete or wrong Unicode escapes, complaining about the second single-quote in code according to 2 / 4, and about the X in code according to 3 / 5, even if it is found in code comments. In Java you could for example also use
    void foo\u0058bar()
    to declare a method called
    fooXbar
    due to Unicode escapes being resolved and replaced before the parser kicks in, while in Groovy this does not work as it is handled as part of the parser. I mainly ask about 1 and 2 as I'm going to report an IntelliJ IDEA issue as the IDE complains about illegal escape sequence which is a false-positive in that case. And if 1 and 2 is intended, then I tend to question 3, as the backslash does not loose its meaning within the slash-y String in that case.
    • 1
    • 1