[jira] [Created] (GROOVY-11440) invalid reference to an array constructor leads to type unsafe results
Thodoris Sotiropoulos created GROOVY-11440: -- Summary: invalid reference to an array constructor leads to type unsafe results Key: GROOVY-11440 URL: https://issues.apache.org/jira/browse/GROOVY-11440 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code:java} import java.util.function.*; class A{ } class Test { public static void main(String[] args) { Function x = A[]::new; A[] y = x.apply(new Object()); } } {code} h3. Actual behavior The code compiles, and I get a ClassCastException: {code:java} Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'java.lang.Object@63d4e2ba' with class 'java.lang.Object' to class 'int' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:177) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.intUnbox(DefaultTypeTransformation.java:85) at Test.ctorRef$main$0(test.groovy) at Test.main(test.groovy:13) {code} h3. Actual behavior The code should have been rejected. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Closed] (GROOVY-11439) closure is assignable to java.io.InputStream
[ https://issues.apache.org/jira/browse/GROOVY-11439?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos closed GROOVY-11439. -- Resolution: Information Provided > closure is assignable to java.io.InputStream > > > Key: GROOVY-11439 > URL: https://issues.apache.org/jira/browse/GROOVY-11439 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > Labels: groovy > > I am not sure if this is an expected behavior or not, but a lambda expression > is assignable to java.io.InputStream > > {code:java} > class Test { > public static void main(String[] args) { > java.io.InputStream x = (int p, int p2) -> p; > System.out.println(x.read()); > } > } {code} > h3. Actual behavior > The code compiles, but I get the following exception at runtime > {code:java} > Exception in thread "main" groovy.lang.MissingMethodException: No signature > of method: Test$_main_closure1.doCall() is applicable for argument types: () > values: [] > Possible solutions: doCall(int, int), isCase(java.lang.Object), > isCase(java.lang.Object), findAll(), findAll(), findAll(groovy.lang.Closure) > at > org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:259) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006) > at groovy.lang.Closure.call(Closure.java:452) > at InputStream1_groovyProxy.read(Unknown Source) > at Test.main(test.groovy:4) {code} > h3. Expected behavior > The code should have been rejected. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-11439) closure is assignable to java.io.InputStream
[ https://issues.apache.org/jira/browse/GROOVY-11439?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17865321#comment-17865321 ] Thodoris Sotiropoulos commented on GROOVY-11439: Thanks for the clarification. Initially, I thought it's only applied to interfaces explicitly marked with @FunctionalInterface. > closure is assignable to java.io.InputStream > > > Key: GROOVY-11439 > URL: https://issues.apache.org/jira/browse/GROOVY-11439 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > Labels: groovy > > I am not sure if this is an expected behavior or not, but a lambda expression > is assignable to java.io.InputStream > > {code:java} > class Test { > public static void main(String[] args) { > java.io.InputStream x = (int p, int p2) -> p; > System.out.println(x.read()); > } > } {code} > h3. Actual behavior > The code compiles, but I get the following exception at runtime > {code:java} > Exception in thread "main" groovy.lang.MissingMethodException: No signature > of method: Test$_main_closure1.doCall() is applicable for argument types: () > values: [] > Possible solutions: doCall(int, int), isCase(java.lang.Object), > isCase(java.lang.Object), findAll(), findAll(), findAll(groovy.lang.Closure) > at > org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:259) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006) > at groovy.lang.Closure.call(Closure.java:452) > at InputStream1_groovyProxy.read(Unknown Source) > at Test.main(test.groovy:4) {code} > h3. Expected behavior > The code should have been rejected. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11439) closure is assignable to java.io.InputStream
Thodoris Sotiropoulos created GROOVY-11439: -- Summary: closure is assignable to java.io.InputStream Key: GROOVY-11439 URL: https://issues.apache.org/jira/browse/GROOVY-11439 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I am not sure if this is an expected behavior or not, but a lambda expression is assignable to java.io.InputStream {code:java} class Test { public static void main(String[] args) { java.io.InputStream x = (int p, int p2) -> p; System.out.println(x.read()); } } {code} h3. Actual behavior The code compiles, but I get the following exception at runtime {code:java} Exception in thread "main" groovy.lang.MissingMethodException: No signature of method: Test$_main_closure1.doCall() is applicable for argument types: () values: [] Possible solutions: doCall(int, int), isCase(java.lang.Object), isCase(java.lang.Object), findAll(), findAll(), findAll(groovy.lang.Closure) at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:259) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006) at groovy.lang.Closure.call(Closure.java:452) at InputStream1_groovyProxy.read(Unknown Source) at Test.main(test.groovy:4) {code} h3. Expected behavior The code should have been rejected. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11437) incorrect typing in nested ternary operator leads to type unsafety
[ https://issues.apache.org/jira/browse/GROOVY-11437?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11437: --- Description: I have the following program, which leads to an unexpected typing result during an LUB operation. {code:java} import java.time.*; import java.time.chrono.*; class Test { public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); int x = 1; ((false ? 1 : (false ? x : (ChronoLocalDateTime) now)) >= x) } }{code} h3. Actual behavior The code compiles, but I receive the following ClassCastException {code:java} Exception in thread "main" java.lang.IllegalArgumentException: Cannot compare java.time.LocalDateTime with value '2024-07-08T17:00:53.307529' and java.lang.Integer with value '1' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:815) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareTo(DefaultTypeTransformation.java:750) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareTo(ScriptBytecodeAdapter.java:802) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareGreaterThanEqual(ScriptBytecodeAdapter.java:915) at Test.main(test.groovy:9) Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.time.chrono.ChronoLocalDateTime (java.lang.Integer and java.time.chrono.ChronoLocalDateTime are in module java.base of loader 'bootstrap') at java.base/java.time.LocalDateTime.compareTo(LocalDateTime.java:135) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:338) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:274) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1227) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006) at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:623) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:614) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:801) ... 4 more {code} h3. Expected behavior The code should have been rejected. Tested against master (commit: c773e04ce402816b8f92c0318d08bde32e723eed) was: I have the following program, which leads to an unexpected typing result during an LUB operation. {code:java} import java.time.*; import java.time.chrono.*; class Test { public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); int x = 1; ((false ? 1 : (false ? x : (ChronoLocalDateTime) now)) >= x) } }{code} h3. Actual behavior The code compiles, but I receive the following ClassCastException {code:java} Exception in thread "main" java.lang.IllegalArgumentException: Cannot compare java.time.LocalDateTime with value '2024-07-08T17:00:53.307529' and java.lang.Integer with value '1' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:815) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareTo(DefaultTypeTransformation.java:750) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareTo(ScriptBytecodeAdapter.java:802) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareGreaterThanEqual(ScriptBytecodeAdapter.java:915) at Test.main(test.groovy:9) Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.time.chrono.ChronoLocalDateTime (java.lang.Integer and java.time.chrono.ChronoLocalDateTime are in module java.base of loader 'bootstrap') at java.base/java.time.LocalDateTime.compareTo(LocalDateTime.java:135) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:338) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:274) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1227) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006) at
[jira] [Created] (GROOVY-11437) incorrect typing in nested ternary operator leads to type unsafety
Thodoris Sotiropoulos created GROOVY-11437: -- Summary: incorrect typing in nested ternary operator leads to type unsafety Key: GROOVY-11437 URL: https://issues.apache.org/jira/browse/GROOVY-11437 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program, which leads to an unexpected typing result during an LUB operation. {code:java} import java.time.*; import java.time.chrono.*; class Test { public static void main(String[] args) { LocalDateTime now = LocalDateTime.now(); int x = 1; ((false ? 1 : (false ? x : (ChronoLocalDateTime) now)) >= x) } }{code} h3. Actual behavior The code compiles, but I receive the following ClassCastException {code:java} Exception in thread "main" java.lang.IllegalArgumentException: Cannot compare java.time.LocalDateTime with value '2024-07-08T17:00:53.307529' and java.lang.Integer with value '1' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:815) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareTo(DefaultTypeTransformation.java:750) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareTo(ScriptBytecodeAdapter.java:802) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareGreaterThanEqual(ScriptBytecodeAdapter.java:915) at Test.main(test.groovy:9) Caused by: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.time.chrono.ChronoLocalDateTime (java.lang.Integer and java.time.chrono.ChronoLocalDateTime are in module java.base of loader 'bootstrap') at java.base/java.time.LocalDateTime.compareTo(LocalDateTime.java:135) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:338) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:274) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1227) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1006) at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:623) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:614) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:801) ... 4 more {code} h3. Expected behavior The code should have been rejected. Tested against master (commit: c773e04ce402816b8f92c0318d08bde32e723eed) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11431) missing type error when using a Closure within a ternary operator
Thodoris Sotiropoulos created GROOVY-11431: -- Summary: missing type error when using a Closure within a ternary operator Key: GROOVY-11431 URL: https://issues.apache.org/jira/browse/GROOVY-11431 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Probably related to GROOVY-10961. I have the following program {code:java} class Test { public static void main(String[] args) { Closure y = () -> "bar"; long x = ((true) ? y : () -> 100).call(); } }{code} h3. Actual behavior The code compiles but I receive the following error at runtime: {code:java} Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'bar' with class 'java.lang.String' to class 'long' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:177) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.longUnbox(DefaultTypeTransformation.java:94) at Test.main(test.groovy:4) {code} h3. Expected behavior The code should have been rejected. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11430) Inconsistent behavior when encountering overloaded methods
Thodoris Sotiropoulos created GROOVY-11430: -- Summary: Inconsistent behavior when encountering overloaded methods Key: GROOVY-11430 URL: https://issues.apache.org/jira/browse/GROOVY-11430 Project: Groovy Issue Type: Bug Components: Static compilation, Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code:java} import java.util.*; import java.util.function.*; class A { void m(T x) { System.out.println("there"); } void m(Integer x) { System.out.println("here"); } } class Test { public static void main(String[] args) { A x = new A<>(); Consumer y = x::m; y.accept(1) } } {code} h3. Actual behavior Depending on the order in which methods "m()" appear in the program, the outcome is different. So, if "m( T x)" is first, the outcome is "there". Otherwise, if "m( Integer x)" is first, the outcome is "here". h3. Expected behavior I would expect that the reference "x::m" is ambiguous, so the program should have been rejected. Tested against master (commit: d3c07b8416743545ebb81fda43768f2cec4ca59b) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11427) unexpectec crash in class generation "On receiver: x with message: getAt and arguments: 0"
Thodoris Sotiropoulos created GROOVY-11427: -- Summary: unexpectec crash in class generation "On receiver: x with message: getAt and arguments: 0" Key: GROOVY-11427 URL: https://issues.apache.org/jira/browse/GROOVY-11427 Project: Groovy Issue Type: Bug Components: Static compilation, Static Type Checker Reporter: Thodoris Sotiropoulos I have the following (ill-typed) program: {code:java} class Test { void test() { Class x = null; x[0]; } } {code} h3. Actual behavior {code:java} >>> a serious error occurred: BUG! exception in phase 'class generation' in >>> source unit 'test.groovy' at line 4 column 5 On receiver: x with message: getAt and arguments: 0 This method should not have been called. Please try to create a simple example reproducing this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY >>> stacktrace: BUG! exception in phase 'class generation' in source unit 'test.groovy' at line 4 column 5 On receiver: x with message: getAt and arguments: 0 This method should not have been called. Please try to create a simple example reproducing this error and file a bug report at https://issues.apache.org/jira/browse/GROOVY at org.codehaus.groovy.classgen.asm.sc.StaticTypesCallSiteWriter.makeSingleArgumentCall(StaticTypesCallSiteWriter.java:592) at org.codehaus.groovy.classgen.asm.InvocationWriter.makeSingleArgumentCall(InvocationWriter.java:659) at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateBinaryExpression(BinaryExpressionHelper.java:730) at org.codehaus.groovy.classgen.asm.BinaryExpressionMultiTypeDispatcher.evaluateBinaryExpression(BinaryExpressionMultiTypeDispatcher.java:203) at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:341) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:872) at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:57) at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610) at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:850) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86) at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:775) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:634) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:569) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:718) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1331) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1324) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:369) at org.codehaus.groovy.control.CompilationUnit$4.call(CompilationUnit.java:810) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:952) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:698) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:672) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:653) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:312) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:241) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:166) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:206) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:190) {code} Tested against master (commit: eb8448f0f74b5e404aabe1428d99151f75954018) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11410) type mismatch when the expected type is java.lang.Class
Thodoris Sotiropoulos created GROOVY-11410: -- Summary: type mismatch when the expected type is java.lang.Class Key: GROOVY-11410 URL: https://issues.apache.org/jira/browse/GROOVY-11410 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code:java} class Test { public static void main(String [] args) { java.lang.Class lapse = 1; } } {code} h3. Actual behavior The code compiles, but I get the following runtime error: {code:java} Caught: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '1' with class 'java.lang.Integer' to class 'java.lang.Class' due to: java.lang.ClassNotFoundException: 1 org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '1' with class 'java.lang.Integer' to class 'java.lang.Class' due to: java.lang.ClassNotFoundException: 1 at Test.main(test.groovy:3){code} h3. Expected behavior The code should have been rejected Tested against master (commit: e6b9133726af9cdea2bc6db7b55523cd88f7190e) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11392) the field of an interface cannot be protected
[ https://issues.apache.org/jira/browse/GROOVY-11392?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11392: --- Description: I have the following code: {code:java} interface A { protected static int x = 1; } class B implements A { } public class Test { public static void main(String[] args) { new B(); } }{code} h3. Actual behavior The code compiles but I receive the following exception: {code:java} Exception in thread "main" java.lang.ClassFormatError: Illegal field modifiers in class A: 0x1D at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) at Test.main(test.groovy:10) {code} h3. Expected behavior The code should have been rejected, as the field should not be protected. was: I have the following code: {code:java} interface A { protected static int x = 1; } class B implements A { } public class Test { public static void main(String[] args) { new B(); } }{code} h3. Actual behavior The code compiles but I receive the following exception: {code:java} {code} > the field of an interface cannot be protected > - > > Key: GROOVY-11392 > URL: https://issues.apache.org/jira/browse/GROOVY-11392 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > > I have the following code: > {code:java} > interface A { > protected static int x = 1; > } > class B implements A { > } > public class Test { > public static void main(String[] args) { > new B(); > } > }{code} > h3. Actual behavior > The code compiles but I receive the following exception: > {code:java} > Exception in thread "main" java.lang.ClassFormatError: Illegal field > modifiers in class A: 0x1D > at java.base/java.lang.ClassLoader.defineClass1(Native Method) > at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) > at > java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) > at > java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) > at > java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) > at > java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621) > at > java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579) > at > java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) > at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) > at java.base/java.lang.ClassLoader.defineClass1(Native Method) > at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) > at > java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174) > at > java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800) > at > java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698) > at >
[jira] [Created] (GROOVY-11392) the field of an interface cannot be protected
Thodoris Sotiropoulos created GROOVY-11392: -- Summary: the field of an interface cannot be protected Key: GROOVY-11392 URL: https://issues.apache.org/jira/browse/GROOVY-11392 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following code: {code:java} interface A { protected static int x = 1; } class B implements A { } public class Test { public static void main(String[] args) { new B(); } }{code} h3. Actual behavior The code compiles but I receive the following exception: {code:java} {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11385) reference to the constructor of an abstract class is not detected
Thodoris Sotiropoulos created GROOVY-11385: -- Summary: reference to the constructor of an abstract class is not detected Key: GROOVY-11385 URL: https://issues.apache.org/jira/browse/GROOVY-11385 Project: Groovy Issue Type: Bug Components: Static Type Checker Affects Versions: 5.0.0-alpha-8 Reporter: Thodoris Sotiropoulos I have the following program {code:java} import java.util.function.*; abstract class Foo { Foo(String x) {} } class Test { public static void main(String[] args) { Function x = Foo::new; x.apply("d"); } } {code} h3. Actual behavior The program compiles but I get the following runtime exception, because I call the constructor of an abstract class. {code:java} Exception in thread "main" java.lang.InstantiationException: Foo at java.base/jdk.internal.misc.Unsafe.allocateInstance(Native Method) at java.base/java.lang.invoke.DirectMethodHandle.allocateInstance(DirectMethodHandle.java:501) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:336) at Test.ctorRef$main$0(test.groovy) at Test.main(test.groovy:10) {code} h3. Expected behavior The program should have been rejected instead. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11383) incorrect comparison is missed by the compiler
Thodoris Sotiropoulos created GROOVY-11383: -- Summary: incorrect comparison is missed by the compiler Key: GROOVY-11383 URL: https://issues.apache.org/jira/browse/GROOVY-11383 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code:java} class Test { public static void main(String[] args) { int x = 1; x > new Object(); } } {code} h3. Actual behavior The code compilers but I receive the following runtime exception {code:java} Exception in thread "main" java.lang.IllegalArgumentException: Cannot compare java.lang.Integer with value '1' and java.lang.Object with value 'java.lang.Object@609cd4d8' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:816) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareTo(DefaultTypeTransformation.java:751) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareTo(ScriptBytecodeAdapter.java:802) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.compareGreaterThan(ScriptBytecodeAdapter.java:888) at Test.main(test.groovy:5) Caused by: java.lang.ClassCastException: class java.lang.Object cannot be cast to class java.lang.Integer (java.lang.Object and java.lang.Integer are in module java.base of loader 'bootstrap') at java.base/java.lang.Integer.compareTo(Integer.java:59) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:338) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:274) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1225) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1005) at org.codehaus.groovy.runtime.InvokerHelper.invokePojoMethod(InvokerHelper.java:623) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:614) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:802) ... 4 more {code} h3. Expected behavior The code should have been rejected with {code:java} test.groovy: 5: [Static type checking] - Cannot find matching method int#compareTo(java.lang.Object). Please check if the declared type is correct and if the method exists. @ line 5, column 5. x > new Object(); ^1 error {code} h3. Notes * Tested against master (commit: ea4b1efad7dcb805b4f4fa6454fc95fa338147cb) * Groovy 4.0.10 rejects the program as expected. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11382) fail to identify type error in static array initialization with generic classes
Thodoris Sotiropoulos created GROOVY-11382: -- Summary: fail to identify type error in static array initialization with generic classes Key: GROOVY-11382 URL: https://issues.apache.org/jira/browse/GROOVY-11382 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Probably related to GROOVY-9985 {code:java} import java.util.* class Test { public static void main(String[] args) { List lst = ["fda"]; List[] x = new List[]{lst}; Integer k = x[0].get(0) } } {code} h3. Actual behavior The program compiles but receiving the following runtime error: {code:java} Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'fda' with class 'java.lang.String' to class 'java.lang.Integer' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToNumber(DefaultTypeTransformation.java:173) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:288) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:245) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:336) at Test.main(test.groovy:7) {code} h3. Expected behavior The program should have been rejected -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11371) unsafe conversion of array of reference type to an array of primitive type
Thodoris Sotiropoulos created GROOVY-11371: -- Summary: unsafe conversion of array of reference type to an array of primitive type Key: GROOVY-11371 URL: https://issues.apache.org/jira/browse/GROOVY-11371 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code:java} class Test { public static void main(String[] args) { double[] z = new Double[]{null}; } } {code} h3. Actual behavior The compiler accepts the program. However, I get the following exception at runtime. {code:java} Exception in thread "main" java.lang.IllegalArgumentException at java.base/java.lang.reflect.Array.set(Native Method) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.asArray(DefaultTypeTransformation.java:459) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:228) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:336) at Test.main(test.groovy:3) {code} h3. Expected behavior The compiler should reject the program: Double[] is not convertible to double[]. h3. Notes Tested against master (commit: 8ba8e8264fc3edeb9c70b52937edb97b0246a5d5) Groovy 4.0.10 rejects the program as expected. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-11301) References to inaccesible methods with static compilation leads to runtime error
[ https://issues.apache.org/jira/browse/GROOVY-11301?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17820077#comment-17820077 ] Thodoris Sotiropoulos commented on GROOVY-11301: {code} ❯ groovyc --version Groovy compiler version 5.0.0-SNAPSHOT Copyright 2003-2024 The Apache Software Foundation. https://groovy-lang.org/ {code} {code} ❯ java --version openjdk 18-ea 2022-03-15 OpenJDK Runtime Environment (build 18-ea+17-1015) OpenJDK 64-Bit Server VM (build 18-ea+17-1015, mixed mode, sharing) {code} {code} ❯ groovyc --compile-static test.groovy ❯ java -cp groovy-repo/build/libs/groovy-5.0.0-SNAPSHOT.jar:. Test Exception in thread "main" java.lang.IllegalAccessError: class Test tried to access private method 'java.lang.String Test$A.m()' (Test and Test$A are in unnamed module of loader 'app') at Test.main(test.groovy:8) {code} > References to inaccesible methods with static compilation leads to runtime > error > > > Key: GROOVY-11301 > URL: https://issues.apache.org/jira/browse/GROOVY-11301 > Project: Groovy > Issue Type: Bug > Components: Static compilation >Reporter: Thodoris Sotiropoulos >Priority: Minor > Attachments: Test$A.class, Test.class > > > I have the following ill-typed program > {code} > import java.util.function.Supplier; > public class Test { > static class A { > private static String m() { return null; } > } > public static void main(String[] args) { > Supplier x = A::m; > } > } > {code} > h3. Actual behaviour > The compiler accepts the program, but I receive the following runtime error, > because I access a private method. > {code} > Exception in thread "main" java.lang.IllegalAccessError: class Test tried to > access private method 'java.lang.String Test$A.m()' (Test and Test$A are in > unnamed module of loader 'app') > at Test.main(groovy51.groovy:9) > {code} > h3. Expected behavior > The program should have been rejected by the compiler. > Tested against master (commit: 191231a832efd2e2fc49391c01f8d176944d68e3) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11319) Access to a private property of a parent object is not caught
Thodoris Sotiropoulos created GROOVY-11319: -- Summary: Access to a private property of a parent object is not caught Key: GROOVY-11319 URL: https://issues.apache.org/jira/browse/GROOVY-11319 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following ill-typed program {code} class A { private int getX() { return 1; } } class B extends A { void test() { def y = super.x; System.out.println(y); } } public class Test { public static void main(String[] args) { new B().test(); } } {code} h3. Actual behavior The program compiles. When I run it, I receive: {code} Exception in thread "main" groovy.lang.MissingPropertyException: No such property: x for class: B at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:68) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getPropertyOnSuper(ScriptBytecodeAdapter.java:426) at B.test(test.groovy:9) at Test.main(test.groovy:16) {code} h3. Expected behavior The problem is on line 9, when the program accesses the private property x of the parent object. Tested against master (commit: e17149013c5943ad3493f9597e6720eb6529d120) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11301) References to inaccesible methods with static compilation leads to runtime error
[ https://issues.apache.org/jira/browse/GROOVY-11301?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11301: --- Attachment: Test$A.class Test.class > References to inaccesible methods with static compilation leads to runtime > error > > > Key: GROOVY-11301 > URL: https://issues.apache.org/jira/browse/GROOVY-11301 > Project: Groovy > Issue Type: Bug > Components: Static compilation >Reporter: Thodoris Sotiropoulos >Priority: Minor > Attachments: Test$A.class, Test.class > > > I have the following ill-typed program > {code} > import java.util.function.Supplier; > public class Test { > static class A { > private static String m() { return null; } > } > public static void main(String[] args) { > Supplier x = A::m; > } > } > {code} > h3. Actual behaviour > The compiler accepts the program, but I receive the following runtime error, > because I access a private method. > {code} > Exception in thread "main" java.lang.IllegalAccessError: class Test tried to > access private method 'java.lang.String Test$A.m()' (Test and Test$A are in > unnamed module of loader 'app') > at Test.main(groovy51.groovy:9) > {code} > h3. Expected behavior > The program should have been rejected by the compiler. > Tested against master (commit: 191231a832efd2e2fc49391c01f8d176944d68e3) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-11301) References to inaccesible methods with static compilation leads to runtime error
[ https://issues.apache.org/jira/browse/GROOVY-11301?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17819521#comment-17819521 ] Thodoris Sotiropoulos commented on GROOVY-11301: [^Test$A.class] [^Test.class] I uploaded the bytecode files. > References to inaccesible methods with static compilation leads to runtime > error > > > Key: GROOVY-11301 > URL: https://issues.apache.org/jira/browse/GROOVY-11301 > Project: Groovy > Issue Type: Bug > Components: Static compilation >Reporter: Thodoris Sotiropoulos >Priority: Minor > Attachments: Test$A.class, Test.class > > > I have the following ill-typed program > {code} > import java.util.function.Supplier; > public class Test { > static class A { > private static String m() { return null; } > } > public static void main(String[] args) { > Supplier x = A::m; > } > } > {code} > h3. Actual behaviour > The compiler accepts the program, but I receive the following runtime error, > because I access a private method. > {code} > Exception in thread "main" java.lang.IllegalAccessError: class Test tried to > access private method 'java.lang.String Test$A.m()' (Test and Test$A are in > unnamed module of loader 'app') > at Test.main(groovy51.groovy:9) > {code} > h3. Expected behavior > The program should have been rejected by the compiler. > Tested against master (commit: 191231a832efd2e2fc49391c01f8d176944d68e3) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-11301) References to inaccesible methods leads to runtime error
[ https://issues.apache.org/jira/browse/GROOVY-11301?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17812445#comment-17812445 ] Thodoris Sotiropoulos commented on GROOVY-11301: {code} ❯ java -version openjdk version "18-ea" 2022-03-15 OpenJDK Runtime Environment (build 18-ea+17-1015) OpenJDK 64-Bit Server VM (build 18-ea+17-1015, mixed mode, sharing) {code} {code} ❯ groovy --compile-static program.groovy Caught: java.lang.IllegalAccessError: class Test tried to access private method 'java.lang.String Test$A.m()' (Test and Test$A are in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @85ec632) java.lang.IllegalAccessError: class Test tried to access private method 'java.lang.String Test$A.m()' (Test and Test$A are in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @85ec632) at Test.main(program.groovy:8) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) {code} > References to inaccesible methods leads to runtime error > > > Key: GROOVY-11301 > URL: https://issues.apache.org/jira/browse/GROOVY-11301 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > > I have the following ill-typed program > {code} > import java.util.function.Supplier; > public class Test { > static class A { > private static String m() { return null; } > } > public static void main(String[] args) { > Supplier x = A::m; > } > } > {code} > h3. Actual behaviour > The compiler accepts the program, but I receive the following runtime error, > because I access a private method. > {code} > Exception in thread "main" java.lang.IllegalAccessError: class Test tried to > access private method 'java.lang.String Test$A.m()' (Test and Test$A are in > unnamed module of loader 'app') > at Test.main(groovy51.groovy:9) > {code} > h3. Expected behavior > The program should have been rejected by the compiler. > Tested against master (commit: 191231a832efd2e2fc49391c01f8d176944d68e3) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-11301) References to inaccesible methods leads to runtime error
[ https://issues.apache.org/jira/browse/GROOVY-11301?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17812402#comment-17812402 ] Thodoris Sotiropoulos commented on GROOVY-11301: Oops; you are right! The code should compile. However, I am still getting this runtime error, that's why I was confused. {code} Caught: java.lang.IllegalAccessError: class Test tried to access private method 'java.lang.String Test$A.m()' (Test and Test$A are in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @12bfd80d) java.lang.IllegalAccessError: class Test tried to access private method 'java.lang.String Test$A.m()' (Test and Test$A are in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @12bfd80d) at Test.main(program.groovy:8) {code} > References to inaccesible methods leads to runtime error > > > Key: GROOVY-11301 > URL: https://issues.apache.org/jira/browse/GROOVY-11301 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > > I have the following ill-typed program > {code} > import java.util.function.Supplier; > public class Test { > static class A { > private static String m() { return null; } > } > public static void main(String[] args) { > Supplier x = A::m; > } > } > {code} > h3. Actual behaviour > The compiler accepts the program, but I receive the following runtime error, > because I access a private method. > {code} > Exception in thread "main" java.lang.IllegalAccessError: class Test tried to > access private method 'java.lang.String Test$A.m()' (Test and Test$A are in > unnamed module of loader 'app') > at Test.main(groovy51.groovy:9) > {code} > h3. Expected behavior > The program should have been rejected by the compiler. > Tested against master (commit: 191231a832efd2e2fc49391c01f8d176944d68e3) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11301) References to inaccesible methods leads to runtime error
Thodoris Sotiropoulos created GROOVY-11301: -- Summary: References to inaccesible methods leads to runtime error Key: GROOVY-11301 URL: https://issues.apache.org/jira/browse/GROOVY-11301 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following ill-typed program {code} import java.util.function.Supplier; public class Test { static class A { private static String m() { return null; } } public static void main(String[] args) { Supplier x = A::m; } } {code} h3. Actual behaviour The compiler accepts the program, but I receive the following runtime error, because I access a private method. {code} Exception in thread "main" java.lang.IllegalAccessError: class Test tried to access private method 'java.lang.String Test$A.m()' (Test and Test$A are in unnamed module of loader 'app') at Test.main(groovy51.groovy:9) {code} h3. Expected behavior The program should have been rejected by the compiler. Tested against master (commit: 191231a832efd2e2fc49391c01f8d176944d68e3) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11297) Fail to identify duplicate constructor declaration
Thodoris Sotiropoulos created GROOVY-11297: -- Summary: Fail to identify duplicate constructor declaration Key: GROOVY-11297 URL: https://issues.apache.org/jira/browse/GROOVY-11297 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following ill-typed program {code} class A { A(int x) {} A(int y) {} } {code} h3. Actual behavior The program compiles but I get the following runtime exception {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during instruction selection: java.lang.ClassFormatError: Duplicate method name "" with signature "(I)V" in class file A java.lang.RuntimeException: java.lang.ClassFormatError: Duplicate method name "" with signature "(I)V" in class file A at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:934) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:654) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:628) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:368) at groovy.lang.GroovyClassLoader.lambda$parseClass$2(GroovyClassLoader.java:311) at org.codehaus.groovy.runtime.memoize.StampedCommonCache.compute(StampedCommonCache.java:163) at org.codehaus.groovy.runtime.memoize.StampedCommonCache.getAndPut(StampedCommonCache.java:154) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:309) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:543) at groovy.lang.GroovyShell.run(GroovyShell.java:364) at groovy.lang.GroovyShell.run(GroovyShell.java:354) at groovy.ui.GroovyMain.processOnce(GroovyMain.java:645) at groovy.ui.GroovyMain.run(GroovyMain.java:390) at groovy.ui.GroovyMain.access$1400(GroovyMain.java:68) at groovy.ui.GroovyMain$GroovyCommand.process(GroovyMain.java:314) at groovy.ui.GroovyMain.processArgs(GroovyMain.java:142) at groovy.ui.GroovyMain.main(GroovyMain.java:115) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:112) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:130) Caused by: java.lang.ClassFormatError: Duplicate method name "" with signature "(I)V" in class file A at java.base/java.lang.ClassLoader.defineClass1(Native Method) at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1012) at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150) at groovy.lang.GroovyClassLoader.access$400(GroovyClassLoader.java:90) at groovy.lang.GroovyClassLoader$ClassCollector.createClass(GroovyClassLoader.java:675) at groovy.lang.GroovyClassLoader$ClassCollector.onClassNode(GroovyClassLoader.java:692) at groovy.lang.GroovyClassLoader$ClassCollector.call(GroovyClassLoader.java:697) at org.codehaus.groovy.control.CompilationUnit$3.call(CompilationUnit.java:768) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:900) ... 22 more 1 error {code} h3. Expected behavior Reject the program and report duplicate constructor declaration. This check is performed for methods, but not for constructors. Tested against master (commit: b39bef39b5a22bd53769298d43a8192cbedecb63) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11274) Not reporting error when implicit default constructor is private
Thodoris Sotiropoulos created GROOVY-11274: -- Summary: Not reporting error when implicit default constructor is private Key: GROOVY-11274 URL: https://issues.apache.org/jira/browse/GROOVY-11274 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following ill-typed program: {code} public class Main { public static void main(String[] args) { var x = new Foo(1); } } class Foo extends Bar { Foo(int p0){ } } class Bar { Bar(int x){ } private Bar(){ } } {code} h3. Actual behavior The code compiles, but I receive the following error at runtime {code} Caught: java.lang.IllegalAccessError: class Foo tried to access private method 'void Bar.()' (Foo and Bar are in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @266374ef) java.lang.IllegalAccessError: class Foo tried to access private method 'void Bar.()' (Foo and Bar are in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @266374ef) at Foo.(test.groovy:8) at Main.main(test.groovy:3) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) {code} h3. Expected behavior The code should be rejected, as the implicit default constructor of Bar is private. Tested against master (commit: 3cd76364f772250324f5729ef93ffd76fbdd2b79) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11273) Fail to identify updates on final variables declared in default methods
Thodoris Sotiropoulos created GROOVY-11273: -- Summary: Fail to identify updates on final variables declared in default methods Key: GROOVY-11273 URL: https://issues.apache.org/jira/browse/GROOVY-11273 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following ill-typed program: {code} interface Test { default void test() { final int x = 1; x = 2; } } {code} h3. Actual behavior The code compiles successfully h3. Expected behavior Code rejected with: {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 4: The variable [x] is declared final but is reassigned . At [4:5] @ line 4, column 5. x = 2; ^ 1 error {code} Tested against master (commit: 3cd76364f772250324f5729ef93ffd76fbdd2b79) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11256) Fail to identify direct call of abstract method
Thodoris Sotiropoulos created GROOVY-11256: -- Summary: Fail to identify direct call of abstract method Key: GROOVY-11256 URL: https://issues.apache.org/jira/browse/GROOVY-11256 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following ill-typed program {code} interface A { int m(); } class C implements A { public int m() { return 1; } void test() { A.super.m(); } } public class Test { public static void main(String[] args) { new C().test(); } } {code} h3. Actual behavior The program compiles with and produces: {code} Exception in thread "main" java.lang.AbstractMethodError: 'int A.m()' at C.test(Test.groovy:8) at Test.main(Test.groovy:14) {code} h3. Expected behavior Reject the program with: {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Test.groovy: 8: [Static type checking] - Abstract method m() cannot be called directly @ line 8, column 9. A.super.m(); ^ 1 error {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11254) Compiler crash: ClassNode#getTypeClass for TemporalAccessor called before the type class is set
Thodoris Sotiropoulos created GROOVY-11254: -- Summary: Compiler crash: ClassNode#getTypeClass for TemporalAccessor called before the type class is set Key: GROOVY-11254 URL: https://issues.apache.org/jira/browse/GROOVY-11254 Project: Groovy Issue Type: Bug Components: Static compilation, Static Type Checker Reporter: Thodoris Sotiropoulos I have the following well-typed program: {code} interface TemporalQuery { T1 queryFrom(TemporalAccessor p0); } class TemporalAccessor {} class Test { void test() { TemporalQuery rec = null; TemporalQuery gravy = rec::queryFrom; } } {code} The program crashes the compiler and produces the following stack trace {code} >>> a serious error occurred: BUG! exception in phase 'class generation' in >>> source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before the >>> type class is set >>> stacktrace: BUG! exception in phase 'class generation' in source unit 'Main.groovy' ClassNode#getTypeClass for Foo called before the type class is set at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1357) at org.codehaus.groovy.ast.ClassNode.getTypeClass(ClassNode.java:1351) at org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.lambda$createMethodDescriptor$0(AbstractFunctionalInterfaceWriter.java:49) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575) at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260) at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616) at org.codehaus.groovy.classgen.asm.sc.AbstractFunctionalInterfaceWriter.createMethodDescriptor(AbstractFunctionalInterfaceWriter.java:49) at org.codehaus.groovy.classgen.asm.sc.StaticTypesMethodReferenceExpressionWriter.writeMethodReferenceExpression(StaticTypesMethodReferenceExpressionWriter.java:176) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodReferenceExpression(AsmClassGenerator.java:935) at org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34) at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateEqual(BinaryExpressionHelper.java:423) at org.codehaus.groovy.classgen.asm.sc.StaticTypesBinaryExpressionMultiTypeDispatcher.evaluateEqual(StaticTypesBinaryExpressionMultiTypeDispatcher.java:203) at org.codehaus.groovy.classgen.AsmClassGenerator.visitDeclarationExpression(AsmClassGenerator.java:853) at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92) at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:610) at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:837) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:86) at org.codehaus.groovy.classgen.asm.sc.StaticTypesStatementWriter.writeBlockStatement(StaticTypesStatementWriter.java:77) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:762) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:621) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:556) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:705) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1278) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1271) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:367) at org.codehaus.groovy.control.CompilationUnit$4.call(CompilationUnit.java:810) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:952) at
[jira] [Created] (GROOVY-11244) Cannot define Java-like lambda inside closure
Thodoris Sotiropoulos created GROOVY-11244: -- Summary: Cannot define Java-like lambda inside closure Key: GROOVY-11244 URL: https://issues.apache.org/jira/browse/GROOVY-11244 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.Function; class Test { void test() { Closure clo = { Function x = (z) -> 1 + z; return "f"; } } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 6: [Static type checking] - The variable [z] is undeclared. @ line 6, column 49. eger, Integer> x = (z) -> 1 + z; ^ test.groovy: 6: [Static type checking] - Cannot find matching method int#plus(java.lang.Object). Please check if the declared type is correct and if the method exists. @ line 6, column 45. x = (z) -> 1 + z; ^ test.groovy: 6: [Static type checking] - The variable [z] is undeclared. @ line 6, column 38. Function x = (z) -> 1 + z; ^ 3 errors {code} h3. Expected behavior Compile successfully -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11129) STC chooses to call a non-polymorphic method although explicit type arguments are given
Thodoris Sotiropoulos created GROOVY-11129: -- Summary: STC chooses to call a non-polymorphic method although explicit type arguments are given Key: GROOVY-11129 URL: https://issues.apache.org/jira/browse/GROOVY-11129 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following code: {code} import java.util.concurrent.*; class Main { static final void test() { ExecutorService z = null; Future future = z.submit(() -> "fd"); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 7: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.concurrent.Future to: java.util.concurrent.Future @ line 7, column 35. Future future = z.submit(() -> "fd"); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes It seems that the compiler chooses to call the variant that takes no type arguments (see https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/concurrent/ExecutorService.html#submit(java.lang.Runnable), even though explicit type arguments are given. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11121) unexpected error when having overloaded methods, one of which receiving an Iterable
Thodoris Sotiropoulos created GROOVY-11121: -- Summary: unexpected error when having overloaded methods, one of which receiving an Iterable Key: GROOVY-11121 URL: https://issues.apache.org/jira/browse/GROOVY-11121 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.*; class Foo { static Foo of(Iterable values) { return null; } static Foo of(T values) { return null; } } class Main { static final void test() { Foo.of((int s) -> s + 1); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 10: [Static type checking] - Wrong number of parameters for method target: iterator() @ line 10, column 38. var x = Foo.of((int s) -> s + 1); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Test case adapted from the following program that uses the apache-commons-io library: {code} import org.apache.commons.io.function.*; import java.util.function.*; class Main { static final void test() { var x = IOStream.of((int s) -> s + 1); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11120) Unexpected error when using static method of class with lower case
Thodoris Sotiropoulos created GROOVY-11120: -- Summary: Unexpected error when using static method of class with lower case Key: GROOVY-11120 URL: https://issues.apache.org/jira/browse/GROOVY-11120 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following class that resides in package named "bar", and its corresponding client. {code} package bar; public class foo { public static void create(String x) {} } // client code class Main { static final void test() { bar.foo.create("fda"); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 3: Apparent variable 'bar' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes: You attempted to reference a variable in the binding or an instance variable from a static context. You misspelled a classname or statically imported field. Please check the spelling. You attempted to use a method 'bar' but left out brackets in a place not allowed by the grammar. @ line 3, column 5. bar.foo.create("fda"); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master Test case adapted from the following code that uses the javassist library. {code} class Main { static final void test() throws Exception { javassist.tools.framedump.main(null); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11115) Miss to check the compatibility of wildcard types
Thodoris Sotiropoulos created GROOVY-5: -- Summary: Miss to check the compatibility of wildcard types Key: GROOVY-5 URL: https://issues.apache.org/jira/browse/GROOVY-5 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos This might be a known issue / limitation. I have the following code {code} import java.util.* class Main { static final void test() { List list = new LinkedList(); List x = list; // types are not compatible. List y = (List) null // types are not compatible; list.add(1); // method call is not permitted. } } {code} h3. Actual behavior The code compiles without raising any errors. h3. Expected behavior The compiler should have rejected the program by raising three type errors. h3. Notes Tested against master -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11114) Fail to find method reference in case of chain of polymorphic method calls
Thodoris Sotiropoulos created GROOVY-4: -- Summary: Fail to find method reference in case of chain of polymorphic method calls Key: GROOVY-4 URL: https://issues.apache.org/jira/browse/GROOVY-4 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos This is probably a regresssion. I have the following program {code} import java.util.*; import java.util.concurrent.*; class Foo { V apply(K p) { return null; } } class Main { static final void test(Foo, String> p) { ConcurrentHashMap.KeySetView x = null; ConcurrentHashMap y = x.getMap(); y.reduceEntries(19, p::apply, null); // works x.getMap().reduceEntries(19, p::apply, null); // fails } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 15: Failed to find method 'apply(java.util.Map$Entry)' for the type: Foo, java.lang.String> @ line 15, column 42. p().reduceEntries(19, p::apply, ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11110) STC mixes names of bounded type parameters
Thodoris Sotiropoulos created GROOVY-0: -- Summary: STC mixes names of bounded type parameters Key: GROOVY-0 URL: https://issues.apache.org/jira/browse/GROOVY-0 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.stream.*; class Main { static final void test() { java.util.function.BiConsumer func = null; Stream stream = null; T res = stream.collect(() -> (T) null, (T finisher, String hijacking) -> { }, func); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 8: [Static type checking] - Cannot assign value of type java.lang.String to variable of type T @ line 8, column 13. T res = stream.collect(() -> (T) null, (T finisher, String hijacking) -> { }, func); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes To trigger the bug, the type parameter of method test() should be bounded with name T. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11109) Unable to initialize generic class with an array
Thodoris Sotiropoulos created GROOVY-11109: -- Summary: Unable to initialize generic class with an array Key: GROOVY-11109 URL: https://issues.apache.org/jira/browse/GROOVY-11109 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Probably a regeression. I have the following program {code} class Foo { Foo(T[] x) {} } class Main { static final void test() { Byte[][] arg = null; Foo res = new Foo(arg) } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 8: [Static type checking] - Cannot call Foo#(java.lang.Byte[][]) with arguments [java.lang.Byte[][]] @ line 8, column 23. Foo res = new Foo(arg) ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master adapted from the following program {code} class Main { static final void test() { byte[][] arg = null; byte[] res = new com.fasterxml.jackson.databind.util.ArrayIterator(arg).next(); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11106) Failed to detect an ambiguous method call?
Thodoris Sotiropoulos created GROOVY-11106: -- Summary: Failed to detect an ambiguous method call? Key: GROOVY-11106 URL: https://issues.apache.org/jira/browse/GROOVY-11106 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following code: {code} import java.io.*; import java.util.*; class Main { void test() { ObjectOutputStream y = null; m(y); } Number m(OutputStream x) { return 1; } Number m(DataOutput x) { return 2; } } {code} h3. Actual behaviour The code compiles successfully. The compiler resolves the second method, that is m(DataOutput). h3. Expected behaviour It seems that the method call is ambiguous, and thus the compiler should have rejected the above program. javac seems to reject the program with a method ambiguity error. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-11094) SAM types not working well along with overloading
[ https://issues.apache.org/jira/browse/GROOVY-11094?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17732246#comment-17732246 ] Thodoris Sotiropoulos commented on GROOVY-11094: Ah I see; got it! > SAM types not working well along with overloading > - > > Key: GROOVY-11094 > URL: https://issues.apache.org/jira/browse/GROOVY-11094 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Assignee: Eric Milles >Priority: Minor > Labels: SAM, overloading > > I have the following program: > {code} > import java.util.*; > import java.util.function.*; > class Bar { > LinkedList collect(Supplier function) { } > List collect(String x, int y, int z) { } > } > class Main { > static final void test() { > Bar x = null; > LinkedList d = x.collect(() -> "fda"); > } > } > {code} > h3. Actual behaviour > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 14: [Static type checking] - Cannot assign value of type > java.util.List to variable of type > java.util.LinkedList > @ line 14, column 28. >LinkedList d = x.collect(() -> "fda"); > ^ > 1 error > {code} > h3. Expected behaviour > Compile successfully > h3. Notes > Tested against master (commit: cac91791764b8f0b3338318248474412f89e3456) > Adapted from: > {code} > import java.util.*; > import java.util.function.*; > import org.eclipse.collections.api.tuple.primitive.BooleanBooleanPair; > import org.eclipse.collections.api.map.primitive.*; > import org.eclipse.collections.api.factory.map.primitive.*; > import org.eclipse.collections.api.collection.*; > import > org.eclipse.collections.api.factory.map.primitive.MutableDoubleFloatMapFactory; > class Main { > static final void test() { > ImmutableObjectDoubleMap> d = null; > final ImmutableCollection x = d.collect((p) > -> (MutableDoubleFloatMapFactory) null ); > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11094) SAM types not working well along with overloading
Thodoris Sotiropoulos created GROOVY-11094: -- Summary: SAM types not working well along with overloading Key: GROOVY-11094 URL: https://issues.apache.org/jira/browse/GROOVY-11094 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Somewhat related to GROOVY-GROOVY-11002. I have the following program {code} import java.util.*; import java.util.function.*; class Bar { LinkedList collect(Supplier function) { return null; } List collect(String x, int y, int d) { return null; } } class Main { static final void test() { Bar x = null; LinkedList d = x.collect(() -> "fda"); } } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 14: [Static type checking] - Cannot assign value of type java.util.List to variable of type java.util.LinkedList @ line 14, column 28. LinkedList d = x.collect(() -> "fda"); ^ 1 error {code} h3. Expected behaviour Compile successfully h3. Notes Tested against master (commit: cac91791764b8f0b3338318248474412f89e3456) Adapted from: {code} import java.util.*; import java.util.function.*; import org.eclipse.collections.api.tuple.primitive.BooleanBooleanPair; import org.eclipse.collections.api.map.primitive.*; import org.eclipse.collections.api.factory.map.primitive.*; import org.eclipse.collections.api.collection.*; import org.eclipse.collections.api.factory.map.primitive.MutableDoubleFloatMapFactory; class Main { static final void test() { ImmutableObjectDoubleMap> d = null; final ImmutableCollection x = d.collect((p) -> (MutableDoubleFloatMapFactory) null ); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-11086) Wrong method is chosen when having overloaded methods with bounded type parameters
[ https://issues.apache.org/jira/browse/GROOVY-11086?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17731484#comment-17731484 ] Thodoris Sotiropoulos commented on GROOVY-11086: If I am not mistaken, Java examines the type arguments, and not the return target. The list overload is not applicable under the given type arguments. So maybe Java does not put list overload into the set of applicable methods? > Wrong method is chosen when having overloaded methods with bounded type > parameters > -- > > Key: GROOVY-11086 > URL: https://issues.apache.org/jira/browse/GROOVY-11086 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Assignee: Eric Milles >Priority: Minor > Labels: bounded-polymorphism, overloading > > I have the following program > {code} > import java.util.*; > class Foo {} > class Bar {} > class Main { > static final void test() { > LinkedList x = null; > Foo> y = Main.>m(x); > } > static > Foo m(Iterable x) {return null;} > static > Bar m(List x) { return null; } > } > {code} > h3. Actual behaviour > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > Main.groovy: 9: [Static type checking] - Cannot assign value of type Bar extends java.util.List> to variable of type > Foo> > @ line 9, column 31. >Foo> y = Main.>m(x); > ^ > 1 error > {code} > h3. Expected behaviour > Compile successfully > In particular, the chosen method is wrong. It's not even applicable as the > provided type argument (at the call-site) does not respect the upper bound of > the chosen method. > h3. Notes > Test case adapted from the following code that uses the assertj-core lib: > {code} > import java.util.*; > import org.assertj.core.api.*; > class Foo {} > class Bar {} > class Main { > static final void test() { > LinkedList x = null; > FactoryBasedNavigableIterableAssert, Number, > ObjectAssert> res = Java6Assertions.assertThat(x, (y) -> x); > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11087) Local variable inference leads to incorrect type when having a complex parameterized type
Thodoris Sotiropoulos created GROOVY-11087: -- Summary: Local variable inference leads to incorrect type when having a complex parameterized type Key: GROOVY-11087 URL: https://issues.apache.org/jira/browse/GROOVY-11087 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} class Main { static final void test() { Class> d = null; var x = d.cast(""); m(x); } static void m(Class x) {} } {code} h3. Actual behaviour {code} Main.groovy: 5: [Static type checking] - Cannot find matching method Main#m(java.lang.Number). Please check if the declared type is correct and if the method exists. @ line 5, column 5. m(x); ^ 1 error {code} h3. Expected behaviour Compile successfully h3. Notes Tested against master (commit: b71df4a88afa4f82d9db3dd7938a3db3090bdf55). The error occurs only when you pass variable x as argument to a method call. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11086) Wrong method is chosen when having overloaded methods with bounded type parameters
[ https://issues.apache.org/jira/browse/GROOVY-11086?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11086: --- Description: I have the following program {code} import java.util.*; class Foo {} class Bar {} class Main { static final void test() { LinkedList x = null; Foo> y = Main.>m(x); } static > Foo m(Iterable x) {return null;} static > Bar m(List x) { return null; } } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 9: [Static type checking] - Cannot assign value of type Bar> to variable of type Foo> @ line 9, column 31. Foo> y = Main.>m(x); ^ 1 error {code} h3. Expected behaviour Compile successfully In particular, the chosen method is wrong. It's not even applicable as the provided type argument (at the call-site) does not respect the upper bound of the chosen method. h3. Notes Test case adapted from the following code that uses the assertj-core lib: {code} import java.util.*; import org.assertj.core.api.*; class Foo {} class Bar {} class Main { static final void test() { LinkedList x = null; FactoryBasedNavigableIterableAssert, Number, ObjectAssert> res = Java6Assertions.assertThat(x, (y) -> x); } {code} was: I have the following program {code} import java.util.*; class Foo {} class Bar {} class Main { static final void test() { LinkedList x = null; Foo> y = Main.>m(x); } static > Foo m(Iterable x) {return null;} static > Bar m(List x) { return null; } } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 10: [Static type checking] - Cannot assign value of type Bar> to variable of type Foo> @ line 10, column 31. Foo> y = Main.>m(x); ^ 1 error {code} h3. Expected behaviour Compile successfully In particular, the chosen method is wrong. It's not even applicable as the provided type argument (at the call-site) does not respect the upper bound of the chosen method. h3. Notes Test case adapted from the following code that uses the assertj-core lib: {code} import java.util.*; import org.assertj.core.api.*; class Foo {} class Bar {} class Main { static final void test() { LinkedList x = null; FactoryBasedNavigableIterableAssert, Number, ObjectAssert> res = Java6Assertions.assertThat(x, (y) -> x); } {code} > Wrong method is chosen when having overloaded methods with bounded type > parameters > -- > > Key: GROOVY-11086 > URL: https://issues.apache.org/jira/browse/GROOVY-11086 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > Labels: bounded-polymorphism, overloading > > I have the following program > {code} > import java.util.*; > class Foo {} > class Bar {} > class Main { > static final void test() { > LinkedList x = null; > Foo> y = Main.>m(x); > } > static > Foo m(Iterable x) {return null;} > static > Bar m(List x) { return null; } > } > {code} > h3. Actual behaviour > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > Main.groovy: 9: [Static type checking] - Cannot assign value of type Bar extends java.util.List> to variable of type > Foo> > @ line 9, column 31. >Foo> y = Main.>m(x); > ^ > 1 error > {code} > h3. Expected behaviour > Compile successfully > In particular, the chosen method is wrong. It's not even applicable as the > provided type argument (at the call-site) does not respect the upper bound of > the chosen method. > h3. Notes > Test case adapted from the following code that uses the assertj-core lib: > {code} > import java.util.*; > import org.assertj.core.api.*; > class Foo {} > class Bar {} > class Main { > static final void test() { > LinkedList x = null; > FactoryBasedNavigableIterableAssert, Number, > ObjectAssert> res = Java6Assertions.assertThat(x, (y) -> x); > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11086) Wrong method is chosen when having overloaded methods with bounded type parameters
Thodoris Sotiropoulos created GROOVY-11086: -- Summary: Wrong method is chosen when having overloaded methods with bounded type parameters Key: GROOVY-11086 URL: https://issues.apache.org/jira/browse/GROOVY-11086 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.*; class Foo {} class Bar {} class Main { static final void test() { LinkedList x = null; Foo> y = Main.>m(x); } static > Foo m(Iterable x) {return null;} static > Bar m(List x) { return null; } } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 10: [Static type checking] - Cannot assign value of type Bar> to variable of type Foo> @ line 10, column 31. Foo> y = Main.>m(x); ^ 1 error {code} h3. Expected behaviour Compile successfully In particular, the chosen method is wrong. It's not even applicable as the provided type argument (at the call-site) does not respect the upper bound of the chosen method. h3. Notes Test case adapted from the following code that uses the assertj-core lib: {code} import java.util.*; import org.assertj.core.api.*; class Foo {} class Bar {} class Main { static final void test() { LinkedList x = null; FactoryBasedNavigableIterableAssert, Number, ObjectAssert> res = Java6Assertions.assertThat(x, (y) -> x); } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11082) Incompatible generic argument when mixing diamond operator and "super" wildcard
Thodoris Sotiropoulos created GROOVY-11082: -- Summary: Incompatible generic argument when mixing diamond operator and "super" wildcard Key: GROOVY-11082 URL: https://issues.apache.org/jira/browse/GROOVY-11082 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Somewhat related to GROOVY-11254. I have the following program {code} import java.util.function.*; class Foo { Foo(Supplier x) {} } class Main { static final void test() { Supplier func = null; Foo x = new Foo<>(func); } } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 10: [Static type checking] - Incompatible generic argument types. Cannot assign Foo to: Foo @ line 10, column 27. Foo x = new Foo<>(func); ^ 1 error {code} h3. Expected behaviour Compile successfully h3. Notes Tested against master Test case adapted from: {code} class Main { static final void test() { final org.apache.commons.collections4.functors.NotPredicate x = null; final org.apache.commons.collections4.functors.PredicateDecorator y = new org.apache.commons.collections4.functors.NullIsTruePredicate<>(x); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11081) Exponential behaviour in error reporting
Thodoris Sotiropoulos created GROOVY-11081: -- Summary: Exponential behaviour in error reporting Key: GROOVY-11081 URL: https://issues.apache.org/jira/browse/GROOVY-11081 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos This might be a rare scenario to appear in practice but I notice that there's an exponential behaviour in error reporting. Particularly, the following code {code} class Main { static final void test() { org.apache.commons.collections4.iterators.ZippingIterator< org.apache.commons.collections4.iterators.ZippingIterator > x = null; } } {code} produces: {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 4: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 4, column 7. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 5: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator> @ line 5, column 7. > x = null; ^ 12 errors {code} while the following code: {code} class Main { static final void test() { org.apache.commons.collections4.iterators.ZippingIterator< org.apache.commons.collections4.iterators.ZippingIterator< org.apache.commons.collections4.iterators.ZippingIterator > > x = null; } } {code} produces: {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test1.groovy: 5: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 5, column 9. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 5: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 5, column 9. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 5: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 5, column 9. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 5: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 5, column 9. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 5: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 5, column 9. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 5: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 5, column 9. org.apache.commons.collections4.iterators.ZippingIterator ^ test1.groovy: 5: unable to resolve class org.apache.commons.collections4.iterators.ZippingIterator @ line 5, column 9.
[jira] [Created] (GROOVY-11077) STC overconstraints lambda's parameter types when expecting a SAM that involves wildcards
Thodoris Sotiropoulos created GROOVY-11077: -- Summary: STC overconstraints lambda's parameter types when expecting a SAM that involves wildcards Key: GROOVY-11077 URL: https://issues.apache.org/jira/browse/GROOVY-11077 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} class Test { void test() { m((Integer x, Integer y) -> 1); } void m(java.util.Comparator x) {} } {code} h3. Actual behavior {code} test.groovy: 3: [Static type checking] - Expected type java.lang.Object for lambda parameter: x @ line 3, column 8. m((Integer x, Integer y) -> 1); ^ test.groovy: 3: [Static type checking] - Expected type java.lang.Object for lambda parameter: y @ line 3, column 19. m((Integer x, Integer y) -> 1); ^ 2 errors {code} h3. Expected behaviour Compile successfully h3. Tested against master (commit: 1d9f35a448a2a731499534841ffe64150e80744c) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11021) Resolving wrong overloaded method when having variable arguments
[ https://issues.apache.org/jira/browse/GROOVY-11021?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11021: --- Description: This might be related to GROOVY-11002. I have the following program {code} import java.util.Comparator; class Foo {} class Bar { static Bar concat(Bar... x) { return null; } static Bar concat(Bar> x) { return null; } void toSortedSet(Comparator x) {} } class Main { static final void test() { Bar> x = null; Comparator> y = null; Bar.concat(x).toSortedSet(y); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: groovy35.groovy: 15: [Static type checking] - Cannot call Bar#concat(Bar>) with arguments [Bar>] @ line 15, column 15. Bar.concat(x).toSortedSet(y); ^ groovy35.groovy: 15: [Static type checking] - Cannot find matching method java.lang.Object#toSortedSet(java.util.Comparator>). Please check if the declared type is correct and if the method exists. @ line 15, column 5. Bar.concat(x).toSortedSet(y); ^ 2 errors {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: efe514a5e28828309e7decbfaf923b5c7f42b05d) To reproduce the bug, two overloaded methods are needed; one of them should contain variable arguments. Test cased adapted from the following program that uses the Guava library {code} import com.google.common.collect.*; import java.util.Comparator; class Foo {} class Main { static final void test() { Iterable> x = null; Comparator> y = null; FluentIterable.concat(x).toSortedSet(y); } } {code} was: This might be related to GROOVY-11002. I have the following program {code} import java.util.Comparator; class Bar { static Bar concat(Bar... x) { return null; } static Bar concat(Bar> x) { return null; } void toSortedSet(Comparator x) {} } class Main { static final void test() { Bar> x = null; Comparator> y = null; Bar.concat(x).toSortedSet(y); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: groovy35.groovy: 15: [Static type checking] - Cannot call Bar#concat(Bar>) with arguments [Bar>] @ line 15, column 15. Bar.concat(x).toSortedSet(y); ^ groovy35.groovy: 15: [Static type checking] - Cannot find matching method java.lang.Object#toSortedSet(java.util.Comparator>). Please check if the declared type is correct and if the method exists. @ line 15, column 5. Bar.concat(x).toSortedSet(y); ^ 2 errors {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: efe514a5e28828309e7decbfaf923b5c7f42b05d) To reproduce the bug, two overloaded methods are needed; one of them should contain variable arguments. Test cased adapted from the following program that uses the Guava library {code} import com.google.common.collect.*; import java.util.Comparator; class Foo {} class Main { static final void test() { Iterable> x = null; Comparator> y = null; FluentIterable.concat(x).toSortedSet(y); } } {code} > Resolving wrong overloaded method when having variable arguments > > > Key: GROOVY-11021 > URL: https://issues.apache.org/jira/browse/GROOVY-11021 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > Labels: overloading, varargs > > This might be related to GROOVY-11002. > I have the following program > {code} > import java.util.Comparator; > class Foo {} > class Bar { > static Bar concat(Bar... x) { return null; } > static Bar concat(Bar> x) { return null; > } > void toSortedSet(Comparator x) {} > } > class Main { > static final void test() { > Bar> x = null; > Comparator> y = null; > Bar.concat(x).toSortedSet(y); > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > groovy35.groovy: 15: [Static type checking] - Cannot call > Bar#concat(Bar>) with arguments > [Bar>] > @ line 15, column 15. >Bar.concat(x).toSortedSet(y); > ^ > groovy35.groovy: 15: [Static type checking] - Cannot find matching method > java.lang.Object#toSortedSet(java.util.Comparator>). > Please check if the declared type is correct and if the method exists. > @ line 15, column 5. >Bar.concat(x).toSortedSet(y); >^ > 2 errors > {code} > h3. Expected behavior > Compile successfully > h3. Notes > Tested against master (commit: efe514a5e28828309e7decbfaf923b5c7f42b05d) > To reproduce the bug, two overloaded methods are needed; one of them
[jira] [Created] (GROOVY-11074) Imprecise type for parameterized method when involving subtyping
Thodoris Sotiropoulos created GROOVY-11074: -- Summary: Imprecise type for parameterized method when involving subtyping Key: GROOVY-11074 URL: https://issues.apache.org/jira/browse/GROOVY-11074 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following code {code} class Main { static final void test() { Number x = 1; List y = m(x, 1); } static List m(T x, T y) { return null; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 4: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.List to: java.util.List @ line 4, column 22. List y = m(x, 1); ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: 73c0f12ab35427bc3e7fd76929b482df61e1b80d) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11073) Cannot infer type of parameterized method when dealing with arrays
Thodoris Sotiropoulos created GROOVY-11073: -- Summary: Cannot infer type of parameterized method when dealing with arrays Key: GROOVY-11073 URL: https://issues.apache.org/jira/browse/GROOVY-11073 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following code {code} class Main { static final void test() { double[] x = Tuple.tuple(org.codehaus.groovy.runtime.ArrayGroovyMethods.max((double[][]) null, { -> 1 })).getV1(); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 3: [Static type checking] - Cannot assign value of type (java.io.Serializable or java.lang.Cloneable) to variable of type double[] @ line 3, column 18. double[] x = Tuple.tuple(org.codehaus.groovy.runtime.ArrayGroovyMethods.max((double[][]) null, { -> 1 })).getV1(); ^ 1 error {code} h3. Expected behavior Compile successully Tested against master (commit: 73c0f12ab35427bc3e7fd76929b482df61e1b80d) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11066) Unable to call parameterized function that contains type variables with recursive bounds
[ https://issues.apache.org/jira/browse/GROOVY-11066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11066: --- Description: I have the following program that uses the guava lib. {code} class Main { static final void test() { String arg1 = null; Number arg2 = null; com.google.common.collect.ImmutableSortedMap.of(arg1, arg2); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 8: [Static type checking] - Cannot call ,V> com.google.common.collect.ImmutableSortedMap#of(K, V) with arguments [java.lang.String, java.lang.Number] @ line 8, column 5. com.google.common.collect.ImmutableSortedMap.of(arg1, arg2); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 7a118010591ca469f0394d8d6946b44201d04ebd) was: I have the following program that uses the guava lib. {code} class Main { static final void test() { String arg1 = null; Number arg2 = null; com.google.common.collect.ImmutableSortedMap.of(arg1, arg2); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 8: [Static type checking] - Cannot call ,V> com.google.common.collect.ImmutableSortedMap#of(K, V) with arguments [java.lang.String, java.util.List] @ line 8, column 5. com.google.common.collect.ImmutableSortedMap.>of(arg1, arg2); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 7a118010591ca469f0394d8d6946b44201d04ebd) > Unable to call parameterized function that contains type variables with > recursive bounds > > > Key: GROOVY-11066 > URL: https://issues.apache.org/jira/browse/GROOVY-11066 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > > I have the following program that uses the guava lib. > {code} > class Main { > static final void test() { > String arg1 = null; > Number arg2 = null; > com.google.common.collect.ImmutableSortedMap.of(arg1, > arg2); > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > Main.groovy: 8: [Static type checking] - Cannot call java.lang.Comparable,V> > com.google.common.collect.ImmutableSortedMap#of(K, V) with arguments > [java.lang.String, java.lang.Number] > @ line 8, column 5. >com.google.common.collect.ImmutableSortedMap.of(arg1, > arg2); >^ > 1 error > {code} > h3. Expected behavior > Compile successfully > h3. Notes > Tested against master (commit: 7a118010591ca469f0394d8d6946b44201d04ebd) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11066) Unable to call parameterized function that contains type variables with recursive bounds
Thodoris Sotiropoulos created GROOVY-11066: -- Summary: Unable to call parameterized function that contains type variables with recursive bounds Key: GROOVY-11066 URL: https://issues.apache.org/jira/browse/GROOVY-11066 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program that uses the guava lib. {code} class Main { static final void test() { String arg1 = null; Number arg2 = null; com.google.common.collect.ImmutableSortedMap.of(arg1, arg2); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 8: [Static type checking] - Cannot call ,V> com.google.common.collect.ImmutableSortedMap#of(K, V) with arguments [java.lang.String, java.util.List] @ line 8, column 5. com.google.common.collect.ImmutableSortedMap.>of(arg1, arg2); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 7a118010591ca469f0394d8d6946b44201d04ebd) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11065) STC takes the instantiation of a wrong type variable
[ https://issues.apache.org/jira/browse/GROOVY-11065?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11065: --- Component/s: Static Type Checker > STC takes the instantiation of a wrong type variable > > > Key: GROOVY-11065 > URL: https://issues.apache.org/jira/browse/GROOVY-11065 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > > I have the following program > {code} > import java.util.* > import java.util.function.*; > class LockVisitor { >T applyWriteLocked(Function func) {return null;} > } > class Main { > static final void test() { > Function> func = null; > LockVisitor rec = null; > var x = rec.applyWriteLocked(func); > X arg = null; > TreeSet y = new java.util.TreeSet<>(x) > y.floor(arg) > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 17: [Static type checking] - Cannot call > java.util.TreeSet#floor(java.util.PropertyPermission) with arguments [X] > @ line 17, column 5. >y.floor(arg) >^ > 1 error > {code} > h3. Expected behavior > Compile successfully > h3. Notes > Tested against master (commit: 62097da6116edb5d55a72c02c1a33042137e07d7) > The error happens when type variables of class LockVisitor and function > "test" have the same name. > The test case adapted from the following program that uses the > apache-commons-lang3 lib. > {code} > import java.util.* > import java.util.function.*; > import org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor; > import org.apache.commons.lang3.function.FailableFunction; > import org.apache.commons.lang3.concurrent.CircuitBreaker > class Main { > static final void test() { > FailableFunction>, ?> x = > null; > LockVisitor rec = null; > final var blandest = rec.applyWriteLocked(x); > TreeSet> y = new java.util.TreeSet<>(blandest) > final Set arg = null; > y.floor(arg) > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11065) STC takes the instantiation of a wrong type variable
[ https://issues.apache.org/jira/browse/GROOVY-11065?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11065: --- Priority: Minor (was: Major) > STC takes the instantiation of a wrong type variable > > > Key: GROOVY-11065 > URL: https://issues.apache.org/jira/browse/GROOVY-11065 > Project: Groovy > Issue Type: Bug >Reporter: Thodoris Sotiropoulos >Priority: Minor > > I have the following program > {code} > import java.util.* > import java.util.function.*; > class LockVisitor { >T applyWriteLocked(Function func) {return null;} > } > class Main { > static final void test() { > Function> func = null; > LockVisitor rec = null; > var x = rec.applyWriteLocked(func); > X arg = null; > TreeSet y = new java.util.TreeSet<>(x) > y.floor(arg) > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 17: [Static type checking] - Cannot call > java.util.TreeSet#floor(java.util.PropertyPermission) with arguments [X] > @ line 17, column 5. >y.floor(arg) >^ > 1 error > {code} > h3. Expected behavior > Compile successfully > h3. Notes > Tested against master (commit: 62097da6116edb5d55a72c02c1a33042137e07d7) > The error happens when type variables of class LockVisitor and function > "test" have the same name. > The test case adapted from the following program that uses the > apache-commons-lang3 lib. > {code} > import java.util.* > import java.util.function.*; > import org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor; > import org.apache.commons.lang3.function.FailableFunction; > import org.apache.commons.lang3.concurrent.CircuitBreaker > class Main { > static final void test() { > FailableFunction>, ?> x = > null; > LockVisitor rec = null; > final var blandest = rec.applyWriteLocked(x); > TreeSet> y = new java.util.TreeSet<>(blandest) > final Set arg = null; > y.floor(arg) > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11065) STC takes the instantiation of a wrong type variable
[ https://issues.apache.org/jira/browse/GROOVY-11065?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11065: --- Description: I have the following program {code} import java.util.* import java.util.function.*; class LockVisitor { T applyWriteLocked(Function func) {return null;} } class Main { static final void test() { Function> func = null; LockVisitor rec = null; var x = rec.applyWriteLocked(func); X arg = null; TreeSet y = new java.util.TreeSet<>(x) y.floor(arg) } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 17: [Static type checking] - Cannot call java.util.TreeSet#floor(java.util.PropertyPermission) with arguments [X] @ line 17, column 5. y.floor(arg) ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 62097da6116edb5d55a72c02c1a33042137e07d7) The error happens when type variables of class LockVisitor and function "test" have the same name. The test case adapted from the following program that uses the apache-commons-lang3 lib. {code} import java.util.* import java.util.function.*; import org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor; import org.apache.commons.lang3.function.FailableFunction; import org.apache.commons.lang3.concurrent.CircuitBreaker class Main { static final void test() { FailableFunction>, ?> x = null; LockVisitor rec = null; final var blandest = rec.applyWriteLocked(x); TreeSet> y = new java.util.TreeSet<>(blandest) final Set arg = null; y.floor(arg) } } {code} was: I have the following program {code} import java.util.* import java.util.function.*; class LockVisitor { T applyWriteLocked(Function func) {return null;} } class Main { static final void test() { Function> func = null; LockVisitor rec = null; var x = rec.applyWriteLocked(func); X arg = null; TreeSet y = new java.util.TreeSet<>(x) y.floor(arg) } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 17: [Static type checking] - Cannot call java.util.TreeSet#floor(java.util.PropertyPermission) with arguments [X] @ line 17, column 5. y.floor(arg) ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 62097da6116edb5d55a72c02c1a33042137e07d7) The error happens when type variables of class LockVisitor and function "test" have the same name. > STC takes the instantiation of a wrong type variable > > > Key: GROOVY-11065 > URL: https://issues.apache.org/jira/browse/GROOVY-11065 > Project: Groovy > Issue Type: Bug >Reporter: Thodoris Sotiropoulos >Priority: Major > > I have the following program > {code} > import java.util.* > import java.util.function.*; > class LockVisitor { >T applyWriteLocked(Function func) {return null;} > } > class Main { > static final void test() { > Function> func = null; > LockVisitor rec = null; > var x = rec.applyWriteLocked(func); > X arg = null; > TreeSet y = new java.util.TreeSet<>(x) > y.floor(arg) > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 17: [Static type checking] - Cannot call > java.util.TreeSet#floor(java.util.PropertyPermission) with arguments [X] > @ line 17, column 5. >y.floor(arg) >^ > 1 error > {code} > h3. Expected behavior > Compile successfully > h3. Notes > Tested against master (commit: 62097da6116edb5d55a72c02c1a33042137e07d7) > The error happens when type variables of class LockVisitor and function > "test" have the same name. > The test case adapted from the following program that uses the > apache-commons-lang3 lib. > {code} > import java.util.* > import java.util.function.*; > import org.apache.commons.lang3.concurrent.locks.LockingVisitors.LockVisitor; > import org.apache.commons.lang3.function.FailableFunction; > import org.apache.commons.lang3.concurrent.CircuitBreaker > class Main { > static final void test() { > FailableFunction>, ?> x = > null; > LockVisitor rec = null; > final var blandest = rec.applyWriteLocked(x); > TreeSet> y = new java.util.TreeSet<>(blandest) > final Set arg = null; > y.floor(arg) > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11065) STC takes the instantiation of a wrong type variable
Thodoris Sotiropoulos created GROOVY-11065: -- Summary: STC takes the instantiation of a wrong type variable Key: GROOVY-11065 URL: https://issues.apache.org/jira/browse/GROOVY-11065 Project: Groovy Issue Type: Bug Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.* import java.util.function.*; class LockVisitor { T applyWriteLocked(Function func) {return null;} } class Main { static final void test() { Function> func = null; LockVisitor rec = null; var x = rec.applyWriteLocked(func); X arg = null; TreeSet y = new java.util.TreeSet<>(x) y.floor(arg) } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 17: [Static type checking] - Cannot call java.util.TreeSet#floor(java.util.PropertyPermission) with arguments [X] @ line 17, column 5. y.floor(arg) ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 62097da6116edb5d55a72c02c1a33042137e07d7) The error happens when type variables of class LockVisitor and function "test" have the same name. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-10984) Unexpected parser error when having fully qualified classes and constructor references
[ https://issues.apache.org/jira/browse/GROOVY-10984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17723817#comment-17723817 ] Thodoris Sotiropoulos commented on GROOVY-10984: The same error happens when having inner classes whose outer class is a polymorphic one, e.g.,: {code} class Foo { class Bar {} } class Main { static final void test() { Foo.Bar x = null; } } {code} > Unexpected parser error when having fully qualified classes and constructor > references > -- > > Key: GROOVY-10984 > URL: https://issues.apache.org/jira/browse/GROOVY-10984 > Project: Groovy > Issue Type: Bug > Components: parser-antlr4 >Reporter: Thodoris Sotiropoulos >Priority: Minor > > I have the following program > {code} > import java.util.function.Supplier; > import java.util.PriorityQueue; > class Main { > static final void test() { > java.util.function.Supplier> x = > java.util.PriorityQueue::new; // parsing error > Supplier> y = PriorityQueue::new; // no > error > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 6: Unexpected input: '>::' @ line 6, column 101. >ava.util.PriorityQueue::new; > ^ > 1 error > {code} > h3. Expected behavior > Compile successfully > Tested against master (commit: dc54541306c937a81b8bb16fe4b023c2a7d8ccf2) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11053) Method ambiguity error when having methods with primitive arrays and varargs
Thodoris Sotiropoulos created GROOVY-11053: -- Summary: Method ambiguity error when having methods with primitive arrays and varargs Key: GROOVY-11053 URL: https://issues.apache.org/jira/browse/GROOVY-11053 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program (it uses the apache-commons-lang3 library) {code} class Main { static final void test() { final byte[] vetting = new byte[1]; final byte[] grafting = org.apache.commons.lang3.ArrayUtils.removeAll(vetting); // works final byte[] grafting = org.apache.commons.lang3.ArrayUtils.removeAll(vetting, 0); // fails } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: groovy38.groovy: 4: [Static type checking] - Reference to method is ambiguous. Cannot choose between [byte[] org.apache.commons.lang3.ArrayUtils#removeAll(byte[], int[]), long[] org.apache.commons.lang3.ArrayUtils#removeAll(long[], int[]), float[] org.apache.commons.lang3.ArrayUtils#removeAll(float[], int[]), double[] org.apache.commons.lang3.ArrayUtils#removeAll(double[], int[]), int[] org.apache.commons.lang3.ArrayUtils#removeAll(int[], int[]), short[] org.apache.commons.lang3.ArrayUtils#removeAll(short[], int[])] @ line 4, column 29. final byte[] grafting = org.apache.commons.lang3.ArrayUtils.removeAll(vetting, 0); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Tested against master (commit: 7a4b2679c77aea8cd9dc00fa2d3b71e25e97fbd2) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11050) Unable to construct Map with repeating key/value entries
Thodoris Sotiropoulos created GROOVY-11050: -- Summary: Unable to construct Map with repeating key/value entries Key: GROOVY-11050 URL: https://issues.apache.org/jira/browse/GROOVY-11050 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} class Main { static final void test() { V key = null; CharSequence value = null; java.util.Map.of(key, value); // succeeds java.util.Map.of(key, value, key, value); // fails } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 6: [Static type checking] - Cannot call java.util.Map#of(K, V, K, V) with arguments [V, java.lang.CharSequence, V, java.lang.CharSequence] @ line 6, column 5. java.util.Map.of(key, value, key, value); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 7a4b2679c77aea8cd9dc00fa2d3b71e25e97fbd2) The bug is triggered when the variable key has type "V". -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11047) Fail to catch incompatible return type of lambdas
Thodoris Sotiropoulos created GROOVY-11047: -- Summary: Fail to catch incompatible return type of lambdas Key: GROOVY-11047 URL: https://issues.apache.org/jira/browse/GROOVY-11047 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Probably related to GROOVY-10277. I have the following program {code} class Main { static final void test() { java.util.stream.StreamSupport.stream(()-> 1, 1, false); // Error, the return type of lamba is not compatible with the expected type. } } {code} h3. Actual behavior The compiler accepts the program h3. Expected behavior Reject the program with an error of the form: "error: incompatible types: bad return type in lambda expression" -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11046) Better diagnostic message instead of stacktrace?
Thodoris Sotiropoulos created GROOVY-11046: -- Summary: Better diagnostic message instead of stacktrace? Key: GROOVY-11046 URL: https://issues.apache.org/jira/browse/GROOVY-11046 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos The following program that uses the log4j-core library {code} class Test { void test() { org.apache.logging.log4j.core.async.AsyncLogger d = null; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during conversion: java.lang.NoClassDefFoundError: com.lmax.disruptor.EventTranslatorVararg java.lang.RuntimeException: java.lang.NoClassDefFoundError: com.lmax.disruptor.EventTranslatorVararg at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:982) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:694) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:668) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:649) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189) Caused by: java.lang.NoClassDefFoundError: com.lmax.disruptor.EventTranslatorVararg at org.codehaus.groovy.ast.decompiled.AsmReferenceResolver.resolveClass(AsmReferenceResolver.java:46) at org.codehaus.groovy.ast.decompiled.TypeSignatureParser.visitEnd(TypeSignatureParser.java:113) at groovyjarjarasm.asm.signature.SignatureReader.parseType(SignatureReader.java:206) at groovyjarjarasm.asm.signature.SignatureReader.accept(SignatureReader.java:124) at org.codehaus.groovy.ast.decompiled.ClassSignatureParser.parseClassSignature(ClassSignatureParser.java:111) at org.codehaus.groovy.ast.decompiled.ClassSignatureParser.configureClass(ClassSignatureParser.java:35) at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.lazyInitSupers(DecompiledClassNode.java:189) at org.codehaus.groovy.ast.decompiled.DecompiledClassNode.getGenericsTypes(DecompiledClassNode.java:148) at org.codehaus.groovy.control.GenericsVisitor.checkGenericsUsage(GenericsVisitor.java:157) at org.codehaus.groovy.control.GenericsVisitor.checkGenericsUsage(GenericsVisitor.java:151) at org.codehaus.groovy.control.GenericsVisitor.visitDeclarationExpression(GenericsVisitor.java:113) at org.codehaus.groovy.ast.expr.DeclarationExpression.visit(DeclarationExpression.java:92) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:212) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:175) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:139) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:118) at org.codehaus.groovy.control.GenericsVisitor.visitConstructorOrMethod(GenericsVisitor.java:93) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1142) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1135) at org.codehaus.groovy.control.GenericsVisitor.visitClass(GenericsVisitor.java:74) at org.codehaus.groovy.control.CompilationUnit.lambda$addPhaseOperations$7(CompilationUnit.java:238) at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:948) ... 8 more 1 error {code} h3. Expected behavior Reject the program with an appropriate diagnostic message when "com.lmax.disruptor.EventTranslatorVararg" is not in the classpath. -- This message was sent by Atlassian Jira
[jira] [Created] (GROOVY-11042) Wrong method is chosen from the Groovy runtime
Thodoris Sotiropoulos created GROOVY-11042: -- Summary: Wrong method is chosen from the Groovy runtime Key: GROOVY-11042 URL: https://issues.apache.org/jira/browse/GROOVY-11042 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following code {code} class Main { static final void test() { String[] p1 = new String[]{"v2"}; String[] p2 = new String[]{"v1"}; java.util.TreeMap x = null; x.subMap(p1, p2); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 6: [Static type checking] - Cannot call org.codehaus.groovy.runtime.DefaultGroovyMethods#subMap(java.util.Map, K[]) with arguments [java.util.TreeMap, java.lang.String[], java.lang.String[]] @ line 6, column 5. x.subMap(p1, p2); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: ce357be7e43542480a8e01f383aac69b19e1fe8f) Perhaps, an incorrect method is chosen (see https://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html#subMap(java.util.Map,K%5B%5D)) instead of https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/util/TreeMap.html#subMap(K,K). -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11036) StackOverflowError in cyclic interface inheritance
Thodoris Sotiropoulos created GROOVY-11036: -- Summary: StackOverflowError in cyclic interface inheritance Key: GROOVY-11036 URL: https://issues.apache.org/jira/browse/GROOVY-11036 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} interface Bar {} interface Foo extends Foo, Bar {} {code} h3. Actual behavior {code} >>> a serious error occurred: null >>> stacktrace: java.lang.StackOverflowError at org.codehaus.groovy.ast.ClassNode.getText(ClassNode.java:1606) at org.codehaus.groovy.ast.ClassNode.hashCode(ClassNode.java:734) at org.codehaus.groovy.ast.ClassNode.hashCode(ClassNode.java:734) at java.base/java.util.HashMap.hash(HashMap.java:339) at java.base/java.util.HashMap.put(HashMap.java:607) at java.base/java.util.HashSet.add(HashSet.java:220) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:466) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at org.codehaus.groovy.ast.ClassNode.getAllInterfaces(ClassNode.java:470) at
[jira] [Created] (GROOVY-11035) Inferred type is Object when having a complex inheritance chain interfaces
Thodoris Sotiropoulos created GROOVY-11035: -- Summary: Inferred type is Object when having a complex inheritance chain interfaces Key: GROOVY-11035 URL: https://issues.apache.org/jira/browse/GROOVY-11035 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos This seems related to GROOVY-11012. I have the following program {code} import org.apache.commons.collections4.iterators.*; class Main { static final void test() { EmptyListIterator tmp = null; Number x = tmp.next(); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 6: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type java.lang.Number @ line 6, column 16. Number x = tmp.next(); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: ed4b33c8d5ac71ee4963d6bb391850593c59e5b1) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11035) Inferred type is Object when having a complex inheritance chain of interfaces
[ https://issues.apache.org/jira/browse/GROOVY-11035?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11035: --- Summary: Inferred type is Object when having a complex inheritance chain of interfaces (was: Inferred type is Object when having a complex inheritance chain interfaces) > Inferred type is Object when having a complex inheritance chain of interfaces > - > > Key: GROOVY-11035 > URL: https://issues.apache.org/jira/browse/GROOVY-11035 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > > This seems related to GROOVY-11012. > I have the following program > {code} > import org.apache.commons.collections4.iterators.*; > class Main { > static final void test() { > EmptyListIterator tmp = null; > Number x = tmp.next(); > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 6: [Static type checking] - Cannot assign value of type > java.lang.Object to variable of type java.lang.Number > @ line 6, column 16. >Number x = tmp.next(); > ^ > 1 error > {code} > h3. Expected behavior > Compile successfully > h3. Notes > Tested against master (commit: ed4b33c8d5ac71ee4963d6bb391850593c59e5b1) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-11020) NullPointerException in instruction selection when calling parameterized function whose type parameter has an upper bound corresponding to a SAM type
[ https://issues.apache.org/jira/browse/GROOVY-11020?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17717539#comment-17717539 ] Thodoris Sotiropoulos commented on GROOVY-11020: Interstingly, the following program still crashes the compiler: {code} import java.util.*; import java.util.function.*; class Main { static final void test(Iterator x, ArrayDeque y) { org.apache.commons.collections4.CollectionUtils.forAllButLastDo(x, y::addFirst); } } {code} > NullPointerException in instruction selection when calling parameterized > function whose type parameter has an upper bound corresponding to a SAM type > - > > Key: GROOVY-11020 > URL: https://issues.apache.org/jira/browse/GROOVY-11020 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Assignee: Eric Milles >Priority: Minor > Fix For: 4.0.12 > > > I have the following code > {code} > import java.util.*; > import java.util.function.*; > class Main { > static final void test(ArrayDeque y) { > > m(y::addFirst); > } > static > void m(C cl) {} > } > {code} > h3. Actual behavior > The compiler crashes with the following stacktrace: > {code} > >>> a serious error occurred: BUG! exception in phase 'instruction selection' > >>> in source unit 'Main.groovy' unexpected NullPointerException > >>> stacktrace: > BUG! exception in phase 'instruction selection' in source unit 'Main.groovy' > unexpected NullPointerException > at > org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:953) > at > org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:694) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:668) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:649) > at > org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311) > at > org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240) > at > org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165) > at > org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205) > at > org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189) > Caused by: java.lang.NullPointerException > at > org.codehaus.groovy.ast.tools.GenericsUtils.parameterizeSAM(GenericsUtils.java:974) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferClosureParameterTypes(StaticTypeCheckingVisitor.java:3110) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2904) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitStaticMethodCallExpression(StaticTypeCheckingVisitor.java:2819) > at > org.codehaus.groovy.ast.expr.StaticMethodCallExpression.visit(StaticMethodCallExpression.java:44) > at > org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:212) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2217) > at > org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) > at > org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:175) > at > org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:139) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:118) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitConstructorOrMethod$28(StaticTypeCheckingVisitor.java:2680) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doWithTypeCheckingExtensions(StaticTypeCheckingVisitor.java:463) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2680) > at >
[jira] [Updated] (GROOVY-11026) NPE when checking compatibility of method reference
[ https://issues.apache.org/jira/browse/GROOVY-11026?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11026: --- Description: I have the following program {code} import java.util.function.*; import java.util.List; class Main { static final void test() { List x = null; m(x::set); } static final void m(BiFunction y) {} } {code} h3. Actual behavior {code} BUG! exception in phase 'instruction selection' in source unit 'test.groovy' unexpected NullPointerException at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:953) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:694) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:668) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:649) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189) Caused by: java.lang.NullPointerException at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkCompatibleAssignmentTypes(StaticTypeCheckingSupport.java:725) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitMethodPointerExpression$25(StaticTypeCheckingVisitor.java:2504) at java.base/java.util.Optional.ifPresent(Optional.java:183) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodPointerExpression(StaticTypeCheckingVisitor.java:2496) at org.codehaus.groovy.ast.CodeVisitorSupport.visitMethodReferenceExpression(CodeVisitorSupport.java:319) at org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2912) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitStaticMethodCallExpression(StaticTypeCheckingVisitor.java:2820) at org.codehaus.groovy.ast.expr.StaticMethodCallExpression.visit(StaticMethodCallExpression.java:44) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:212) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2217) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:175) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:139) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:118) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitConstructorOrMethod$28(StaticTypeCheckingVisitor.java:2681) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doWithTypeCheckingExtensions(StaticTypeCheckingVisitor.java:463) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2681) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2664) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2643) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitConstructorOrMethod(StaticCompilationVisitor.java:189) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:204) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1144) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1137) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at
[jira] [Created] (GROOVY-11026) NPE when checking compatibility of method reference
Thodoris Sotiropoulos created GROOVY-11026: -- Summary: NPE when checking compatibility of method reference Key: GROOVY-11026 URL: https://issues.apache.org/jira/browse/GROOVY-11026 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.*; import java.util.List; class Main { static final void test() { List x = null; m(x::set); } static final void m(BiFunction y) {} } {code} h3. Actual behavior {code} BUG! exception in phase 'instruction selection' in source unit 'test.groovy' unexpected NullPointerException at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:953) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:694) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:668) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:649) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189) Caused by: java.lang.NullPointerException at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkCompatibleAssignmentTypes(StaticTypeCheckingSupport.java:725) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitMethodPointerExpression$25(StaticTypeCheckingVisitor.java:2504) at java.base/java.util.Optional.ifPresent(Optional.java:183) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodPointerExpression(StaticTypeCheckingVisitor.java:2496) at org.codehaus.groovy.ast.CodeVisitorSupport.visitMethodReferenceExpression(CodeVisitorSupport.java:319) at org.codehaus.groovy.ast.expr.MethodReferenceExpression.visit(MethodReferenceExpression.java:34) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2912) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitStaticMethodCallExpression(StaticTypeCheckingVisitor.java:2820) at org.codehaus.groovy.ast.expr.StaticMethodCallExpression.visit(StaticMethodCallExpression.java:44) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:212) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2217) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:175) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:139) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:118) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitConstructorOrMethod$28(StaticTypeCheckingVisitor.java:2681) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doWithTypeCheckingExtensions(StaticTypeCheckingVisitor.java:463) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2681) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2664) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2643) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitConstructorOrMethod(StaticCompilationVisitor.java:189) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:204) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1144) at
[jira] [Commented] (GROOVY-10754) Incompatible generic argument types when using wildcards
[ https://issues.apache.org/jira/browse/GROOVY-10754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17716719#comment-17716719 ] Thodoris Sotiropoulos commented on GROOVY-10754: [~emilles]The master version of Groovy does compile this program. > Incompatible generic argument types when using wildcards > > > Key: GROOVY-10754 > URL: https://issues.apache.org/jira/browse/GROOVY-10754 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Assignee: Eric Milles >Priority: Minor > > I have the following program > {code} > class A {} > class B extends A {} > class C, U extends T> { > C(T x, U v) {} > } > class Test { > void test(B x, B y) { > C z = new C<>(x, y); > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 12: [Static type checking] - Incompatible generic argument > types. Cannot assign C, B> to: C B> > @ line 12, column 37. >C z = new C<>(x, y); >^ > 1 error > {code} > h3. Expected behavior > Compile successfully > *Notes*: The bug happens only when the class named C has two type parameters, > and the second parameter is bounded to the first one > Tested against master (commit: 099cf5b3f0ca61ea5daa72ebcea66ef09a74fd84) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11025) Conficts between type parameter names result in unexpected type error
Thodoris Sotiropoulos created GROOVY-11025: -- Summary: Conficts between type parameter names result in unexpected type error Key: GROOVY-11025 URL: https://issues.apache.org/jira/browse/GROOVY-11025 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.Map; import java.util.List; class Main { static void m(Map map, K key, V value) {} static final void test() { Map, K> map = null; List key = null; K value = null; Main.m(map, key, value); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 11: [Static type checking] - Cannot find matching method Main#m(java.util.Map, K>, java.util.List, K). Please check if the declared type is correct and if the method exists. @ line 11, column 5. Main.m(map, key, value); ^ {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 8346e3406ed51dd071a2d31792d3fbad543585a7) The error is triggered only when instantiating method m with a type variable of the same name as its first type parameter. Test case adapted from the following program that uses the apache-commons-lang3 lib: {code} import java.util.List; import java.util.concurrent.ConcurrentMap; import org.apache.commons.lang3.concurrent.ConcurrentInitializer; import org.apache.commons.lang3.concurrent.ConcurrentUtils; class Main { static final void test() { ConcurrentMap, K> map = null; List key = null; ConcurrentInitializer init = null; ConcurrentUtils., K>createIfAbsentUnchecked(map, key, init); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-11021) Resolving wrong overloaded method when having variable arguments
[ https://issues.apache.org/jira/browse/GROOVY-11021?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11021: --- Labels: overloading varargs (was: varargs) > Resolving wrong overloaded method when having variable arguments > > > Key: GROOVY-11021 > URL: https://issues.apache.org/jira/browse/GROOVY-11021 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > Labels: overloading, varargs > > This might be related to GROOVY-11002. > I have the following program > {code} > import java.util.Comparator; > class Bar { > static Bar concat(Bar... x) { return null; } > static Bar concat(Bar> x) { return null; > } > void toSortedSet(Comparator x) {} > } > class Main { > static final void test() { > Bar> x = null; > Comparator> y = null; > Bar.concat(x).toSortedSet(y); > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > groovy35.groovy: 15: [Static type checking] - Cannot call > Bar#concat(Bar>) with arguments > [Bar>] > @ line 15, column 15. >Bar.concat(x).toSortedSet(y); > ^ > groovy35.groovy: 15: [Static type checking] - Cannot find matching method > java.lang.Object#toSortedSet(java.util.Comparator>). > Please check if the declared type is correct and if the method exists. > @ line 15, column 5. >Bar.concat(x).toSortedSet(y); >^ > 2 errors > {code} > h3. Expected behavior > Compile successfully > h3. Notes > Tested against master (commit: efe514a5e28828309e7decbfaf923b5c7f42b05d) > To reproduce the bug, two overloaded methods are needed; one of them should > contain variable arguments. > Test cased adapted from the following program that uses the Guava library > {code} > import com.google.common.collect.*; > import java.util.Comparator; > class Foo {} > class Main { > static final void test() { > Iterable> x = null; > Comparator> y = null; > FluentIterable.concat(x).toSortedSet(y); > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11022) StackOverflowError when having parameterized function with recursive bounds
Thodoris Sotiropoulos created GROOVY-11022: -- Summary: StackOverflowError when having parameterized function with recursive bounds Key: GROOVY-11022 URL: https://issues.apache.org/jira/browse/GROOVY-11022 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} class Test { public static , V> Test m(K k1, V v1) { return new Test(); } } public class Main { static void test() { Test.m(null, 1); } } {code} h3. Actual behavior {code} >>> a serious error occurred: null >>> stacktrace: java.lang.StackOverflowError at org.codehaus.groovy.ast.ClassNode.getText(ClassNode.java:1606) at org.codehaus.groovy.ast.ClassNode.equals(ClassNode.java:729) at org.codehaus.groovy.ast.ClassHelper.isObjectType(ClassHelper.java:525) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.hasNonTrivialBounds(StaticTypeCheckingSupport.java:1880) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1833) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1821) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1905) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1843) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1821) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1905) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1890) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1834) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1821) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1905) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1843) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1821) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1905) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1890) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1834) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1821) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1905) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1843) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1821) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1905) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1890) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1834) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1821) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1905) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1843) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1821) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1905) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1890) at org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext(StaticTypeCheckingSupport.java:1834) at
[jira] [Updated] (GROOVY-11021) Resolving wrong overloaded method when having variable arguments
[ https://issues.apache.org/jira/browse/GROOVY-11021?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-11021: --- Labels: varargs (was: ) > Resolving wrong overloaded method when having variable arguments > > > Key: GROOVY-11021 > URL: https://issues.apache.org/jira/browse/GROOVY-11021 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Minor > Labels: varargs > > This might be related to GROOVY-11002. > I have the following program > {code} > import java.util.Comparator; > class Bar { > static Bar concat(Bar... x) { return null; } > static Bar concat(Bar> x) { return null; > } > void toSortedSet(Comparator x) {} > } > class Main { > static final void test() { > Bar> x = null; > Comparator> y = null; > Bar.concat(x).toSortedSet(y); > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > groovy35.groovy: 15: [Static type checking] - Cannot call > Bar#concat(Bar>) with arguments > [Bar>] > @ line 15, column 15. >Bar.concat(x).toSortedSet(y); > ^ > groovy35.groovy: 15: [Static type checking] - Cannot find matching method > java.lang.Object#toSortedSet(java.util.Comparator>). > Please check if the declared type is correct and if the method exists. > @ line 15, column 5. >Bar.concat(x).toSortedSet(y); >^ > 2 errors > {code} > h3. Expected behavior > Compile successfully > h3. Notes > Tested against master (commit: efe514a5e28828309e7decbfaf923b5c7f42b05d) > To reproduce the bug, two overloaded methods are needed; one of them should > contain variable arguments. > Test cased adapted from the following program that uses the Guava library > {code} > import com.google.common.collect.*; > import java.util.Comparator; > class Foo {} > class Main { > static final void test() { > Iterable> x = null; > Comparator> y = null; > FluentIterable.concat(x).toSortedSet(y); > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11021) Resolving wrong overloaded method when having variable arguments
Thodoris Sotiropoulos created GROOVY-11021: -- Summary: Resolving wrong overloaded method when having variable arguments Key: GROOVY-11021 URL: https://issues.apache.org/jira/browse/GROOVY-11021 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos This might be related to GROOVY-11002. I have the following program {code} import java.util.Comparator; class Bar { static Bar concat(Bar... x) { return null; } static Bar concat(Bar> x) { return null; } void toSortedSet(Comparator x) {} } class Main { static final void test() { Bar> x = null; Comparator> y = null; Bar.concat(x).toSortedSet(y); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: groovy35.groovy: 15: [Static type checking] - Cannot call Bar#concat(Bar>) with arguments [Bar>] @ line 15, column 15. Bar.concat(x).toSortedSet(y); ^ groovy35.groovy: 15: [Static type checking] - Cannot find matching method java.lang.Object#toSortedSet(java.util.Comparator>). Please check if the declared type is correct and if the method exists. @ line 15, column 5. Bar.concat(x).toSortedSet(y); ^ 2 errors {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: efe514a5e28828309e7decbfaf923b5c7f42b05d) To reproduce the bug, two overloaded methods are needed; one of them should contain variable arguments. Test cased adapted from the following program that uses the Guava library {code} import com.google.common.collect.*; import java.util.Comparator; class Foo {} class Main { static final void test() { Iterable> x = null; Comparator> y = null; FluentIterable.concat(x).toSortedSet(y); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11020) NullPointerException in instruction selection when calling parameterized function whose type parameter has an upper bound corresponding to a SAM type
Thodoris Sotiropoulos created GROOVY-11020: -- Summary: NullPointerException in instruction selection when calling parameterized function whose type parameter has an upper bound corresponding to a SAM type Key: GROOVY-11020 URL: https://issues.apache.org/jira/browse/GROOVY-11020 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following code {code} import java.util.*; import java.util.function.*; class Main { static final void test(ArrayDeque y) { m(y::addFirst); } static > void m(C cl) {} } {code} h3. Actual behavior The compiler crashes with the following stacktrace: {code} >>> a serious error occurred: BUG! exception in phase 'instruction selection' >>> in source unit 'Main.groovy' unexpected NullPointerException >>> stacktrace: BUG! exception in phase 'instruction selection' in source unit 'Main.groovy' unexpected NullPointerException at org.codehaus.groovy.control.CompilationUnit$IPrimaryClassNodeOperation.doPhaseOperation(CompilationUnit.java:953) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:694) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:668) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:649) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:311) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:240) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:165) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:205) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:189) Caused by: java.lang.NullPointerException at org.codehaus.groovy.ast.tools.GenericsUtils.parameterizeSAM(GenericsUtils.java:974) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferClosureParameterTypes(StaticTypeCheckingVisitor.java:3110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2904) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitStaticMethodCallExpression(StaticTypeCheckingVisitor.java:2819) at org.codehaus.groovy.ast.expr.StaticMethodCallExpression.visit(StaticMethodCallExpression.java:44) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:117) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:212) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitExpressionStatement(StaticTypeCheckingVisitor.java:2217) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:41) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:86) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:175) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:72) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:139) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:118) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.lambda$visitConstructorOrMethod$28(StaticTypeCheckingVisitor.java:2680) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.doWithTypeCheckingExtensions(StaticTypeCheckingVisitor.java:463) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:2680) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2663) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2642) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitConstructorOrMethod(StaticCompilationVisitor.java:189) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:204) at org.codehaus.groovy.ast.ClassNode.visitMethods(ClassNode.java:1144) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1137) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:52) at
[jira] [Created] (GROOVY-11013) Fail to substitute type when having SAM type with generics
Thodoris Sotiropoulos created GROOVY-11013: -- Summary: Fail to substitute type when having SAM type with generics Key: GROOVY-11013 URL: https://issues.apache.org/jira/browse/GROOVY-11013 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.*; @FunctionalInterface interface Foo { int m(List x); } class Main { static final void test() { Foo p = (List x) -> 1; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 11: [Static type checking] - Expected type java.util.List for lambda parameter: x @ line 11, column 22. Foo p = (List x) -> 1; ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: cdc57551a7cce33ec7031b40753f25c869dcf0cc) Test case adapted from the following program that uses the apache-commons-collection4 lib {code} class Main { static final void test() { org.apache.commons.collections4.sequence.ReplacementsHandler f = (int x, List y, List z) -> { } ; } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11012) Wrong type is inferred when calling method defined in the parent class
Thodoris Sotiropoulos created GROOVY-11012: -- Summary: Wrong type is inferred when calling method defined in the parent class Key: GROOVY-11012 URL: https://issues.apache.org/jira/browse/GROOVY-11012 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} interface Bar { default V get(Object x, Object y) { return null; } } class Foo implements Bar { static Foo create() { return null; } } class Main { static final void test() { Number x = Foo.create().get(null, null); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 11: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type java.lang.Number @ line 11, column 16. Number x = Foo.create().get(null, null); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 5bcd83e0fde722971f97d479f1a4d6da6cd4aa5f) Test cased adapt from the following program that uses the Guava lib {code} import com.google.common.collect.HashBasedTable; class Main { static final void test() { Number x = HashBasedTable.create().get(null, null); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11010) Ambiguous method reference when expecting a SAM type
Thodoris Sotiropoulos created GROOVY-11010: -- Summary: Ambiguous method reference when expecting a SAM type Key: GROOVY-11010 URL: https://issues.apache.org/jira/browse/GROOVY-11010 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.*; class Main { static final void test() { from(Main::m); } static void from(Function f) {} static void from(Supplier f) {} static int m(String x) { return 1; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 6: [Static type checking] - Reference to method is ambiguous. Cannot choose between [void Main#from(java.util.function.Supplier), void Main#from(java.util.function.Function)] @ line 6, column 5. from(Main::m); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: 5bcd83e0fde722971f97d479f1a4d6da6cd4aa5f) Test case adapted from (Guava library) {code} import java.util.function.*; class Main { static final void test() { com.google.common.cache.CacheLoader.from(Main::m); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11009) STC resolves wrong method reference
Thodoris Sotiropoulos created GROOVY-11009: -- Summary: STC resolves wrong method reference Key: GROOVY-11009 URL: https://issues.apache.org/jira/browse/GROOVY-11009 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos This is probably a regression I have the following program {code} import java.util.function.*; class Main { static final void test() { final Function x = Main::clone; } public static T clone(T x) { return x; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 5: [Static type checking] - Invalid return type: java.lang.Object is not convertible to java.lang.Double @ line 5, column 40. final Function x = Main::clone; ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: c4ee3ce0661eec7d633fc81281d79c8889b3dc66) Test case adapted from: {code} import java.util.function.*; class Main { static final void test() { Function x = org.apache.commons.lang3.ObjectUtils::clone; } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11004) Incompatible generic argument types when mixing diamond operator in parameterized function
Thodoris Sotiropoulos created GROOVY-11004: -- Summary: Incompatible generic argument types when mixing diamond operator in parameterized function Key: GROOVY-11004 URL: https://issues.apache.org/jira/browse/GROOVY-11004 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos This might be a regression, as Groovy 4.0.10 accepts the program. I have the following program {code} import java.util.*; class Main { static final void test() { Map x = null; Map y = Collections.unmodifiableNavigableMap(new TreeMap<>(x)); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 6: [Static type checking] - Incompatible generic argument types. Cannot assign java.util.NavigableMap to: java.util.Map @ line 6, column 29. Map y = Collections.unmodifiableNavigableMap(new TreeMap<>(x)); ^ 1 error {code} h3. Expected behavior Compile successfully -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11003) Cannot find method with variable arguments when using fully qualified class names
Thodoris Sotiropoulos created GROOVY-11003: -- Summary: Cannot find method with variable arguments when using fully qualified class names Key: GROOVY-11003 URL: https://issues.apache.org/jira/browse/GROOVY-11003 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} class Main { static final void test(java.util.List p) { m(1, p); } static void m(Integer x, java.util.List... items) { } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 3: [Static type checking] - Cannot find matching method Main#m(int, java.util.List). Please check if the declared type is correct and if the method exists. @ line 3, column 5. m(1, p); ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: a4e0d6de9cc2d8ecb48b48df501e63ec1735d837) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-11002) Unexpected type mismatch when having overloaded methods with variable arguments
Thodoris Sotiropoulos created GROOVY-11002: -- Summary: Unexpected type mismatch when having overloaded methods with variable arguments Key: GROOVY-11002 URL: https://issues.apache.org/jira/browse/GROOVY-11002 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.Supplier; class Main { static final void test() { Main.m(() -> "df", "fdaf"); } static void m(Supplier x, T... y) {} static > void m(T...y) {} } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 5: [Static type checking] - Cannot return value of type java.lang.String for lambda expecting int @ line 5, column 26. Main.m(() -> "df", "fdaf"); ^ 1 error {code} h3. Expected behavior Compile successfully h3. Notes Tested against master (commit: a4e0d6de9cc2d8ecb48b48df501e63ec1735d837) Test case adapted from: {code} class Main { static final void test() { org.apache.commons.lang3.ObjectUtils.median((stills, impeaches) -> 86 , "fdaf"); } } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10999) Unexpected type mismatch when having bounded type parameters
Thodoris Sotiropoulos created GROOVY-10999: -- Summary: Unexpected type mismatch when having bounded type parameters Key: GROOVY-10999 URL: https://issues.apache.org/jira/browse/GROOVY-10999 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos This might be related to GROOVY-10629. I have the following program: {code} class Main { static final void test() { def x = java.util.Collections.emptyNavigableMap().ceilingKey((H) null); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 3: [Static type checking] - Cannot call java.util.NavigableMap#ceilingKey(H) with arguments [H] @ line 3, column 13. def x = java.util.Collections.emptyNavigableMap().ceilingKey((H) null); ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: 72cae725137e3a610b94e6927b18587c439f6f9b) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10998) Not reporting cyclic dependency in function's type parameters
Thodoris Sotiropoulos created GROOVY-10998: -- Summary: Not reporting cyclic dependency in function's type parameters Key: GROOVY-10998 URL: https://issues.apache.org/jira/browse/GROOVY-10998 Project: Groovy Issue Type: Bug Reporter: Thodoris Sotiropoulos This is related to GROOVY-10113. The check for detecting cycles in type parameters is not there for parameterized functions. {code} class Test { static void test() {} } {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10997) Unexpected type mismatch when using super on a bounded type parameter
Thodoris Sotiropoulos created GROOVY-10997: -- Summary: Unexpected type mismatch when using super on a bounded type parameter Key: GROOVY-10997 URL: https://issues.apache.org/jira/browse/GROOVY-10997 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.stream.*; import java.util.function.*; class Main { static final void test() { Stream x = null; Consumer y = null; x.forEach(y); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: groovy30.groovy: 9: [Static type checking] - Cannot call java.util.stream.Stream#forEach(java.util.function.Consumer) with arguments [java.util.function.Consumer] @ line 9, column 5. x.forEach(y); ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: 72cae725137e3a610b94e6927b18587c439f6f9b) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10994) Fail to resolve method reference with generics
Thodoris Sotiropoulos created GROOVY-10994: -- Summary: Fail to resolve method reference with generics Key: GROOVY-10994 URL: https://issues.apache.org/jira/browse/GROOVY-10994 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.List; import java.util.function.Predicate; class Main { static final void test() { List x = null; Predicate y = x::add; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 9: Failed to find method 'add(T)' for the type: java.util.List @ line 9, column 30. Predicate y = x::add; ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: a29ce1ce64d565526b70e145ace665dd0617ec9b) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10992) Unexpected type mismatch when calling a parameterized function with a bounded type parameter
Thodoris Sotiropoulos created GROOVY-10992: -- Summary: Unexpected type mismatch when calling a parameterized function with a bounded type parameter Key: GROOVY-10992 URL: https://issues.apache.org/jira/browse/GROOVY-10992 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Possible regression? Groovyc 4.0.10 compiles the program I have the following program {code} import java.util.function.Supplier; import java.util.function.BinaryOperator; import java.util.stream.Stream; class Main { static final void test() { Supplier> x = null; X y = null; BinaryOperator z = null; X result = x.get().reduce(y, z); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 11: [Static type checking] - Cannot call java.util.stream.Stream#reduce(X, java.util.function.BinaryOperator) with arguments [X, java.util.function.BinaryOperator] @ line 11, column 16. X result = x.get().reduce(y, z); ^ 1 error {code} h3. Expected behavior Compile successfully Notes: The type parameter X should have an upper bound in order to trigger the error. Tested against master (commit: a29ce1ce64d565526b70e145ace665dd0617ec9b) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (GROOVY-10984) Unexpected parser error when having fully qualified classes and constructor references
[ https://issues.apache.org/jira/browse/GROOVY-10984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17705883#comment-17705883 ] Thodoris Sotiropoulos edited comment on GROOVY-10984 at 3/28/23 8:51 AM: - Ah I see. It seems that the Java syntax allows type arguments on the left of "::" only for constructor references. was (Author: theosot): Ah I see. It seems that the Java syntax allows type arguments on the right of "::" only for constructor references. > Unexpected parser error when having fully qualified classes and constructor > references > -- > > Key: GROOVY-10984 > URL: https://issues.apache.org/jira/browse/GROOVY-10984 > Project: Groovy > Issue Type: Bug > Components: parser-antlr4 >Reporter: Thodoris Sotiropoulos >Priority: Major > > I have the following program > {code} > import java.util.function.Supplier; > import java.util.PriorityQueue; > class Main { > static final void test() { > java.util.function.Supplier> x = > java.util.PriorityQueue::new; // parsing error > Supplier> y = PriorityQueue::new; // no > error > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 6: Unexpected input: '>::' @ line 6, column 101. >ava.util.PriorityQueue::new; > ^ > 1 error > {code} > h3. Expected behavior > Compile successfully > Tested against master (commit: dc54541306c937a81b8bb16fe4b023c2a7d8ccf2) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-10974) Fail to perform SAM conversion using method references
[ https://issues.apache.org/jira/browse/GROOVY-10974?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17705884#comment-17705884 ] Thodoris Sotiropoulos commented on GROOVY-10974: The use of functional interfaces (e.g., BiConsumer) is irrelevant. I think the issue is caused when passing a reference to method with generics. > Fail to perform SAM conversion using method references > -- > > Key: GROOVY-10974 > URL: https://issues.apache.org/jira/browse/GROOVY-10974 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Assignee: Eric Milles >Priority: Major > > I have the following program > {code} > import java.util.*; > import java.util.stream.*; > import java.util.function.*; > class Main { > static final void test(DoubleStream x, ObjDoubleConsumer y, > BiConsumer z) { > Spliterator.OfDouble d = null; > StreamSupport.doubleStream(d, x.collect( > () -> true, y::accept, z::accept)); > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > Main.groovy: 10: [Static type checking] - Cannot find matching method > java.util.stream.StreamSupport#doubleStream(java.util.Spliterator$OfDouble, > U). Please check if the declared type is correct and if the method exists. > @ line 10, column 9. >StreamSupport.doubleStream(d, x.collect( >^ > 1 error > {code} > h3. Expected behavior > Compile successfully > Tested against master (commit: d3c914693486bf137ec0992ef0dc28b79cba2fae) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (GROOVY-10984) Unexpected parser error when having fully qualified classes and constructor references
[ https://issues.apache.org/jira/browse/GROOVY-10984?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17705883#comment-17705883 ] Thodoris Sotiropoulos commented on GROOVY-10984: Ah I see. It seems that the Java syntax allows type arguments on the right of "::" only for constructor references. > Unexpected parser error when having fully qualified classes and constructor > references > -- > > Key: GROOVY-10984 > URL: https://issues.apache.org/jira/browse/GROOVY-10984 > Project: Groovy > Issue Type: Bug > Components: parser-antlr4 >Reporter: Thodoris Sotiropoulos >Priority: Major > > I have the following program > {code} > import java.util.function.Supplier; > import java.util.PriorityQueue; > class Main { > static final void test() { > java.util.function.Supplier> x = > java.util.PriorityQueue::new; // parsing error > Supplier> y = PriorityQueue::new; // no > error > } > } > {code} > h3. Actual behavior > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 6: Unexpected input: '>::' @ line 6, column 101. >ava.util.PriorityQueue::new; > ^ > 1 error > {code} > h3. Expected behavior > Compile successfully > Tested against master (commit: dc54541306c937a81b8bb16fe4b023c2a7d8ccf2) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10984) Unexpected parser error when having fully qualified classes and constructor references
Thodoris Sotiropoulos created GROOVY-10984: -- Summary: Unexpected parser error when having fully qualified classes and constructor references Key: GROOVY-10984 URL: https://issues.apache.org/jira/browse/GROOVY-10984 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.Supplier; import java.util.PriorityQueue; class Main { static final void test() { java.util.function.Supplier> x = java.util.PriorityQueue::new; // parsing error Supplier> y = PriorityQueue::new; // no error } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 6: Unexpected input: '>::' @ line 6, column 101. ava.util.PriorityQueue::new; ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: dc54541306c937a81b8bb16fe4b023c2a7d8ccf2) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10979) Cannot provide method reference to a type parameter instantiated with a SAM type
Thodoris Sotiropoulos created GROOVY-10979: -- Summary: Cannot provide method reference to a type parameter instantiated with a SAM type Key: GROOVY-10979 URL: https://issues.apache.org/jira/browse/GROOVY-10979 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.*; import java.util.stream.*; public class Test { public static void test() { Stream x = null; BiFunction, Number, Function> y = null; BinaryOperator> z = null; x.>reduce(Test::m, y, z); // fails x.reduce(Test::m, y, z); // fails x.reduce((d) -> 1, y, z); // works } public static Integer m(String x) { return 1; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 12: The argument is a method reference, but the parameter type is not a functional interface @ line 12, column 43. ction>reduce(Test::m, y ^ test.groovy: 13: The argument is a method reference, but the parameter type is not a functional interface @ line 13, column 16. x.reduce(Test::m, y, z); // fails ^ 2 errors {code} h3. Expected behavior Compile successfully Tested against master (commit: 55c6edfd81a64ce759357a3976070c0811bff637) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10977) STC does not catch the type error when a generic is instantiated with bounded type parameter
Thodoris Sotiropoulos created GROOVY-10977: -- Summary: STC does not catch the type error when a generic is instantiated with bounded type parameter Key: GROOVY-10977 URL: https://issues.apache.org/jira/browse/GROOVY-10977 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Probably this is a regression, because groovyc 4.0.10 catches the error. Program: {code} import java.util.*; public class Test { public static void test() { List d = null; d.add(false); } } {code} h3. Actual behavior Groovyc compiles the code h3. Expected behavior Groovyc rejects the code with a message of the form: {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 8: [Static type checking] - Cannot find matching method java.util.List#add(boolean). Please check if the declared type is correct and if the method exists. @ line 8, column 7. d.add(false); ^ 1 error {code} Tested against master -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10975) STC rejects program when passing method reference in parameterized function
Thodoris Sotiropoulos created GROOVY-10975: -- Summary: STC rejects program when passing method reference in parameterized function Key: GROOVY-10975 URL: https://issues.apache.org/jira/browse/GROOVY-10975 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos Probably a regression because groovyc 4.0.10 compiles the program. Program: {code} import java.util.*; class Main { static final void test() { Collection x = null; WeakHashMap y = null; new Hashtable(Collections.min(x, y::put)); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 8: [Static type checking] - Cannot find matching constructor java.util.Hashtable(java.lang.Object) @ line 8, column 5. new Hashtable(Collections.min(x, y::put)); ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: d3c914693486bf137ec0992ef0dc28b79cba2fae) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10974) Fail to perform SAM conversion using method references
Thodoris Sotiropoulos created GROOVY-10974: -- Summary: Fail to perform SAM conversion using method references Key: GROOVY-10974 URL: https://issues.apache.org/jira/browse/GROOVY-10974 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.*; import java.util.stream.*; import java.util.function.*; class Main { static final void test(DoubleStream x, ObjDoubleConsumer y, BiConsumer z) { Spliterator.OfDouble d = null; StreamSupport.doubleStream(d, x.collect( () -> true, y::accept, z::accept)); } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Main.groovy: 10: [Static type checking] - Cannot find matching method java.util.stream.StreamSupport#doubleStream(java.util.Spliterator$OfDouble, U). Please check if the declared type is correct and if the method exists. @ line 10, column 9. StreamSupport.doubleStream(d, x.collect( ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: d3c914693486bf137ec0992ef0dc28b79cba2fae) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-10972) Issue in resolving overloaded method reference
[ https://issues.apache.org/jira/browse/GROOVY-10972?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-10972: --- Description: I have the following program {code} import java.util.function.Function; import java.util.LinkedList; class Foo {} class Test { public static void main(String[] args) { LinkedList x = new LinkedList(); x.add(new Foo()); Function z = x::remove; Foo k = z.apply(0); // ClassCastException boolean cannot be cast to Foo. } } {code} h3. Actual behavior The compiler accepts the code, but the following exception is triggered at runtime. {code} Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'false' with class 'java.lang.Boolean' to class 'Foo' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:425) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:336) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:256) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321) at Test.main(test.groovy:14) {code} There problem happens because there are two overloaded methods inside LinkedList: * E remove(int x) * boolean remove(Object d) The compiler seems to resolve the second method (i.e., boolean remove (Object)) although its return type does not match with Function. Based only on the argument type, both methods are applicable. If the second "remove" method is more specific than the first one, then a compiler error should be raised at compile-time, because boolean does not match Foo. If this is not the case, then the program should call the first "remove" method. was: I have the following program {code} import java.util.function.Function; import java.util.LinkedList; class Foo {} class Test { public static void main(String[] args) { LinkedList x = new LinkedList(); x.add(new Foo()); Function z = x::remove; Foo k = z.apply(0); // ClassCastException boolean cannot be cast to Foo. } } {code} h3. Actual behavior The compiler accepts the code, but the following exception is triggered at runtime. {code} Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'false' with class 'java.lang.Boolean' to class 'Foo' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:425) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:336) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:256) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321) at Test.main(test.groovy:14) {code} There problem happens because there are two overloaded methods inside LinkedList: * E remove(int x) * boolean remove(Object d) The compiler seems to choose to resolve the second method although its return type does not match with Function. Based only on the argument type, both methods are applicable. If the second "remove" method is more specific than the first one, then a compiler error should be raised at compile-time. If it's not the case, then the program should call the first "remove" method. > Issue in resolving overloaded method reference > -- > > Key: GROOVY-10972 > URL: https://issues.apache.org/jira/browse/GROOVY-10972 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Reporter: Thodoris Sotiropoulos >Priority: Major > > I have the following program > {code} > import java.util.function.Function; > import java.util.LinkedList; > class Foo {} > class Test { > public static void main(String[] args) { > LinkedList x = new LinkedList(); > x.add(new Foo()); > Function z = x::remove; > Foo k = z.apply(0); // ClassCastException boolean cannot be cast to > Foo. > } > } > {code} > h3. Actual behavior > The compiler accepts the code, but the following exception is triggered at > runtime. > {code} > Exception in thread "main" > org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast > object 'false' with class 'java.lang.Boolean' to class 'Foo' > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:425) > at >
[jira] [Created] (GROOVY-10972) Issue in resolving overloaded method reference
Thodoris Sotiropoulos created GROOVY-10972: -- Summary: Issue in resolving overloaded method reference Key: GROOVY-10972 URL: https://issues.apache.org/jira/browse/GROOVY-10972 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.Function; import java.util.LinkedList; class Foo {} class Test { public static void main(String[] args) { LinkedList x = new LinkedList(); x.add(new Foo()); Function z = x::remove; Foo k = z.apply(0); // ClassCastException boolean cannot be cast to Foo. } } {code} h3. Actual behavior The compiler accepts the code, but the following exception is triggered at runtime. {code} Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'false' with class 'java.lang.Boolean' to class 'Foo' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:425) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:336) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:256) at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321) at Test.main(test.groovy:14) {code} There problem happens because there are two overloaded methods inside LinkedList: * E remove(int x) * boolean remove(Object d) The compiler seems to choose to resolve the second method although its return type does not match with Function. Based only on the argument type, both methods are applicable. If the second "remove" method is more specific than the first one, then a compiler error should be raised at compile-time. If it's not the case, then the program should call the first "remove" method. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10971) STC is looking for the wrong constructor reference
Thodoris Sotiropoulos created GROOVY-10971: -- Summary: STC is looking for the wrong constructor reference Key: GROOVY-10971 URL: https://issues.apache.org/jira/browse/GROOVY-10971 Project: Groovy Issue Type: Bug Reporter: Thodoris Sotiropoulos I have the following program {code} class Foo { Foo(String d) {} } class Main { static final void test() { def x = java.util.stream.Collectors.groupingBy(Main::m) // works; def y = java.util.stream.Collectors.groupingBy(Foo::new) // fails; } static Foo m(String x) { return null; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 8: [Static type checking] - Cannot find matching constructor Foo(java.lang.Object) @ line 8, column 56. .stream.Collectors.groupingBy(Foo::new) ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: 46722e7147ed529fe8817660617ac6af98ad6f54) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10961) STC rejects program when having SAM types and conditionals
Thodoris Sotiropoulos created GROOVY-10961: -- Summary: STC rejects program when having SAM types and conditionals Key: GROOVY-10961 URL: https://issues.apache.org/jira/browse/GROOVY-10961 Project: Groovy Issue Type: Bug Components: Static Type Checker Reporter: Thodoris Sotiropoulos I have the following program {code} import java.util.function.*; import java.util.Deque; class Main { static final void test(Deque p1, Supplier p2) { Supplier x = (true) ? p1::peek : p2; } } {code} h3. Actual behavior {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 8: [Static type checking] - Cannot assign value of type java.lang.Object to variable of type java.util.function.Supplier @ line 8, column 27. Supplier x = (true) ? p1::peek : p2; ^ 1 error {code} h3. Expected behavior Compile successfully Tested against master (commit: ee93378e5c9560032284b66d33af440884c8505f) -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Updated] (GROOVY-10959) Type checking fails when casting method references
[ https://issues.apache.org/jira/browse/GROOVY-10959?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Thodoris Sotiropoulos updated GROOVY-10959: --- Description: Probably related to GROOVY-10270. I have the following program {code} import java.util.function.*; import java.util.stream.*; class Main { static final void test() { Foo x = null; Foo y = null; BinaryOperator z = null; final Object powdery = java.util.stream.Collectors.toConcurrentMap( x::m as Function, y::m as Function, z ); } } interface Foo { T2 m(T1 x); } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 11: [Static type checking] - Cannot call java.util.stream.Collectors#toConcurrentMap(java.util.function.Function, java.util.function.Function, java.util.function.BinaryOperator) with arguments [java.util.function.Function, java.util.function.Function, java.util.function.BinaryOperator] @ line 11, column 28. final Object powdery = java.util.stream.Collectors.toConcurrentMap( ^ 1 error {code} h3. Expected behaviour Compile successfully Notes: If a remove type casts, the code compiles as expected. was: Probably related to GROOVY-10270. I have the following program {code} import java.util.function.*; import java.util.stream.*; class Main { static final void test() { Foo x = null; Foo y = null; BinaryOperator z = null; final Object powdery = java.util.stream.Collectors.toConcurrentMap( x::m as Function, y::m as Function, z ); } } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 11: [Static type checking] - Cannot call java.util.stream.Collectors#toConcurrentMap(java.util.function.Function, java.util.function.Function, java.util.function.BinaryOperator) with arguments [java.util.function.Function, java.util.function.Function, java.util.function.BinaryOperator] @ line 11, column 28. final Object powdery = java.util.stream.Collectors.toConcurrentMap( ^ 1 error {code} h3. Expected behaviour Compile successfully Notes: If a remove type casts, the code compiles as expected. > Type checking fails when casting method references > -- > > Key: GROOVY-10959 > URL: https://issues.apache.org/jira/browse/GROOVY-10959 > Project: Groovy > Issue Type: Bug >Reporter: Thodoris Sotiropoulos >Priority: Major > > Probably related to GROOVY-10270. > I have the following program > {code} > import java.util.function.*; > import java.util.stream.*; > class Main { > static final void test() { > Foo x = null; > Foo y = null; > BinaryOperator z = null; > final Object powdery = java.util.stream.Collectors.toConcurrentMap( > x::m as Function, > y::m as Function, > z > ); > } > } > interface Foo { > T2 m(T1 x); > } > {code} > h3. Actual behaviour > {code} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > test.groovy: 11: [Static type checking] - Cannot call > java.util.stream.Collectors#toConcurrentMap(java.util.function.Function super T, ? extends K>, java.util.function.Function, > java.util.function.BinaryOperator) with arguments > [java.util.function.Function, > java.util.function.Function, > java.util.function.BinaryOperator] > @ line 11, column 28. >final Object powdery = java.util.stream.Collectors.toConcurrentMap( > ^ > 1 error > {code} > h3. Expected behaviour > Compile successfully > Notes: If a remove type casts, the code compiles as expected. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Created] (GROOVY-10959) Type checking fails when casting method references
Thodoris Sotiropoulos created GROOVY-10959: -- Summary: Type checking fails when casting method references Key: GROOVY-10959 URL: https://issues.apache.org/jira/browse/GROOVY-10959 Project: Groovy Issue Type: Bug Reporter: Thodoris Sotiropoulos Probably related to GROOVY-10270. I have the following program {code} import java.util.function.*; import java.util.stream.*; class Main { static final void test() { Foo x = null; Foo y = null; BinaryOperator z = null; final Object powdery = java.util.stream.Collectors.toConcurrentMap( x::m as Function, y::m as Function, z ); } } {code} h3. Actual behaviour {code} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 11: [Static type checking] - Cannot call java.util.stream.Collectors#toConcurrentMap(java.util.function.Function, java.util.function.Function, java.util.function.BinaryOperator) with arguments [java.util.function.Function, java.util.function.Function, java.util.function.BinaryOperator] @ line 11, column 28. final Object powdery = java.util.stream.Collectors.toConcurrentMap( ^ 1 error {code} h3. Expected behaviour Compile successfully Notes: If a remove type casts, the code compiles as expected. -- This message was sent by Atlassian Jira (v8.20.10#820010)