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

Import alias introduces weird property

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4.12
    • None
    • Compiler
    • None

    Description

      com/foo/Bar.java
      package com.foo;
      public class Bar {
          public static Object getSome() {return 42;}
      }
      
      playground.groovy
      import static com.foo.Bar.some as getAbc
      println abc // 42
      println getAbc
      println getGetAbc()
      

      AFAIU an alias introduces property into a file which is being compiled (in this case getAbc and getGetAbc() become valid). This works as expected.
      But abc should fail with MPE, instead it's actually resolved into a getSome().
      This happens when alias is itself a valid getter name.

      Is it a bug or a feature?

      One more thing to consider.
      Given abc is valid, getAbc() should be valid too. Instead it behaves like getAbc.call().

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              daniilo Daniil Ovchinnikov
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: