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

parameter.metaClass returns different result when parameter type is "Class<?> parameter" compared to when type is "Class parameter"

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.1
    • Fix Version/s: 2.2.2
    • Component/s: Static compilation
    • Labels:
      None

      Description

      parameter.metaClass returns different result when parameter type is "Class<?> parameter" compared to when type is "Class parameter"

      Here is example code for Groovy console to reproduce the problem:

      class ShowMcDynamic {
        MetaClass findMc(Class someClass) {
            someClass.metaClass
        }
        MetaClass findMcWithGenericsParam(Class<?> someClass) {
            someClass.metaClass
        }
      }
      def mcByDynamic = new ShowMcDynamic().findMc(String)
      def mcByDynamic2 = new ShowMcDynamic().findMcWithGenericsParam(String)
      assert mcByDynamic.theClass==String
      assert mcByDynamic2.theClass==String
      
      @groovy.transform.CompileStatic
      class ShowMcStatic {
        MetaClass findMc(Class someClass) {
            someClass.metaClass
        }
        MetaClass findMcWithGenericsParam(Class<?> someClass) {
            someClass.metaClass
        }
      }
      def mcByStatic = new ShowMcStatic().findMc(String)
      def mcByStatic2 = new ShowMcStatic().findMcWithGenericsParam(String)
      assert mcByStatic.theClass==String
      assert mcByStatic2.theClass==String
      

        Attachments

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              lhotari Lari Hotari
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: