[ https://issues.apache.org/jira/browse/GROOVY-11737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King reassigned GROOVY-11737: ---------------------------------- Assignee: Paul King > Understanding Groovy main method priority overloading. > ------------------------------------------------------ > > Key: GROOVY-11737 > URL: https://issues.apache.org/jira/browse/GROOVY-11737 > Project: Groovy > Issue Type: Bug > Reporter: Georgii Ustinov > Assignee: Paul King > Priority: Major > > Good afternoon > > I am currently trying to support instance main methods inside IntelliJ IDEA > groovy plugin as a part of Groovy 5 release, however, I can’t find any > specification of how it works. > > I have found that the feature was implemented here - > [https://github.com/apache/groovy/pull/1910/files]. > > Looking into the source code - > [https://github.com/paulk-asert/groovy/blob/90480bfade8c20f935311055e2ceb85288870605/src/main/java/groovy/lang/GroovyShell.java#L275] > I can see the following order: > > 1) static void main(String[] args); > 2) void main(String[] args); > 3) static void main(args); > 4) void main(args); > 5) static void main(); > 6) void main(); > > The problem is that it doesn’t correspond to the reality. > > Let’s consider the following code main.groovy > > > {code:java} > void main(args) { > println "1" > } > > static void main() { > println "2" > } > {code} > > > If I run > {code:java} > groovy main.groovy{code} > 1 will be printed (and it looks correct according to the semantics), > But if I change example: > > > {code:java} > void main(String[] args) { > println "1" > } > > static void main() { > println "2" > } > {code} > 2 will be printed (and thus the order in the code is violated). But if I run > {code:java} > groovy main.groovy someArg{code} > , then 1 will be printed > > Could you, please, provide the correct main method order resolution? -- This message was sent by Atlassian Jira (v8.20.10#820010)