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

strange error accessing property following method call in @Category class, invokeStaticMissingMethod

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • None
    • 1.6.4, 1.7-beta-1
    • None
    • None
    • groovy eclipse 1.6.3

    Description

      The following code fails

      //////////////////////////////////////////////////////////////////////////////

      @Category(Guy)
      class Naming {
      	String getTypeName() {
      		if(this.getType() != null)
      			this.getType().name
      		else
      			""
      	}
      }
      
      interface Guy {
      //	String getName()
      	Type getType()
      }
      
      class Type {
      	String name
      }
      
      class MyGuyver implements Guy {
      	Type type
      //	String getName() {return "ver"}
      }
      
      def atype = new Type(name: 'String')
      def onetest = new MyGuyver(type:atype)
      
      //assert onetest.getName() == 'ver'
      
      use(Naming) {
      	assert onetest.getTypeName() == onetest.getType().getName()
      }
      

      //////////////////////////////////////////////////////////////////////////////

      The problem is the line 'this.getType().name' in the method Naming.getTypeName()
      The exception is :

      Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: static Naming.getType() is applicable for argument types: () values: []
      at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1364)
      at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1350)
      at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.callStatic(StaticMetaClassSite.java:47)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:48)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:167)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:171)
      at Naming.getTypeName(test.groovy:9)

      If we use the getter method getName() instead of 'name' property accessor it works

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            lwi Louis Foucart
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: