[ 
https://issues.apache.org/jira/browse/GROOVY-10027?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Eric Milles reassigned GROOVY-10027:
------------------------------------

    Assignee: Eric Milles

> STC: NamedParams error for method call argument
> -----------------------------------------------
>
>                 Key: GROOVY-10027
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10027
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.5.14, 3.0.7, 4.0.0-alpha-2
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>
> Consider the following:
> {code:groovy}
> 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 {
> }
> {code}
> 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.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to