[jira] [Commented] (GROOVY-7865) Better error message in the presence of Generics arity errors

2016-06-23 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-7865:


GitHub user paulk-asert opened a pull request:

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

GROOVY-7865: Better error message and earlier detection of Generics errors

reworked version

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

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

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

https://github.com/apache/groovy/pull/353.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 #353


commit 2b8d488f0519add9aef73f59d998769f8808cbfe
Author: paulk 
Date:   2016-06-17T08:38:25Z

GROOVY-7865: Better error message in the presence of Generics arity errors 
(spike)




> Better error message in the presence of Generics arity errors
> -
>
> Key: GROOVY-7865
> URL: https://issues.apache.org/jira/browse/GROOVY-7865
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.7
>Reporter: Paul King
>
> Currently there are many places in the codebase which make assumptions that 
> they are working with valid generics information. Generics information is 
> checked but not until the classgen phase. Consequently, we get a very 
> uninformative ArrayIndexOutOfBoundsException from the compiler - either along 
> with or instead of the subsequent generics checking. These are all examples 
> which should fail compilation since I have intentionally tried to instantiate 
> the generics type with an incorrect number of parameters. It is just the 
> error message which is not currently useful and masking the subsequent 
> message that would occur had not the exception got in the way. 
> Example with TraitComposer:
> {code}
> class MyNames implements Queue { }
> // java.lang.ArrayIndexOutOfBoundsException: 1
> // TraitComposer calls GenericsUtils.parameterizeType()
> // which calls GenericsUtils.createGenericsSpec()
> {code}
> Example with StaticTypeCheckingVisitor:
> {code}
> @CompileStatic
> def foo() {
>   List ss = new LinkedList()
> }
> // => java.lang.ArrayIndexOutOfBoundsException: 1
> {code}
> Example with Verifier:
> {code}
> class MyNames extends Queue { }
> {code}
> which gives
> {noformat}
> 2 compilation errors:
> The class java.util.Queue refers to the class java.util.Queue and uses 2 
> parameters, but the referred class needs 1
>  at line: 5, column: 23
> Exception thrown
> java.lang.ArrayIndexOutOfBoundsException: 1
>   at 
> org.codehaus.groovy.ast.tools.GenericsUtils.createGenericsSpec(GenericsUtils.java:410)
> {noformat}
> So we get one error from the generics checking but then continue on to the 
> Verifier.
> I suspect the fix for this is to move just the arity checking part of that 
> visitor to an earlier phase.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7865) Better error message in the presence of Generics arity errors

2016-06-17 Thread ASF GitHub Bot (JIRA)

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

ASF GitHub Bot commented on GROOVY-7865:


GitHub user paulk-asert opened a pull request:

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

GROOVY-7865: Better error message in the presence of Generics arity e…

…rrors (spike)

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

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

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

https://github.com/apache/groovy/pull/352.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 #352


commit d4250bc36893ccfa4a575c260e4df586f2c761fa
Author: paulk 
Date:   2016-06-17T08:38:25Z

GROOVY-7865: Better error message in the presence of Generics arity errors 
(spike)




> Better error message in the presence of Generics arity errors
> -
>
> Key: GROOVY-7865
> URL: https://issues.apache.org/jira/browse/GROOVY-7865
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.7
>Reporter: Paul King
>
> Currently there are many places in the codebase which make assumptions that 
> they are working with valid generics information. Generics information is 
> checked but not until the classgen phase. Consequently, we get a very 
> uninformative ArrayIndexOutOfBoundsException from the compiler - either along 
> with or instead of the subsequent generics checking. These are all examples 
> which should fail compilation since I have intentionally tried to instantiate 
> the generics type with an incorrect number of parameters. It is just the 
> error message which is not currently useful and masking the subsequent 
> message that would occur had not the exception got in the way. 
> Example with TraitComposer:
> {code}
> class MyNames implements Queue { }
> // java.lang.ArrayIndexOutOfBoundsException: 1
> // TraitComposer calls GenericsUtils.parameterizeType()
> // which calls GenericsUtils.createGenericsSpec()
> {code}
> Example with StaticTypeCheckingVisitor:
> {code}
> @CompileStatic
> def foo() {
>   List ss = new LinkedList()
> }
> // => java.lang.ArrayIndexOutOfBoundsException: 1
> {code}
> Example with Verifier:
> {code}
> class MyNames extends Queue { }
> {code}
> which gives
> {noformat}
> 2 compilation errors:
> The class java.util.Queue refers to the class java.util.Queue and uses 2 
> parameters, but the referred class needs 1
>  at line: 5, column: 23
> Exception thrown
> java.lang.ArrayIndexOutOfBoundsException: 1
>   at 
> org.codehaus.groovy.ast.tools.GenericsUtils.createGenericsSpec(GenericsUtils.java:410)
> {noformat}
> So we get one error from the generics checking but then continue on to the 
> Verifier.
> I suspect the fix for this is to move just the arity checking part of that 
> visitor to an earlier phase.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (GROOVY-7865) Better error message in the presence of Generics arity errors

2016-06-16 Thread Paul King (JIRA)

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

Paul King commented on GROOVY-7865:
---

I should point out that any transforms that use 
{{GenericsUtils.parameterizeType()}} or {{GenericsUtils.createGenericsSpec()}} 
are also subject to this error. There are currently about 20 such usages.

> Better error message in the presence of Generics arity errors
> -
>
> Key: GROOVY-7865
> URL: https://issues.apache.org/jira/browse/GROOVY-7865
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.4.7
>Reporter: Paul King
>
> Currently there are many places in the codebase which make assumptions that 
> they are working with valid generics information. Generics information is 
> checked but not until the classgen phase. Consequently, we get a very 
> uninformative ArrayIndexOutOfBoundsException from the compiler - either along 
> with or instead of the subsequent generics checking. These are all examples 
> which should fail compilation since I have intentionally tried to instantiate 
> the generics type with an incorrect number of parameters. It is just the 
> error message which is not currently useful and masking the subsequent 
> message that would occur had not the exception got in the way. 
> Example with TraitComposer:
> {code}
> class MyNames implements Queue { }
> // java.lang.ArrayIndexOutOfBoundsException: 1
> // TraitComposer calls GenericsUtils.parameterizeType()
> // which calls GenericsUtils.createGenericsSpec()
> {code}
> Example with StaticTypeCheckingVisitor:
> {code}
> @CompileStatic
> def foo() {
>   List ss = new LinkedList()
> }
> // => java.lang.ArrayIndexOutOfBoundsException: 1
> {code}
> Example with Verifier:
> {code}
> class MyNames extends Queue { }
> {code}
> which gives
> {noformat}
> 2 compilation errors:
> The class java.util.Queue refers to the class java.util.Queue and uses 2 
> parameters, but the referred class needs 1
>  at line: 5, column: 23
> Exception thrown
> java.lang.ArrayIndexOutOfBoundsException: 1
>   at 
> org.codehaus.groovy.ast.tools.GenericsUtils.createGenericsSpec(GenericsUtils.java:410)
> {noformat}
> So we get one error from the generics checking but then continue on to the 
> Verifier.
> I suspect the fix for this is to move just the arity checking part of that 
> visitor to an earlier phase.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)