[jira] [Created] (GROOVY-8960) Can not call a java parameterized type method from groovy with java enum. Compile error
Stuart Adamson created GROOVY-8960: -- Summary: Can not call a java parameterized type method from groovy with java enum. Compile error Key: GROOVY-8960 URL: https://issues.apache.org/jira/browse/GROOVY-8960 Project: Groovy Issue Type: Bug Components: GroovyScriptEngine Affects Versions: 2.5.5 Reporter: Stuart Adamson Java: {code:java} import java.io.Serializable; public class aJavaClass { private aJavaClass(final A inA) { System.out.println("Hello"); } public static aJavaClass create(final A inA) { return new aJavaClass<>(inA); } public enum aEnum { entry1, } }{code} Groovy calling class: {code:java} import groovy.transform.CompileStatic import aJavaClass @CompileStatic class aCallingGroovyClass { static void main(String[] args) { aJavaClass.create(aJavaClass.aEnum.entry1) } }{code} try compiling get: {code:java} Error:(10, 9) Groovyc: [Static type checking] - Cannot call aJavaClass#create(A) with arguments [aJavaClass$aEnum]{code} Replace the method arg aJavaClass.aEnum.entry1 with non enum, say '1' no quotes, code compiles and runs. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8959) NPE in StaticVerifier
[ https://issues.apache.org/jira/browse/GROOVY-8959?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Eric Milles updated GROOVY-8959: Description: I don't have the exact code that created this error, but the fix seems pretty simple. {code:java} // excerpt from StaticVerifier.visitConstructorOrMethod public void visitVariableExpression(VariableExpression ve) { if (exceptions.contains(ve.getName())) return; /* GRECLIPSE edit -- VariableExpression.isInStaticContext is null safe Variable av = ve.getAccessedVariable(); if (av instanceof DynamicVariable || !av.isInStaticContext()) { // this is line 96 */ if (ve.getAccessedVariable() instanceof DynamicVariable || !ve.isInStaticContext()) { // GRECLIPSE end addVariableError(ve); } } {code} {code} 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:302) 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:162) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1210) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:54) at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:54) at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:241) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1143) ... 20 more {code} was: I don't have the exact code that created this error, but the fix seems pretty simple. {code:java} // excerpt from StaticVerifier.visitConstructorOrMethod public void visitVariableExpression(VariableExpression ve) { if (exceptions.contains(ve.getName())) return; /* GRECLIPSE edit -- VariableExpression.isInStaticContext is null safe Variable av = ve.getAccessedVariable(); if (av instanceof DynamicVariable || !av.isInStaticContext()) { */ if (ve.getAccessedVariable() instanceof DynamicVariable || !ve.isInStaticContext()) { // GRECLIPSE end addVariableError(ve); } } {code} {code} 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:302) 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:162) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1210) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:54) at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:54) at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:241) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1143) ... 20 more {code} > NPE in StaticVerifier > - > > Key: GROOVY-8959 > URL: https://issues.apache.org/jira/browse/GROOVY-8959 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.4.16, 2.5.5 >Reporter: Eric Milles >Priority: Major > > I don't have the exact code that created this error, but the fix seems pretty > simple. > {code:java} > // excerpt from StaticVerifier.visitConstructorOrMethod > public void > visitVariableExpression(VariableExpression ve) { > if (exceptions.contains(ve.getName()))
[jira] [Created] (GROOVY-8959) NPE in StaticVerifier
Eric Milles created GROOVY-8959: --- Summary: NPE in StaticVerifier Key: GROOVY-8959 URL: https://issues.apache.org/jira/browse/GROOVY-8959 Project: Groovy Issue Type: Bug Components: Compiler Affects Versions: 2.5.5, 2.4.16 Reporter: Eric Milles I don't have the exact code that created this error, but the fix seems pretty simple. {code:java} // excerpt from StaticVerifier.visitConstructorOrMethod public void visitVariableExpression(VariableExpression ve) { if (exceptions.contains(ve.getName())) return; /* GRECLIPSE edit -- VariableExpression.isInStaticContext is null safe Variable av = ve.getAccessedVariable(); if (av instanceof DynamicVariable || !av.isInStaticContext()) { */ if (ve.getAccessedVariable() instanceof DynamicVariable || !ve.isInStaticContext()) { // GRECLIPSE end addVariableError(ve); } } {code} {code} 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:302) 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:162) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1210) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:54) at org.codehaus.groovy.control.StaticVerifier.visitClass(StaticVerifier.java:54) at org.codehaus.groovy.control.CompilationUnit$13.call(CompilationUnit.java:241) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1143) ... 20 more {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Closed] (GROOVY-8434) ClassCastException: Class cannot be cast to type-of-with's-delegate
[ https://issues.apache.org/jira/browse/GROOVY-8434?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Paul King closed GROOVY-8434. - Resolution: Duplicate I believe this is a duplicate of GROOVY-8873. > ClassCastException: Class cannot be cast to type-of-with's-delegate > --- > > Key: GROOVY-8434 > URL: https://issues.apache.org/jira/browse/GROOVY-8434 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.4.12 > Environment: Windows 10, Gradle 4.2.1 >Reporter: Robert Papp >Priority: Major > > I'm sorry for the hard repro, but I couldn't figure it out with a smaller one. > 1. > https://github.com/TWiStErRob/net.twisterrob.gradle.quality/tree/groovy-cast-bug > 2. {{gradlew test}} (if you're lucky it runs and fails, otherwise don't fret > there's an other way) > Test fails: > {code} > Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to > org.gradle.api.reporting.ConfigurableReport > at > net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig$_setupReports_closure2$_closure3.doCall(CheckStyleTask.groovy:95) > at > net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig$_setupReports_closure2$_closure3.call(CheckStyleTask.groovy) > at > net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig$_setupReports_closure2.doCall(CheckStyleTask.groovy:94) > at > net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig$_setupReports_closure2.call(CheckStyleTask.groovy) > at > net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig.setupReports(CheckStyleTask.groovy:91) > at > net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig.execute(CheckStyleTask.groovy:42) > at > net.twisterrob.gradle.checkstyle.CheckStyleTask$TaskConfig.execute(CheckStyleTask.groovy) > at > org.gradle.api.internal.tasks.DefaultTaskContainer.create(DefaultTaskContainer.java:148) > {code} > Now, that's obviously not my error, because 1) it worked in the previous > commit (when the class wasn't an inner class) and 2) I'm using > {{ast(groovy.transform.CompileStatic)}} to build. > Another way: {{gradlew groovyCompile}}, and then observe the build directory: > {code} > static def setupReports(CheckStyleTask task) { > task.reports.with { > def reportsDir = > task.project.extensions.findByType(ReportingExtension).baseDir > xml.with { > enabled = true > setDestination(new File(reportsDir, 'checkstyle.xml')) > {code} > compiles to > {code} > public Object doCall(Object it) { > boolean var2 = true; > > ((ConfigurableReport)CheckStyleTask.class).setEnabled(var2); > Object var10001 = null; > > ((ConfigurableReport)((_closure4)this).getDelegate()).setDestination(new > File((File)ScriptBytecodeAdapter.castToType(this.reportsDir.get(), > File.class), "checkstyle.html")); > Object var1 = null; > {code} > Note: the first cast is wrong, the second one is using getDelegate properly. -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[GitHub] paulk-asert opened a new pull request #854: GROOVY-8873: Fails at runtime with @CompileStatic and two nested with…
paulk-asert opened a new pull request #854: GROOVY-8873: Fails at runtime with @CompileStatic and two nested with… URL: https://github.com/apache/groovy/pull/854 … statements with ClassCastException This is an automated message from the Apache Git Service. To respond to the message, please log on 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 With regards, Apache Git Services