groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Keegan Witt <keeganw...@gmail.com>
Subject Re: type checking bug
Date Wed, 02 Sep 2015 21:05:44 GMT
When I said I didn't see that error, I meant in the GroovyConsole.  Because
I'm a lazy bum and that's where I test everything.  So how were you
applying the transformation?  It sounds like you're manually calling and
not as a Gradle/GMavenPlus/groovyc config script?

-Keegan

On Wed, Sep 2, 2015 at 4:34 PM, Jamie Echlin <jamie.echlin@gmail.com> wrote:

> 2.4.3. Sorry I should have said first time round. I will check the diffs
> to the new version...
>
> This "bug" is confusing the hell out of me. If I run the script with
> groovyshell or groovyscriptengine or whatever it works, but if I add the
> TypeChecked as a AST customiser then you get the result I posted above.
>
> I would have thought it was the same code path.
>
> Thanks for the info.
>
> On Wed, Sep 2, 2015 at 8:59 PM, Keegan Witt <keeganwitt@gmail.com> wrote:
>
>> What version of Groovy are you using?  Maybe I'm doing something
>> different, but on 2.4.4, I'm not seeing the error you're seeing.
>>
>> -Keegan
>>
>> On Wed, Sep 2, 2015 at 8:44 AM, Jamie Echlin <jamie.echlin@gmail.com>
>> wrote:
>>
>>> Found a bug with type checking... at least I think it's a bug. If no one
>>> disagrees I'll raise a ticket in jira.
>>>
>>> When I compile the following using:
>>>
>>>          ASTTransformationCustomizer astcz = new
>>> ASTTransformationCustomizer(
>>>              TypeChecked)
>>>
>>> I get an NPE, which suggests that the compilation unit hasn't been set
>>> for one of the classes. Input code is:
>>>
>>> import groovy.transform.TypeChecked
>>>
>>> @TypeChecked
>>> class TypeCheckingBug {
>>>
>>>     void methodA() {
>>>         // removing this or the othing makes this work
>>>         ['a', 'b'].eachWithIndex { String value, sequence -> }
>>>     }
>>>
>>>
>>>     void methodB() {
>>>
>>>         def instanceB = new ClassB()
>>>
>>>         // removing this or the above makes this work
>>>         instanceB.with {
>>>             instanceC
>>>         }
>>>     }
>>>
>>>
>>>     class ClassB {
>>>         ClassC instanceC
>>>     }
>>>
>>>     class ClassC { }
>>> }
>>>
>>> Removing either of the two lines with the comments makes it work.
>>>
>>> Any help appreciated.
>>> cheers, jamie
>>>
>>> Caused by: java.lang.NullPointerException
>>> at
>>> org.codehaus.groovy.control.ClassNodeResolver.tryAsLoaderClassOrScript(ClassNodeResolver.java:177)
>>> at
>>> org.codehaus.groovy.control.ClassNodeResolver.findClassNode(ClassNodeResolver.java:167)
>>> at
>>> org.codehaus.groovy.control.ClassNodeResolver.resolveName(ClassNodeResolver.java:123)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.resolveToOuter(ResolveVisitor.java:675)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:307)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:307)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.resolve(ResolveVisitor.java:275)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:259)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.resolveOrFail(ResolveVisitor.java:271)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.visitConstructorOrMethod(ResolveVisitor.java:196)
>>> at
>>> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
>>> at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1083)
>>> at
>>> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1260)
>>> at
>>> org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:175)
>>> at
>>> org.codehaus.groovy.ast.tools.GenericsUtils.resolveClassNode(GenericsUtils.java:560)
>>> at
>>> org.codehaus.groovy.ast.tools.GenericsUtils.parseClassNodesFromString(GenericsUtils.java:527)
>>> at groovy.transform.stc.FromString.parseOption(FromString.java:74)
>>> at
>>> groovy.transform.stc.FromString.getClosureSignatures(FromString.java:55)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.getSignaturesFromHint(StaticTypeCheckingVisitor.java:2588)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doInferClosureParameterTypes(StaticTypeCheckingVisitor.java:2609)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferClosureParameterTypes(StaticTypeCheckingVisitor.java:2508)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2474)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:3109)
>>> at
>>> org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:64)
>>> at
>>> org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:69)
>>> at
>>> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:193)
>>> at
>>> org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:40)
>>> at
>>> org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:35)
>>> at
>>> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:163)
>>> at
>>> org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:69)
>>> at
>>> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:101)
>>> at
>>> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:112)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1969)
>>> at
>>> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:123)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2302)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2261)
>>> at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1083)
>>> at
>>> org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:50)
>>> at
>>> org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:248)
>>> at
>>> org.codehaus.groovy.transform.StaticTypesTransformation.visit(StaticTypesTransformation.java:63)
>>>  <+2> (DelegatingMethodAccessorImpl.java:43)
>>> at java.lang.reflect.Method.invoke(Method.java:497)
>>> at
>>> org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSite.invoke(PojoMetaMethodSite.java:189)
>>> at
>>> org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:53)
>>> at
>>> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130)
>>> at
>>> org.codehaus.groovy.control.customizers.ASTTransformationCustomizer.call(ASTTransformationCustomizer.groovy:292)
>>> at
>>> org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1052)
>>> ... 268 more
>>>
>>>
>>>
>>
>

Mime
View raw message