[GitHub] [groovy] danielsun1106 commented on pull request #1444: GROOVY-9865: Add some DGM methods for primitive arrays

2020-12-18 Thread GitBox


danielsun1106 commented on pull request #1444:
URL: https://github.com/apache/groovy/pull/1444#issuecomment-748411931


   > > How about adding `stream()` too?
   > 
   > As in `int[] arr; Arrays.stream(arr)`? I think 
`org.codehaus.groovy.vmplugin.v8.PluginDefaultGroovyMethods` covers the 
relevant cases.
   
   Thanks for your reminding. I forgot we had added `stream()`...



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] paulk-asert commented on pull request #1444: GROOVY-9865: Add some DGM methods for primitive arrays

2020-12-18 Thread GitBox


paulk-asert commented on pull request #1444:
URL: https://github.com/apache/groovy/pull/1444#issuecomment-748398454


   Yes, boxed streams are already covered. Possibly an unboxed variant, e.g. 
intStream(int[]), would also be useful.
   
   As to using the stream-based max, we could certainly consider that. For 
small arrays the overheads of setting up the stream would be slower than the 
current implementation. For large streams, there might be a gain. I am inclined 
to leave as is and make it easy for folks to do that themselves. If we had 
something like `intStream()` they could choose between `nums.max()`, 
`nums.intStream().max().asInt`, and `nums.intStream().parallel().max().asInt` 
as they felt appropriate.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] paulk-asert commented on pull request #1445: GROOVY-9662: StreamingJsonBuilder: set resolve strategy metadata

2020-12-18 Thread GitBox


paulk-asert commented on pull request #1445:
URL: https://github.com/apache/groovy/pull/1445#issuecomment-748381200


   Merged, thanks!



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Assigned] (GROOVY-9866) Inner class of superinterface cannot be found

2020-12-18 Thread Eric Milles (Jira)


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

Eric Milles reassigned GROOVY-9866:
---

Assignee: Eric Milles

> Inner class of superinterface cannot be found
> -
>
> Key: GROOVY-9866
> URL: https://issues.apache.org/jira/browse/GROOVY-9866
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.7
>Reporter: Daniil Ovchinnikov
>Assignee: Eric Milles
>Priority: Major
>
> https://github.com/dovchinnikov/groovy-bug-inner-of-superinterface 
> {noformat}
> $ groovy playground.groovy
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 11: unable to 
> resolve class Level
>  @ line 11, column 24.
>boolean isLoggable(Level level) {
>   ^
> file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 16: unable to 
> resolve class Level
>  @ line 16, column 14.
>void log(Level level, ResourceBundle bundle, String msg, Throwable 
> thrown) {}
> ^
> file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 19: unable to 
> resolve class Level
>  @ line 19, column 14.
>void log(Level level, ResourceBundle bundle, String format, Object... 
> params) {}
> ^
> 3 errors
> {noformat}



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


[GitHub] [groovy] asfgit closed pull request #1445: GROOVY-9662: StreamingJsonBuilder: set resolve strategy metadata

2020-12-18 Thread GitBox


asfgit closed pull request #1445:
URL: https://github.com/apache/groovy/pull/1445


   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles edited a comment on pull request #1444: GROOVY-9865: Add some DGM methods for primitive arrays

2020-12-18 Thread GitBox


eric-milles edited a comment on pull request #1444:
URL: https://github.com/apache/groovy/pull/1444#issuecomment-748339728


   Does it make sense to implement `max(int[])` using `IntStream`'s `max` 
method?  Like `IntStream.of(self).max().orElseThrow(() -> new 
UnsupportedOperationException(...));`?  And similarly for long and double 
arrays?  Essentially, the `max` DGM is just shorthand for 
`ints.stream().max().asInt`.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles commented on pull request #1444: GROOVY-9865: Add some DGM methods for primitive arrays

2020-12-18 Thread GitBox


eric-milles commented on pull request #1444:
URL: https://github.com/apache/groovy/pull/1444#issuecomment-748339728


   Does it make sense to implement `max(int[])` using `IntStream`'s `max` 
method?  Like `IntStream.of(self).max().orElseThrow(() -> new 
UnsupportedOperationException(...));`?  And similarly for long and double 
arrays?  Essentially, the `max` DGM is just shorthand for 
`ints.stream().max().getAsInt()`.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles commented on pull request #1444: GROOVY-9865: Add some DGM methods for primitive arrays

2020-12-18 Thread GitBox


eric-milles commented on pull request #1444:
URL: https://github.com/apache/groovy/pull/1444#issuecomment-748335694


   > How about adding `stream()` too?
   
   As in `int[] arr; Arrays.stream(arr)`?  I think 
`org.codehaus.groovy.vmplugin.v8.PluginDefaultGroovyMethods` covers the 
relevant cases.



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [groovy] eric-milles opened a new pull request #1445: GROOVY-9662: StreamingJsonBuilder: set resolve strategy metadata

2020-12-18 Thread GitBox


eric-milles opened a new pull request #1445:
URL: https://github.com/apache/groovy/pull/1445


   https://issues.apache.org/jira/browse/GROOVY-9662



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Updated] (GROOVY-9852) Result is already complete (IllegalStateException)

