groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7921) using "this" as the target of an assignment not working with Category annotation
Date Sun, 28 Aug 2016 09:24:20 GMT

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

ASF GitHub Bot commented on GROOVY-7921:
----------------------------------------

GitHub user paulk-asert opened a pull request:

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

    GROOVY-7921: using "this" as the target of an assignment not working …

    …with Category annotation

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

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

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

    https://github.com/apache/groovy/pull/400.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 #400
    
----
commit db2bbcce46528bb87afd68855caa1118da5b0164
Author: paulk <paulk@asert.com.au>
Date:   2016-08-28T09:21:37Z

    GROOVY-7921: using "this" as the target of an assignment not working with Category annotation

----


> using "this" as the target of an assignment not working with Category annotation
> --------------------------------------------------------------------------------
>
>                 Key: GROOVY-7921
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7921
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.7
>         Environment: mac os x 10.10.5
> jdk 1.8.0_51
>            Reporter: kyon_mm
>
> when I executed this code in GroovyConsole
> {code:java}
> @Category(Integer)
> class IntegerEx {
>   def reset(int value) {
>     this = value
>     this
>   }
> }
> use(IntegerEx){
>   println (1 + 2).reset(1)
> }
> {code}
> Then, I get this exception log
> {code}
> Exception thrown
> BUG! exception in phase 'semantic analysis' in source unit 'ConsoleScript17' null
> 	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:935)
> 	at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:593)
> 	at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:542)
> 	at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
> 	at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
> 	at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:517)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:497)
> 	at groovy.lang.GroovyShell.run(GroovyShell.java:170)
> 	at groovy.lang.GroovyShell$run$1.call(Unknown Source)
> 	at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:1005)
> 	at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)
> 	at sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:497)
> 	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
> 	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
> 	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)
> 	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1024)
> 	at groovy.lang.Closure.call(Closure.java:414)
> 	at groovy.lang.Closure.call(Closure.java:408)
> 	at groovy.lang.Closure.run(Closure.java:495)
> 	at java.lang.Thread.run(Thread.java:745)
> Caused by: java.lang.NullPointerException
> 	at org.codehaus.groovy.classgen.VariableScopeVisitor.checkForFinal(VariableScopeVisitor.java:388)
> 	at org.codehaus.groovy.classgen.VariableScopeVisitor.checkFinalFieldAccess(VariableScopeVisitor.java:381)
> 	at org.codehaus.groovy.classgen.VariableScopeVisitor.visitBinaryExpression(VariableScopeVisitor.java:365)
> 	at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51)
> 	at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:71)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:196)
> 	at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42)
> 	at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166)
> 	at org.codehaus.groovy.classgen.VariableScopeVisitor.visitBlockStatement(VariableScopeVisitor.java:308)
> 	at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104)
> 	at org.codehaus.groovy.classgen.VariableScopeVisitor.visitConstructorOrMethod(VariableScopeVisitor.java:505)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126)
> 	at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078)
> 	at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53)
> 	at org.codehaus.groovy.classgen.VariableScopeVisitor.visitClass(VariableScopeVisitor.java:473)
> 	at org.codehaus.groovy.control.CompilationUnit$11.call(CompilationUnit.java:648)
> 	at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:931)
> 	... 22 more
> {code}
> Is this behavior groovy-language specification ?



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

Mime
View raw message