You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/10/25 15:42:00 UTC

[jira] [Updated] (GROOVY-8179) Map-style constructor call, inner class and static compilation

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

Eric Milles updated GROOVY-8179:
--------------------------------
    Fix Version/s: 2.5.15

> Map-style constructor call, inner class and static compilation
> --------------------------------------------------------------
>
>                 Key: GROOVY-8179
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8179
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 2.4.11
>            Reporter: Mauro Molinari
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 2.5.15, 4.0.0-beta-1, 3.0.9
>
>
> Consider the following:
> {code}
> package c 
> import groovy.transform.CompileStatic
> @CompileStatic
> class C { 
> 	class MyBean { 
> 		String foo 
> 		int bar 
> 	} 
> 	class AnotherClass { 
> 		int createInt() { 
> 			return 1 
> 		} 
> 		String createString() { 
> 			return 'foo' 
> 		} 
> 	} 
> 	
> 	void doSomething() { 
> 		def a = new AnotherClass() 
> 		def b = new MyBean(foo: a.createString()) 
> 	} 
> }
> {code}
> The compiler complains on {{new MyBean(...)}}:
> {noformat}
> \src\main\groovy\c\C.groovy: 22: [Static type checking] - Cannot find matching method c.C$MyBean#<init>(c.C, java.util.LinkedHashMap <java.lang.String, java.lang.String>). Please check if the declared type is right and if the method exists.
>  @ line 22, column 11.
> {noformat}
> Changing it to {{new C.MyBean(...)}} works though.



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