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

STC: NamedParams error for method call argument

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      import groovy.transform.NamedParam
      import groovy.transform.NamedParams
      
      @groovy.transform.TypeChecked
      //@Configuration
      class Config {
        //@Value
        String indexName
        //@Bean
        ResultType resultType() {  }
        //@Bean
        def facetApplier() { new FacetApplier(index:indexName, resultType:resultType()) }
      }
      //@Component
      class FacetApplier {
          protected final String index
          protected final ResultType resultType
      
          FacetApplier(@NamedParams([
              @NamedParam(value='index', type=String, required=true),
              @NamedParam(value='resultType', type=ResultType, required=true)]) Map props)
          {
              this.index = props.index
              this.resultType = props.resultType
          }
      }
      class ResultType {
      }
      

      Constructor call expression "new FacetApplier(index:indexName, resultType:resultType())" has static type checking error for "resultType" named parameter. [Static type checking] - parameter for named arg 'resultType' has type 'java.lang.Object' but expected 'ResultType'.

      If resultType() is cast or replaced with a variable, the error goes away.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h