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

Aliased static imports wrong in stubs

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 2.4.4
    • None
    • None

    Description

      I believe GROOVY-7366 didn't account for aliasing in imports. For example, if I have

      Application.groovy
      import static Util.hello as hi
      
      class Application {
        static void main(def args) {
          hi
        }
      }
      
      Util.groovy
      class Util {
        static void sayHello() {
          println "Hello"
        }
      }
      

      The generated stub looks like

      Application.java
      import java.lang.*;
      import java.io.*;
      import java.net.*;
      import java.util.*;
      import groovy.lang.*;
      import groovy.util.*;
      import static Util.hi;
      
      public class Application
        extends java.lang.Object  implements
          groovy.lang.GroovyObject {
      ;
      public  groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;}
      public  void setMetaClass(groovy.lang.MetaClass mc) { }
      public  java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;}
      public  java.lang.Object getProperty(java.lang.String property) { return null;}
      public  void setProperty(java.lang.String property, java.lang.Object value) { }
      public static  void main(java.lang.String... args) { }
      }
      

      When it should be like

      Application.java
      import java.lang.*;
      import java.io.*;
      import java.net.*;
      import java.util.*;
      import groovy.lang.*;
      import groovy.util.*;
      import static Util.hello;
      
      public class Application
        extends java.lang.Object  implements
          groovy.lang.GroovyObject {
      ;
      public  groovy.lang.MetaClass getMetaClass() { return (groovy.lang.MetaClass)null;}
      public  void setMetaClass(groovy.lang.MetaClass mc) { }
      public  java.lang.Object invokeMethod(java.lang.String method, java.lang.Object arguments) { return null;}
      public  java.lang.Object getProperty(java.lang.String property) { return null;}
      public  void setProperty(java.lang.String property, java.lang.Object value) { }
      public static  void main(java.lang.String... args) { }
      }
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              keegan Keegan Witt
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: