Eric Milles created GROOVY-8267: ----------------------------------- Summary: NPE in StaticVerifier Key: GROOVY-8267 URL: https://issues.apache.org/jira/browse/GROOVY-8267 Project: Groovy Issue Type: Bug Affects Versions: 2.4.12 Reporter: Eric Milles
I am seeing this NPE due to one of our Groovy sources. When I replace the defaults below with additional constructors, the error subsides. {code} @CompileStatic class Foo implements Comparable<Foo> { Foo(String id = null, List<Bar> bars = Collections.EMPTY_LIST) { ... } } {code} {code} Caused by: java.lang.NullPointerException at org.codehaus.groovy.control.StaticVerifier$1.visitVariableExpression(StaticVerifier.java:96) at org.codehaus.groovy.ast.expr.VariableExpression.visit(VariableExpression.java:72) at org.codehaus.groovy.ast.CodeVisitorSupport.visitPropertyExpression(CodeVisitorSupport.java:254) at org.codehaus.groovy.ast.expr.PropertyExpression.visit(PropertyExpression.java:57) at org.codehaus.groovy.control.StaticVerifier.visitConstructorOrMethod(StaticVerifier.java:91) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructor(ClassCodeVisitorSupport.java:166) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1197) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:56) at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:54) at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:228) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1129) {code} Line 96 is the last line of: {code} @Override public void visitConstructorOrMethod(MethodNode node, boolean isConstructor) { MethodNode oldCurrentMethod = currentMethod; currentMethod = node; super.visitConstructorOrMethod(node, isConstructor); if (isConstructor) { final Set<String> exceptions = new HashSet<String>(); for (final Parameter param : node.getParameters()) { exceptions.add(param.getName()); if (param.hasInitialExpression()) { param.getInitialExpression().visit(new CodeVisitorSupport() { @Override public void visitVariableExpression(VariableExpression ve) { if (exceptions.contains(ve.getName())) return; Variable av = ve.getAccessedVariable(); if (av instanceof DynamicVariable || !av.isInStaticContext()) { {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)