2020-12-18 Thread Eric Milles (Jira)


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

Eric Milles updated GROOVY-9852:

Labels: Breaking-Change breaking breaking_change  (was: Breaking-Change 
breaking_change)

> Result is already complete (IllegalStateException)
> --
>
> Key: GROOVY-9852
> URL: https://issues.apache.org/jira/browse/GROOVY-9852
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.5
> Environment: Windows 10
> OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_272-b10)
>Reporter: André Filipe Aloise
>Assignee: Eric Milles
>Priority: Major
>  Labels: Breaking-Change, breaking, breaking_change
> Fix For: 4.0.0-alpha-3
>
>  Time Spent: 40m
>  Remaining Estimate: 0h
>
> Steps:
> 1 - Consider this reproducer [https://github.com/ptomaszek/vertx-groovy]
> 2 - Edit build.gradle and change vertxVersion to '4.0.0.Beta1' (uses Groovy 
> 3.0.3)
> 3 - Edit org.example.MainGroovy and replace the code of main method with the 
> following:
> {code:java}
> Promise p = Promise.promise()
> p.future().onSuccess { println it }
> p.complete("Done with Groovy!!!"){code}
> The code runs fine.
> But, if in Step 2 the vertxVersion in build.gradle is changed to 
> '4.0.0.Beta2' (uses Groovy 3.0.5), the code from Step 3 will fail with an 
> IllegalStateException. 
> {code:java}
> Exception in thread "main" java.lang.IllegalStateException: Result is already 
> complete
>  at io.vertx.core.Promise.complete(Promise.java:67)
>  at io.vertx.core.Promise$complete$1.call(Unknown Source)
>  at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
>  at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
>  at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:139)
>  at org.example.MainGroovy.main(MainGroovy.groovy:17)
> {code}
> If you use @CompileStatic on main method with Step 3, with Beta2, it works 
> fine. The @CompileStatic is not necessary to run well with Vert.x 
> '4.0.0.Beta1'. A Java class with similar code will work using any version of 
> Vert.x (Beta1, Beta2, Beta3, CR1), so doesn't looks like a Java or Vertx 
> issue.



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


[jira] [Comment Edited] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-9662 at 12/18/20, 5:39 PM:


This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}} (as does {{Closure}}).  So by not specifying {{strategy}} 
attribute, the compiler gets the default.  Static compilation must choose a 
resolve strategy and it relies on the annotation metadata to do so.  
GROOVY-8394 and GROOVY-9283 discuss this further.  I think GROOVY-9086 is where 
the change comes from.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.call()
}
{code}



was (Author: emilles):
This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}} (as does {{Closure}}).  So by not specifying {{strategy}} 
attribute, the compiler gets the default.  Static compilation must choose a 
resolve strategy and it relies on the annotation metadata to do so.  
GROOVY-9283 discusses this further.  I think GROOVY-9086 is where the change 
comes from.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.call()
}
{code}


> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> delegate.call (...
> {code}
>  
> To reproduce the issue please checkout 
> [https://github.com/grails/grails-views/commits/bugs/groovy-9962]
>  



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


[jira] [Comment Edited] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-9662 at 12/18/20, 4:57 PM:


This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}} (as does {{Closure}}).  So by not specifying {{strategy}} 
attribute, the compiler gets the default.  Static compilation must choose a 
resolve strategy and it relies on the annotation metadata to do so.  
GROOVY-9283 discusses this further.  I think GROOVY-9086 is where the change 
comes from.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.call()
}
{code}



was (Author: emilles):
This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}} (as does {{Closure}}).  So by not specifying {{strategy}} 
attribute, the compiler gets the default.  Static compilation must choose a 
resolve strategy and it relies on the annotation metadata to do so.  
GROOVY-9283 discusses this further.  I think GROOVY-9086 is where the change 
comes from.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.class()
}
{code}


> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> delegate.call (...
> {code}
>  
> To reproduce the issue please checkout 
> [https://github.com/grails/grails-views/commits/bugs/groovy-9962]
>  



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


[jira] [Comment Edited] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-9662 at 12/18/20, 4:56 PM:


This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}} (as does {{Closure}}).  So by not specifying {{strategy}} 
attribute, the compiler gets the default.  Static compilation must choose a 
resolve strategy and it relies on the annotation metadata to do so.  
GROOVY-9283 discusses this further.  I think GROOVY-9086 is where the change 
comes from.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.class()
}
{code}



was (Author: emilles):
This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}}.  So by not specifying {{strategy}} attribute, the compiler 
gets the default.  Static compilation must choose a resolve strategy and it 
relies on the annotation metadata to do so.  GROOVY-9283 discusses this 
further.  I think GROOVY-9086 is where the change comes from.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.class()
}
{code}


> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> delegate.call (...
> {code}
>  
> To reproduce the issue please checkout 
> [https://github.com/grails/grails-views/commits/bugs/groovy-9962]
>  



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


[jira] [Comment Edited] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-9662 at 12/18/20, 4:54 PM:


This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}}.  So by not specifying {{strategy}} attribute, the compiler 
gets the default.  Static compilation must choose a resolve strategy and it 
relies on the annotation metadata to do so.  GROOVY-9283 discusses this 
further.  I think GROOVY-9086 is where the change comes from.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.class()
}
{code}



was (Author: emilles):
This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}}.  So by not specifying {{strategy}} attribute, the compiler 
gets the default.  Static compilation must choose a resolve strategy and it 
relies on the annotation metadata to do so.  GROOVY-9283 discusses this further.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.class()
}
{code}


> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> delegate.call (...
> {code}
>  
> To reproduce the issue please checkout 
> [https://github.com/grails/grails-views/commits/bugs/groovy-9962]
>  



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


[jira] [Comment Edited] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Eric Milles (Jira)


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

Eric Milles edited comment on GROOVY-9662 at 12/18/20, 4:52 PM:


This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}}.  So by not specifying {{strategy}} attribute, the compiler 
gets the default.  Static compilation must choose a resolve strategy and it 
relies on the annotation metadata to do so.  GROOVY-9283 discusses this further.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.class()
}
{code}



was (Author: emilles):
This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}}.  So by not specifying {{strategy}} attribute, the compiler 
gets the default.  Static compilation must choose a resolve strategy and it 
relies on the annotation metadata to do so.  I'll try to find the ticket where 
this was discussed further.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.class()
}
{code}


> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> delegate.call (...
> {code}
>  
> To reproduce the issue please checkout 
> [https://github.com/grails/grails-views/commits/bugs/groovy-9962]
>  



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


[jira] [Commented] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9662:
-

This is a common case where the delegation metadata does not match the runtime 
resolve strategy.  {{DelegatesTo}} has a default resolve strategy of 
{{OWNER_FIRST}}.  So by not specifying {{strategy}} attribute, the compiler 
gets the default.  Static compilation must choose a resolve strategy and it 
relies on the annotation metadata to do so.  I'll try to find the ticket where 
this was discussed further.

{code:groovy}
void test(@DelegatesTo(value=Type) block) {
  block.resolveStrategy = Closure.DELEGATE_FIRST
  block.delegate = new Type()
  block.class()
}
{code}


> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> delegate.call (...
> {code}
>  
> To reproduce the issue please checkout 
> [https://github.com/grails/grails-views/commits/bugs/groovy-9962]
>  



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


[jira] [Commented] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Jeff Scott Brown (Jira)


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

Jeff Scott Brown commented on GROOVY-9662:
--

The project at https://github.com/jeffbrown/groovy9662 represents one of the 
scenarios we have had trouble with.

https://github.com/jeffbrown/groovy9662/blob/f823bec082aa59fc1e6166fc2bf71390c0a025a5/lib/src/main/groovy/groovy9662/MyCustomDelegate.groovy

{code:title=lib/src/main/groovy/groovy9662/MyCustomDelegate.groovy|borderStyle=solid}
package groovy9662

class MyCustomDelegate {
String getMessage() {
'Message From Closure Delegate'
}
}
{code}

https://github.com/jeffbrown/groovy9662/blob/f823bec082aa59fc1e6166fc2bf71390c0a025a5/lib/src/main/groovy/groovy9662/Library.groovy

{code:title=lib/src/main/groovy/groovy9662/Library.groovy|borderStyle=solid}

package groovy9662

class Library {

String invokeClosure(@DelegatesTo(value = MyCustomDelegate) Closure c) {
c.resolveStrategy = Closure.DELEGATE_FIRST
c.delegate = new MyCustomDelegate()
c()
}

String doSomeWork() {
invokeClosure {
// this will be dispatched to the delegate
// as expected because of the code above
// inside of the invokeClosure method
// which is setting the strategy to DELEGATE_FIRST
getMessage()
}
}

String getMessage() {
'Message From Closure Owner (Library)'
}

}
{code}

https://github.com/jeffbrown/groovy9662/blob/f823bec082aa59fc1e6166fc2bf71390c0a025a5/lib/src/main/groovy/groovy9662/LibraryCompileStatic.groovy

{code:title=lib/src/main/groovy/groovy9662/LibraryCompileStatic.groovy|borderStyle=solid}
package groovy9662

import groovy.transform.CompileStatic

@CompileStatic
class LibraryCompileStatic {

String invokeClosure(@DelegatesTo(value = MyCustomDelegate) Closure c) {
// this resolve strategy does not have an affect
// because the closure has been statically
// compiled to delegate to the owner, possibly
// because that is the default value of the strategy
// attribute in @DelegatesTo.
c.resolveStrategy = Closure.DELEGATE_FIRST
c.delegate = new MyCustomDelegate()
c()
}

String doSomeWork() {
invokeClosure {
// this will be dispatched to the owner even
// thou the invokeClosure method is setting
// strategy to DELEGATE_FIRST.
getMessage()
}
}

String getMessage() {
'Message From Closure Owner (Library)'
}
}
{code}

https://github.com/jeffbrown/groovy9662/blob/f823bec082aa59fc1e6166fc2bf71390c0a025a5/lib/src/test/groovy/groovy9662/LibraryTest.groovy

{code:title=lib/src/test/groovy/groovy9662/LibraryTest.groovy|borderStyle=solid}
package groovy9662

import spock.lang.Specification

class LibraryTest extends Specification {

// this test passes
def "test dynamically dispatched library"() {
expect:
new Library().doSomeWork() == 'Message From Closure Delegate'
}

// this test fails
def "test statically  dispatched library"() {
expect:
new LibraryCompileStatic().doSomeWork() == 'Message From Closure 
Delegate'
}
}
{code}

> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working 

[GitHub] [groovy] danielsun1106 commented on pull request #1444: GROOVY-9865: Add some DGM methods for primitive arrays

2020-12-18 Thread GitBox


danielsun1106 commented on pull request #1444:
URL: https://github.com/apache/groovy/pull/1444#issuecomment-748098734


   +1
   
   How about  adding `stream()` too?
   



This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Comment Edited] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Puneet Behl (Jira)


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

Puneet Behl edited comment on GROOVY-9662 at 12/18/20, 1:48 PM:


This is also happening with Grails Framework after updating to Groovy 2.5.14, 
the following code does not behave the same with `CompileStatic`:
{code:java}
import groovy.json.JsonOutput
import groovy.json.StreamingJsonBuilder
import groovy.transform.CompileStatic
import org.springframework.http.HttpMethod
import org.springframework.validation.ObjectError

@CompileStatic
class VndErrorJsonRenderer {

final String LOGREF_ATTRIBUTE = 'logref'
final String MESSAGE_ATTRIBUTE = "message"
final String PATH_ATTRIBUTE = "path"
final String RESOURCE_ATTRIBUTE = "resource"
final String HREF_ATTRIBUTE = "href"
final String LINKS_ATTRIBUTE = "_links"

Writer targetWriter = new StringWriter()

void render() {

StreamingJsonBuilder writer = new StreamingJsonBuilder(targetWriter)

writer.call { ObjectError oe->
writer
call(LOGREF_ATTRIBUTE, "logref")
call(MESSAGE_ATTRIBUTE, "msg")
call(PATH_ATTRIBUTE, "http://localhost:8080;)
call(LINKS_ATTRIBUTE) {
call(RESOURCE_ATTRIBUTE) {
call(HREF_ATTRIBUTE, "path")
}
}

}
targetWriter.flush()
}
}

def vndErrorJsonRenderer = new VndErrorJsonRenderer()
vndErrorJsonRenderer.render()

JsonOutput.prettyPrint(vndErrorJsonRenderer.targetWriter.toString())

{code}


was (Author: behlp):
This is also happening with Grails Framework after updating to Groovy 2.5.14, 
the following code does not behave the same with `CompileStatic`:
{code:java}
import groovy.json.JsonOutput
import groovy.json.StreamingJsonBuilder
import groovy.transform.CompileStatic
import org.springframework.http.HttpMethod
import org.springframework.validation.ObjectError@CompileStatic
class VndErrorJsonRenderer {final String LOGREF_ATTRIBUTE = 'logref'
final String MESSAGE_ATTRIBUTE = "message"
final String PATH_ATTRIBUTE = "path"
final String RESOURCE_ATTRIBUTE = "resource"
final String HREF_ATTRIBUTE = "href"
final String LINKS_ATTRIBUTE = "_links"Writer targetWriter = new 
StringWriter()void render() {StreamingJsonBuilder writer = new 
StreamingJsonBuilder(targetWriter)writer.call { ObjectError oe->
writer
call(LOGREF_ATTRIBUTE, "logref")
call(MESSAGE_ATTRIBUTE, "msg")
call(PATH_ATTRIBUTE, "http://localhost:8080;)
call(LINKS_ATTRIBUTE) {
call(RESOURCE_ATTRIBUTE) {
call(HREF_ATTRIBUTE, "path")
}
}}
targetWriter.flush()
}
}def vndErrorJsonRenderer = new VndErrorJsonRenderer()
vndErrorJsonRenderer.render()JsonOutput.prettyPrint(vndErrorJsonRenderer.targetWriter.toString())

{code}

> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> delegate.call (...
> {code}
>  
> To reproduce the issue please checkout 
> 

[jira] [Comment Edited] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Puneet Behl (Jira)


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

Puneet Behl edited comment on GROOVY-9662 at 12/18/20, 1:46 PM:


This is also happening with Grails Framework after updating to Groovy 2.5.14, 
the following code does not behave the same with `CompileStatic`:
{code:java}
import groovy.json.JsonOutput
import groovy.json.StreamingJsonBuilder
import groovy.transform.CompileStatic
import org.springframework.http.HttpMethod
import org.springframework.validation.ObjectError@CompileStatic
class VndErrorJsonRenderer {final String LOGREF_ATTRIBUTE = 'logref'
final String MESSAGE_ATTRIBUTE = "message"
final String PATH_ATTRIBUTE = "path"
final String RESOURCE_ATTRIBUTE = "resource"
final String HREF_ATTRIBUTE = "href"
final String LINKS_ATTRIBUTE = "_links"Writer targetWriter = new 
StringWriter()void render() {StreamingJsonBuilder writer = new 
StreamingJsonBuilder(targetWriter)writer.call { ObjectError oe->
writer
call(LOGREF_ATTRIBUTE, "logref")
call(MESSAGE_ATTRIBUTE, "msg")
call(PATH_ATTRIBUTE, "http://localhost:8080;)
call(LINKS_ATTRIBUTE) {
call(RESOURCE_ATTRIBUTE) {
call(HREF_ATTRIBUTE, "path")
}
}}
targetWriter.flush()
}
}def vndErrorJsonRenderer = new VndErrorJsonRenderer()
vndErrorJsonRenderer.render()JsonOutput.prettyPrint(vndErrorJsonRenderer.targetWriter.toString())

{code}


was (Author: behlp):
This is also happening with Grails Framework after updating to Groovy 2.5.14, 
the following code does not behave the same with `CompileStatic`:
{code}

import groovy.json.JsonOutput

import groovy.json.StreamingJsonBuilder

import groovy.transform.CompileStatic

import org.springframework.http.HttpMethod

import org.springframework.validation.ObjectError

 

@CompileStatic

class VndErrorJsonRenderer { 

    final String LOGREF_ATTRIBUTE = 'logref'

    final String MESSAGE_ATTRIBUTE = "message"

    final String PATH_ATTRIBUTE = "path"

    final String RESOURCE_ATTRIBUTE = "resource"

    final String HREF_ATTRIBUTE = "href"

    final String LINKS_ATTRIBUTE = "_links"

    Writer targetWriter = new StringWriter()

 

    void render() { 

        StreamingJsonBuilder writer = new StreamingJsonBuilder(targetWriter)

        writer.call *{* ObjectError oe*->*

                **                writer

                call(LOGREF_ATTRIBUTE, "logref")

                call(MESSAGE_ATTRIBUTE, "msg")

                call(PATH_ATTRIBUTE, "http://localhost:8080;)

                call(LINKS_ATTRIBUTE) *{*

                    **                    call(RESOURCE_ATTRIBUTE) *{*

                        **                        call(HREF_ATTRIBUTE, "path")

                    *}*

                *}*

        *}*

        **        targetWriter.flush()

    }

}

 

def vndErrorJsonRenderer = new VndErrorJsonRenderer()

vndErrorJsonRenderer.render()

 

JsonOutput._prettyPrint_(vndErrorJsonRenderer.targetWriter.toString())

 


{code}

> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> 

[jira] [Commented] (GROOVY-9662) Groovy 3.0.5: Closure delegate is not working properly

2020-12-18 Thread Puneet Behl (Jira)


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

Puneet Behl commented on GROOVY-9662:
-

This is also happening with Grails Framework after updating to Groovy 2.5.14, 
the following code does not behave the same with `CompileStatic`:
{code}

import groovy.json.JsonOutput

import groovy.json.StreamingJsonBuilder

import groovy.transform.CompileStatic

import org.springframework.http.HttpMethod

import org.springframework.validation.ObjectError

 

@CompileStatic

class VndErrorJsonRenderer { 

    final String LOGREF_ATTRIBUTE = 'logref'

    final String MESSAGE_ATTRIBUTE = "message"

    final String PATH_ATTRIBUTE = "path"

    final String RESOURCE_ATTRIBUTE = "resource"

    final String HREF_ATTRIBUTE = "href"

    final String LINKS_ATTRIBUTE = "_links"

    Writer targetWriter = new StringWriter()

 

    void render() { 

        StreamingJsonBuilder writer = new StreamingJsonBuilder(targetWriter)

        writer.call *{* ObjectError oe*->*

                **                writer

                call(LOGREF_ATTRIBUTE, "logref")

                call(MESSAGE_ATTRIBUTE, "msg")

                call(PATH_ATTRIBUTE, "http://localhost:8080;)

                call(LINKS_ATTRIBUTE) *{*

                    **                    call(RESOURCE_ATTRIBUTE) *{*

                        **                        call(HREF_ATTRIBUTE, "path")

                    *}*

                *}*

        *}*

        **        targetWriter.flush()

    }

}

 

def vndErrorJsonRenderer = new VndErrorJsonRenderer()

vndErrorJsonRenderer.render()

 

JsonOutput._prettyPrint_(vndErrorJsonRenderer.targetWriter.toString())

 


{code}

> Groovy 3.0.5: Closure delegate is not working properly
> --
>
> Key: GROOVY-9662
> URL: https://issues.apache.org/jira/browse/GROOVY-9662
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 3.0.2, 3.0.3, 3.0.4, 3.0.5, 2.5.14
>Reporter: Puneet Behl
>Assignee: Eric Milles
>Priority: Major
> Attachments: JsonViewWritableScript.groovy, StreamingJsonBuilder.java
>
>
> In Grails Views, we are using closures to generate JSON using 
> `StreamingJsonBuilder`. The HAL implementation for an entity now generates an 
> incorrect JSON after updating to Groovy 3.
>  
> Here is the problem code snipped from 
> \{{grails.plugin.json.view.api.internal.DefaultHalViewHelper#links}}: 
> {code:java}
> jsonDelegate.call(LINKS_ATTRIBUTE) {
> call(SELF_ATTRIBUTE) {
> call HREF_ATTRIBUTE, viewHelper.link(resource: object, method: 
> HttpMethod.GET, absolute: true)
> call HREFLANG_ATTRIBUTE, locale.toString()
> call TYPE_ATTRIBUTE, contentType
> }
> Set links = getLinks(object)
> for (link in links) {
> call(link.rel) {
> call HREF_ATTRIBUTE, link.href
> call HREFLANG_ATTRIBUTE, link.hreflang?.toString() ?: 
> locale.toString()
> def linkType = link.contentType
> if (linkType) {
> call TYPE_ATTRIBUTE, linkType
> }
> }
> }
> }
> {code}
>  
> Although the `resolveStatergy` for the closures is `DELEGATE_FIRST` but I 
> believe that is not working correctly because it works if I change the above 
> to:
> {code:java}
> delegate.call (...
> {code}
>  
> To reproduce the issue please checkout 
> [https://github.com/grails/grails-views/commits/bugs/groovy-9962]
>  



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


[jira] [Created] (GROOVY-9866) Inner class of superinterface cannot be found

2020-12-18 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9866:
--

 Summary: Inner class of superinterface cannot be found
 Key: GROOVY-9866
 URL: https://issues.apache.org/jira/browse/GROOVY-9866
 Project: Groovy
  Issue Type: Bug
Affects Versions: 3.0.7
Reporter: Daniil Ovchinnikov


https://github.com/dovchinnikov/groovy-bug-inner-of-superinterface 

{noformat}
$ groovy playground.groovy
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 11: unable to 
resolve class Level
 @ line 11, column 24.
   boolean isLoggable(Level level) {
  ^

file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 16: unable to 
resolve class Level
 @ line 16, column 14.
   void log(Level level, ResourceBundle bundle, String msg, Throwable 
thrown) {}
^

file:~/groovy-bug-inner-of-superinterface/com/foo/C.groovy: 19: unable to 
resolve class Level
 @ line 19, column 14.
   void log(Level level, ResourceBundle bundle, String format, Object... 
params) {}
^

3 errors
{noformat}




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