[jira] [Updated] (GROOVY-9652) SC: ClassCastException for comparison to single-character string literal in closure

2020-09-09 Thread Paul King (Jira)


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

Paul King updated GROOVY-9652:
--
Fix Version/s: 2.5.14

> SC: ClassCastException for comparison to single-character string literal in 
> closure
> ---
>
> Key: GROOVY-9652
> URL: https://issues.apache.org/jira/browse/GROOVY-9652
> Project: Groovy
>  Issue Type: Bug
>Affects Versions: 2.5.13
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-alpha-1, 2.5.14, 3.0.6
>
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> This started failing with Groovy 2.5.13:
> {code:groovy}
> class Node {
>   String name, text
> }
> class Root implements Iterable {
>   @Override
>   Iterator iterator() {
> return [
>   new Node(name: 'term', text: 'foo'),
>   new Node(name: 'dash', text: '-'  ),
>   new Node(name: 'term', text: 'bar')
> ].iterator()
>   }
> }
> @groovy.transform.CompileStatic
> void test() {
>   Root root = new Root()
>   root[0].with {
> assert name == 'term'
> assert text == 'foo'
>   }
>   root[1].with {
> assert name == 'dash'
> assert text == '-' // GroovyCastException: Cannot cast object 
> 'script@b91d8c4' with class 'script' to class 'bugs.Node'
>   }
> }
> test()
> {code}
> Adding a cast to String in front of "-" fixes and {{@CompileDynamic}} also 
> fixes.  I'm guessing {{@TypeChecked}} would not have the issue.  I noticed 
> some changes in {{BinaryExpressionTransformer#tryOptimizeCharComparison}} 
> that may be relevant.



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


[jira] [Updated] (GROOVY-9706) Groovy 3.0.5 varargs [Static type checking] - Cannot find matching method

2020-09-09 Thread Paul King (Jira)


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

Paul King updated GROOVY-9706:
--
Fix Version/s: 2.5.14

> Groovy 3.0.5 varargs [Static type checking] - Cannot find matching method
> -
>
> Key: GROOVY-9706
> URL: https://issues.apache.org/jira/browse/GROOVY-9706
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 3.0.5
> Environment: Java version AdoptOpenJDK (build 25.262-b10, mixed mode)
> Gradle version 6.6.1
> Groovy version 3.0.5 
>Reporter: Chiang Seng Chang
>Assignee: Paul King
>Priority: Major
> Fix For: 4.0.0-alpha-1, 2.5.14, 3.0.6
>
> Attachments: g3varargs.tar.gz
>
>
> Compile error: [Static type checking] - Cannot find matching method 
> foo.Foo#vfunc(java.lang.String, java.lang.Integer).
> If i is declared as int, then it compiles okay.
>  
> {noformat}
> package foo
> import groovy.transform.CompileStatic
> @CompileStatic
> class Foo {
> private void vfunc(String s, int... ints) {}
> void caller() {
> Integer i = 1
> vfunc('foo', i)
> }
> }
> {noformat}



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


[jira] [Created] (GROOVY-9734) Generic is not inferred from context

2020-09-09 Thread Daniil Ovchinnikov (Jira)
Daniil Ovchinnikov created GROOVY-9734:
--

 Summary: Generic is not inferred from context
 Key: GROOVY-9734
 URL: https://issues.apache.org/jira/browse/GROOVY-9734
 Project: Groovy
  Issue Type: Bug
  Components: Static Type Checker
Affects Versions: 2.5.13, 3.0.5
Reporter: Daniil Ovchinnikov


{code:title=bugs.groovy}
static void stuff(List operations) {}

@groovy.transform.CompileStatic
void usage() {
stuff(Collections.emptyList()) // 
}

usage()
{code}

Results in compilation error:
{noformat}
[Static type checking] - Cannot call bugs#stuff(java.util.List 
) with arguments [java.util.List ] 
 @ line 5, column 5.
   stuff(Collections.emptyList())
   ^
{noformat}



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


[jira] [Commented] (GROOVY-9723) CLONE - ASTTest annotation has runtime retention and transform removes required member from AST

2020-09-09 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9723:
-

One additional loose end that was not resolved: {{ASTTest}} closures are parsed 
and executed for *every* {{SourceUnit}} in a {{CompilationUnit}}.  If they are 
used a lot in a project, there is a lot of parsing the text of the closure and 
starting up a shell to execute it.  Not sure if the use of {{ProgressListener}} 
can ever give enough information to restrict the execution to the applicable 
{{SourceUnit}}.

> CLONE - ASTTest annotation has runtime retention and transform removes 
> required member from AST
> ---
>
> Key: GROOVY-9723
> URL: https://issues.apache.org/jira/browse/GROOVY-9723
> Project: Groovy
>  Issue Type: Bug
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
>
> Description below is for GROOVY-9702 which is fixed in master. This issue is 
> to explore a partial non-breaking fix for Groovy 3 (and maybe 2.5).
> =
> Consider the following:
> {code:groovy}
> import groovy.transform.*
> import org.codehaus.groovy.ast.*
> import static org.codehaus.groovy.transform.stc.StaticTypesMarker.*
> class C {
>   void m() {
> def that = this;
> { ->
>   @ASTTest(phase=INSTRUCTION_SELECTION, value={
> ClassNode type = node.getNodeMetaData(INFERRED_TYPE)
> assert type?.name == 'C'
>   })
>   def ref = getThisObject()
>   assert ref == that
> }()
>   }
> }
> {code}
> This is a typical use of {{@ASTTest}}.  When compiled, the test annotation is 
> retained in the class file, which is unnecessary.  When the transform class 
> runs, it removes the "value" member from the AST, which is causing compiler 
> errors down the line when {{ExtendedVerifier}} runs {{AnnotationVisitor}}.  
> Also, the variable scope of the test closure is still connected to the class 
> and module, so code completion is making proposals for class members which 
> will not be there at run-time.
> This was originally investigated from the IDE side (see linked issue).
> [https://user-images.githubusercontent.com/18193802/90964420-fd51c800-e485-11ea-8349-c0f89e04561a.png]



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


[jira] [Commented] (GROOVY-9723) CLONE - ASTTest annotation has runtime retention and transform removes required member from AST

2020-09-09 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-9723:
-

You could drop the runtime retention part of the issue; keeping the annotation 
in the class file and runtime state does not impact function, only efficiency.  
Removing the closure expression from the AST is the main problem.

I never did figure out why Groovy's gradle build has no issue with the ASTTest 
annotations and Groovy-Eclipse's compilation sequence does.  Easiest thing from 
my end was to just add something back to the AST to satisfy the required 
annotation attribute.

> CLONE - ASTTest annotation has runtime retention and transform removes 
> required member from AST
> ---
>
> Key: GROOVY-9723
> URL: https://issues.apache.org/jira/browse/GROOVY-9723
> Project: Groovy
>  Issue Type: Bug
>Reporter: Eric Milles
>Assignee: Eric Milles
>Priority: Major
>
> Description below is for GROOVY-9702 which is fixed in master. This issue is 
> to explore a partial non-breaking fix for Groovy 3 (and maybe 2.5).
> =
> Consider the following:
> {code:groovy}
> import groovy.transform.*
> import org.codehaus.groovy.ast.*
> import static org.codehaus.groovy.transform.stc.StaticTypesMarker.*
> class C {
>   void m() {
> def that = this;
> { ->
>   @ASTTest(phase=INSTRUCTION_SELECTION, value={
> ClassNode type = node.getNodeMetaData(INFERRED_TYPE)
> assert type?.name == 'C'
>   })
>   def ref = getThisObject()
>   assert ref == that
> }()
>   }
> }
> {code}
> This is a typical use of {{@ASTTest}}.  When compiled, the test annotation is 
> retained in the class file, which is unnecessary.  When the transform class 
> runs, it removes the "value" member from the AST, which is causing compiler 
> errors down the line when {{ExtendedVerifier}} runs {{AnnotationVisitor}}.  
> Also, the variable scope of the test closure is still connected to the class 
> and module, so code completion is making proposals for class members which 
> will not be there at run-time.
> This was originally investigated from the IDE side (see linked issue).
> [https://user-images.githubusercontent.com/18193802/90964420-fd51c800-e485-11ea-8349-c0f89e04561a.png]



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


[jira] [Resolved] (GROOVY-9712) groovyc fails when compiling class starting with unicode character

2020-09-09 Thread Paul King (Jira)


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

Paul King resolved GROOVY-9712.
---
Fix Version/s: 3.0.6
   4.0.0-alpha-1
   Resolution: Fixed

Proposed PR merged. Thanks!

> groovyc fails when compiling class starting with unicode character
> --
>
> Key: GROOVY-9712
> URL: https://issues.apache.org/jira/browse/GROOVY-9712
> Project: Groovy
>  Issue Type: Bug
>  Components: Compiler
>Affects Versions: 3.0.5
> Environment: Windows 10 version 1809
> Groovy 3.0.5
>Reporter: Ted Lundqvist
>Assignee: Eric Milles
>Priority: Major
> Fix For: 4.0.0-alpha-1, 3.0.6
>
>  Time Spent: 1h
>  Remaining Estimate: 0h
>
>  
> Compiling the code below with groovyc results in the following error message:
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
>  Ö_ClassWithUlmaut.groovy: 2: Unexpected input: '(' @ line 2, column 41.
>  Ö_ClassWithUlmaut getInstance(){
>  ^
> 1 error
>  
> The file is encoded in Windows-1252 and I'm compiling it with the following 
> command:
>  \Tools\groovy-3.0.5\bin\groovyc --encoding Windows-1252 
> Ö_ClassWithUlmaut.groovy
> Compiling with version 2.5.8 works fine
>  
> The problem only seem to occur when the class name starts with a unicode 
> character i.e. the problem doesn't occur if the class name has an unicode in 
> it as long as it isn't the first character
> Example:
> {code:java}
> class Ö_ClassWithUlmaut {
> static Ö_ClassWithUlmaut getInstance(){
> }
> }
> {code}
>  



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


[jira] [Resolved] (GROOVY-9726) Compile error needed for illegal field modifier combination

2020-09-09 Thread Paul King (Jira)


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

Paul King resolved GROOVY-9726.
---
Fix Version/s: 3.0.6
   4.0.0-alpha-1
 Assignee: Paul King
   Resolution: Fixed

> Compile error needed for illegal field modifier combination
> ---
>
> Key: GROOVY-9726
> URL: https://issues.apache.org/jira/browse/GROOVY-9726
> Project: Groovy
>  Issue Type: Improvement
>Affects Versions: 3.0.5, 2.5.13
>Reporter: Paul King
>Assignee: Paul King
>Priority: Major
> Fix For: 4.0.0-alpha-1, 3.0.6
>
>
> The JLS (recent versions at least) states:
> {quote}
> It is a compile-time error if a final variable is also declared volatile.
> {quote}
> Compiling this class:
> {code}
> public class Foo {
> final volatile String foo = "bar";
> }
> {code}
> in Java gives the following compilation error:
> {noformat}
> error: illegal combination of modifiers: final and volatile
> {noformat}
> Groovy currently passes compilation but then gives the following error at 
> runtime when trying to create an instance of such a class:
> {noformat}
> java.lang.ClassFormatError: Illegal field modifiers in class Foo: 0x52
> {noformat}
> Groovy should also have a compilation error for this case.



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


[GitHub] [groovy] paulk-asert commented on a change in pull request #1362: GROOVY-9712: type name may start with more than A-Z (CapitalizedIdentifier)

2020-09-09 Thread GitBox


paulk-asert commented on a change in pull request #1362:
URL: https://github.com/apache/groovy/pull/1362#discussion_r485372966



##
File path: 
subprojects/parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/TestUtils.groovy
##
@@ -87,17 +81,15 @@ final class TestUtils {
 return [newAST, null]
 }
 
-static void shouldFail(String path, boolean toCheckNewParserOnly = false) {

Review comment:
   I'll add back in the `(String, boolean)` variant for binary compatibility





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 a change in pull request #1362: GROOVY-9712: type name may start with more than A-Z (CapitalizedIdentifier)

2020-09-09 Thread GitBox


paulk-asert commented on a change in pull request #1362:
URL: https://github.com/apache/groovy/pull/1362#discussion_r485372609



##
File path: src/antlr/GroovyLexer.g4
##
@@ -882,7 +882,7 @@ ELVIS_ASSIGN: '?=';
 
 // §3.8 Identifiers (must appear after all keywords in the grammar)
 CapitalizedIdentifier
-:   [A-Z] JavaLetterOrDigit*
+:   JavaLetter {Character.isUpperCase(getInputStream().LA(-1))}? 
JavaLetterOrDigit*

Review comment:
   LGTM. I'll merge and include this change.





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] asfgit closed pull request #1362: GROOVY-9712: type name may start with more than A-Z (CapitalizedIdentifier)

2020-09-09 Thread GitBox


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


   



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