[jira] [Commented] (GROOVY-7632) Groovy named parameters static check

2018-11-14 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/GROOVY-7632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686591#comment-16686591
 ] 

ASF GitHub Bot commented on GROOVY-7632:


GitHub user paulk-asert opened a pull request:

https://github.com/apache/groovy/pull/822

GROOVY-7632: Groovy named parameters static check (initial cut of sup…

…port)

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulk-asert/groovy groovy7632

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/groovy/pull/822.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #822


commit b53eba0249b976ca3554867d78ef974e56c5f189
Author: Paul King 
Date:   2018-11-14T14:33:14Z

GROOVY-7632: Groovy named parameters static check (initial cut of support)




> Groovy named parameters static check
> 
>
> Key: GROOVY-7632
> URL: https://issues.apache.org/jira/browse/GROOVY-7632
> Project: Groovy
>  Issue Type: Improvement
>  Components: groovy-jdk, Static Type Checker
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> It would be really nice if groovy will include some annotation for type 
> checking named params.
> For example we do not know what map is expected until we go into source.
> {code:title=Annotation|borderStyle=solid}
> @Retention(RetentionPolicy.RUNTIME)
> @Target({ElementType.PARAMETER})
> public @interface NamedParams {
> NamedParam[] value();
> boolean unknowns() default false;
> @interface NamedParam {
> String value();
> Class type() default Object.class;
> int genericTypeIndex() default -1;
> String target() default "";
> boolean required() default false;
> }
> }
> {code}
> {code:title=Example Usage|borderStyle=solid}
> def foo(@NamedParams([
> @NamedParam("bar"),
> @NamedParam(value = "baz", type = String)]) Map map) {
> println map.bar
> println map.baz
> }
> foo(bar: [], baz: "")
> {code}
> In {{@CompileStatic}} case it could be used to fail the compilation if user 
> tries to get some unknown value from map, and also fail if user does not pass 
> some required argument. 
> Also it could be used to annotate map-constructors in compile-time.
> And the last one: it will be VERY useful for IDEs. 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[GitHub] groovy pull request #822: GROOVY-7632: Groovy named parameters static check ...

2018-11-14 Thread paulk-asert
GitHub user paulk-asert opened a pull request:

https://github.com/apache/groovy/pull/822

GROOVY-7632: Groovy named parameters static check (initial cut of sup…

…port)

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/paulk-asert/groovy groovy7632

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/groovy/pull/822.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #822


commit b53eba0249b976ca3554867d78ef974e56c5f189
Author: Paul King 
Date:   2018-11-14T14:33:14Z

GROOVY-7632: Groovy named parameters static check (initial cut of support)




---