Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-8724

Groovy static methods with dots causes compilation error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.4.15, 2.5.2
    • None
    • None

    Description

      I have a problem with methods that have dots in their name. Here's a code example

       

      class SomeList {
      
          SomeList(String field) {
          }
      
          static SomeList "Regular name of method"() {
              println("regular method")
          }
      
          static SomeList "Name with.dot"() {
              println("method with dot")
          }
      }
      

      and i have test for it which cause compilation error:

       

       

      class SomeListTests {
      
          @Test
          def "some list test"() {
              //given
              SomeList list = new SomeList()
      
              //when
              list."Regular name of method"()
      
              //then
              //compilation error
          }
      }
      

      Even if i run it in IDEA or with ./gradlew test it crashes with error:

       

       

      Error:Groovyc: While compiling tests of example-project_test: BUG! exception in phase 'semantic analysis' in source unit '/home/alex/Projects/example-project/src/test/groovy/SomeListTests.groovy' Problem loading class SomeList
      at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:970)
      ... and so on i can drop all at comments

      BUT if i run Groovy script like this:

       

      Script:

       

      SomeList."Regular name of method"()
      SomeList."Name with.dot"()
      

      Run:

       

       

      class Main {
          public static void main(String[] args) {
              GroovyShell shell = new GroovyShell()
              shell.run(new File("""pathToFile/Script.groovy"""), Collections.emptyList())
              println "Everything is cool"
          }
      }
      

      I have everything perfect:

       

      regular method
      method with dot
      Everything is cool
      

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              dixon961 Markov Alexey
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: