[jira] [Commented] (GROOVY-7632) Groovy named parameters static check
[ https://issues.apache.org/jira/browse/GROOVY-7632?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15318349#comment-15318349 ] Daniil Ovchinnikov commented on GROOVY-7632: Named arguments are placed into single map parameter so this annotation could be applied to method instead of parameter. I think it would be more readable: {code} @NamedParams([@NamedParam("bar"), @NamedParam(value = "baz", type = String)]) def foo(Map map) { println map.bar println map.baz } {code} > Groovy named parameters static check > > > Key: GROOVY-7632 > URL: https://issues.apache.org/jira/browse/GROOVY-7632 > Project: Groovy > Issue Type: Improvement > Components: groovy-jdk, Static Type Checker >Reporter: Daniil Ovchinnikov > > It would be really nice if groovy will include some annotation for type > checking named params. > For example we do not know what map is expected until we go into source. > {code:title=Annotation|borderStyle=solid} > @Retention(RetentionPolicy.RUNTIME) > @Target({ElementType.PARAMETER}) > public @interface NamedParams { > NamedParam[] value(); > boolean unknowns() default false; > @interface NamedParam { > String value(); > Class type() default Object.class; > int genericTypeIndex() default -1; > String target() default ""; > boolean required() default false; > } > } > {code} > {code:title=Example Usage|borderStyle=solid} > def foo(@NamedParams([ > @NamedParam("bar"), > @NamedParam(value = "baz", type = String)]) Map map) { > println map.bar > println map.baz > } > foo(bar: [], baz: "") > {code} > In {{@CompileStatic}} case it could be used to fail the compilation if user > tries to get some unknown value from map, and also fail if user does not pass > some required argument. > Also it could be used to annotate map-constructors in compile-time. > And the last one: it will be VERY useful for IDEs. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-7849) Incompatible covariant array return type
Daniil Ovchinnikov created GROOVY-7849: -- Summary: Incompatible covariant array return type Key: GROOVY-7849 URL: https://issues.apache.org/jira/browse/GROOVY-7849 Project: Groovy Issue Type: Bug Components: Compiler Affects Versions: 2.4.6 Reporter: Daniil Ovchinnikov Probably duplicates/is related to GROOVY-7185. Consider the snippet: {code} interface Base {} interface Derived extends Base {} interface I { Base[] foo() } interface I2 extends I { Derived[] foo() } class C implements I2 { Derived[] foo() { null } } {code} Compilation fails with: {noformat} The return type of Derived[] foo() in C is incompatible with Base[] in I {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-7911) Chained multiple assignment parsing fail
Daniil Ovchinnikov created GROOVY-7911: -- Summary: Chained multiple assignment parsing fail Key: GROOVY-7911 URL: https://issues.apache.org/jira/browse/GROOVY-7911 Project: Groovy Issue Type: Bug Components: parser Reporter: Daniil Ovchinnikov {code} def a, b, c, d (a, b) = [1, 2] (c, d) = (a, b) = [1, 2] // fails, ')' expected after 'a' (c, d) = a = (a, b) = [1, 2] {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8073) Map delegate within @CompileStatic
Daniil Ovchinnikov created GROOVY-8073: -- Summary: Map delegate within @CompileStatic Key: GROOVY-8073 URL: https://issues.apache.org/jira/browse/GROOVY-8073 Project: Groovy Issue Type: Bug Components: Static compilation Affects Versions: 2.4.8 Reporter: Daniil Ovchinnikov {code} @CompileStatic class Main { static void main(String[] args) { def map = [a: 1, b: 2] map.with { // Exception in thread "main" java.lang.ClassCastException: java.util.LinkedHashMap cannot be cast to groovy.lang.GroovyObject println a } } } {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Created] (GROOVY-8074) @CompileStatic class property accessed instead of map property
Daniil Ovchinnikov created GROOVY-8074: -- Summary: @CompileStatic class property accessed instead of map property Key: GROOVY-8074 URL: https://issues.apache.org/jira/browse/GROOVY-8074 Project: Groovy Issue Type: Bug Components: Static compilation Affects Versions: 2.4.8 Reporter: Daniil Ovchinnikov {code} class MyMap extends LinkedHashMap { def foo = 1 } @CompileStatic class Main { static void main(String[] args) { def map = new MyMap() map.put('foo', 42) println map.foo // 1 is printed, should be 42 } } {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-7956) Allow @DelegatesTo on named arguments
[ https://issues.apache.org/jira/browse/GROOVY-7956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15865747#comment-15865747 ] Daniil Ovchinnikov commented on GROOVY-7956: I vote for: {code}@MapDescription(value = Point, required=['x']) void methodDescribed(Map point) { println "$p.x, $p.y" } // with ability to annotate parameters void methodDescribed2(someParameter, @MapDescription(Point) Map point) { println "$p.x, $p.y" } {code} The second allows such calls to be checked: {{methodDescribed2(42, \[x: 1, y: 2])}} If {{required}} is empty then all properties should be considered required. > Allow @DelegatesTo on named arguments > - > > Key: GROOVY-7956 > URL: https://issues.apache.org/jira/browse/GROOVY-7956 > Project: Groovy > Issue Type: New Feature > Components: GEP >Reporter: Graeme Rocher > > In order to aid static compilation for builders we have {{@DelegatesTo}} > which allows statically compiled code to know what the delegate of a closure > is. > This proposal is to allow {{@DelegatesTo}} on {{Map}} types such that IDEs > and the static compiler can resolve the target type the named arguments are > to be used on. > For example: > {code} > class Farm { > void animal(@DelegatesTo(Animal) Map arguments, > @DelegatesTo(AnimalBuilder) Closure callable) { > def animal = new Animal(arguments) > // handle closure > } > } > class Animal { String name } > {code} > The following code would then fail to compile : > {code} > def farm = new Farm() > // compilation failure, no name property on Animal > farm.animal(nam: "Dog") { > } > {code} > It would then be down to IDEs to also provide support for code completion etc. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Updated] (GROOVY-8054) Static imports inconsistency with @CompileStatic and use()
[ https://issues.apache.org/jira/browse/GROOVY-8054?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8054: --- Component/s: Compiler > Static imports inconsistency with @CompileStatic and use() > -- > > Key: GROOVY-8054 > URL: https://issues.apache.org/jira/browse/GROOVY-8054 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation >Affects Versions: 2.4.8 >Reporter: Daniil Ovchinnikov > > {code} > package hello > import groovy.transform.CompileStatic > import static hello.C.* > class C { > static foo(a) { 'imported foo' } > static bar(a) { 'imported bar' } > } > class Main { > static void main(String[] args) { > def main = new Main() > println main.foo1() // imported foo > println main.bar1() // class bar > use(Main) { > println main.bar1() // imported bar > } > } > @CompileStatic > def foo1() { > foo '2' > } > def bar1() { > bar '2' > } > static foo(String s) { 'class foo' } > static bar(String s) { 'class bar' } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Updated] (GROOVY-8054) Static imports inconsistency with @CompileStatic and use()
[ https://issues.apache.org/jira/browse/GROOVY-8054?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8054: --- Affects Version/s: 2.4.8 > Static imports inconsistency with @CompileStatic and use() > -- > > Key: GROOVY-8054 > URL: https://issues.apache.org/jira/browse/GROOVY-8054 > Project: Groovy > Issue Type: Bug > Components: Static compilation >Affects Versions: 2.4.8 >Reporter: Daniil Ovchinnikov > > {code} > package hello > import groovy.transform.CompileStatic > import static hello.C.* > class C { > static foo(a) { 'imported foo' } > static bar(a) { 'imported bar' } > } > class Main { > static void main(String[] args) { > def main = new Main() > println main.foo1() // imported foo > println main.bar1() // class bar > use(Main) { > println main.bar1() // imported bar > } > } > @CompileStatic > def foo1() { > foo '2' > } > def bar1() { > bar '2' > } > static foo(String s) { 'class foo' } > static bar(String s) { 'class bar' } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8054) Static imports inconsistency with @CompileStatic and use()
Daniil Ovchinnikov created GROOVY-8054: -- Summary: Static imports inconsistency with @CompileStatic and use() Key: GROOVY-8054 URL: https://issues.apache.org/jira/browse/GROOVY-8054 Project: Groovy Issue Type: Bug Components: Static compilation Reporter: Daniil Ovchinnikov {code} package hello import groovy.transform.CompileStatic import static hello.C.* class C { static foo(a) { 'imported foo' } static bar(a) { 'imported bar' } } class Main { static void main(String[] args) { def main = new Main() println main.foo1() // imported foo println main.bar1() // class bar use(Main) { println main.bar1() // imported bar } } @CompileStatic def foo1() { foo '2' } def bar1() { bar '2' } static foo(String s) { 'class foo' } static bar(String s) { 'class bar' } } {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Updated] (GROOVY-7929) @SelfType compilation fail
[ https://issues.apache.org/jira/browse/GROOVY-7929?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-7929: --- Description: {code} class C1 { def c1() {} } @groovy.transform.CompileStatic @groovy.transform.SelfType(C1) trait TT { def foo() { c2() } } {code} Fails with: {noformat} java.lang.UnsupportedOperationException at org.codehaus.groovy.transform.stc.UnionTypeClassNode.getInnerClasses(UnionTypeClassNode.java:269) at org.codehaus.groovy.transform.trait.Traits.findHelpers(Traits.java:114) at org.codehaus.groovy.transform.trait.Traits.findHelper(Traits.java:104) at org.codehaus.groovy.transform.stc.TraitTypeCheckingExtension.handleMissingMethod(TraitTypeCheckingExtension.java:82) at org.codehaus.groovy.transform.stc.DefaultTypeCheckingExtension.handleMissingMethod(DefaultTypeCheckingExtension.java:110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2925) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:317) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:196) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1784) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2119) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2078) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:164) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:249) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:123) at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:63) at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134) at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:525) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:61) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:217) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:150) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:180) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109) at
[jira] [Updated] (GROOVY-7929) @SelfType with multiple classes compilation fail
[ https://issues.apache.org/jira/browse/GROOVY-7929?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-7929: --- Affects Version/s: 2.4.6 2.4.7 > @SelfType with multiple classes compilation fail > > > Key: GROOVY-7929 > URL: https://issues.apache.org/jira/browse/GROOVY-7929 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static Type Checker >Affects Versions: 2.4.6, 2.4.7 >Reporter: Daniil Ovchinnikov > > {code} > class C1 { > def c1() {} > } > class C2 { > def c2() {} > } > @groovy.transform.CompileStatic > @groovy.transform.SelfType([C1, C2]) > trait TT { > def foo() { > c1() > c2() > c3() > } > } > {code} > Fails with: > {noformat} > java.lang.UnsupportedOperationException > at > org.codehaus.groovy.transform.stc.UnionTypeClassNode.getInnerClasses(UnionTypeClassNode.java:269) > at > org.codehaus.groovy.transform.trait.Traits.findHelpers(Traits.java:114) > at > org.codehaus.groovy.transform.trait.Traits.findHelper(Traits.java:104) > at > org.codehaus.groovy.transform.stc.TraitTypeCheckingExtension.handleMissingMethod(TraitTypeCheckingExtension.java:82) > at > org.codehaus.groovy.transform.stc.DefaultTypeCheckingExtension.handleMissingMethod(DefaultTypeCheckingExtension.java:110) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2925) > at > org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:317) > at > org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) > at > org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:71) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:196) > at > org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42) > at > org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166) > at > org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1784) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2119) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2078) > at > org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:164) > at > org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:249) > at > org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:123) > at > org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:63) > at > org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134) > at > org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178) > at > org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053) > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591) > at > org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:525) > at >
[jira] [Created] (GROOVY-7929) @SelfType with multiple classes compilation fail
Daniil Ovchinnikov created GROOVY-7929: -- Summary: @SelfType with multiple classes compilation fail Key: GROOVY-7929 URL: https://issues.apache.org/jira/browse/GROOVY-7929 Project: Groovy Issue Type: Bug Components: Compiler, Static Type Checker Reporter: Daniil Ovchinnikov {code} class C1 { def c1() {} } class C2 { def c2() {} } @groovy.transform.CompileStatic @groovy.transform.SelfType([C1, C2]) trait TT { def foo() { c1() c2() c3() } } {code} Fails with: {noformat} java.lang.UnsupportedOperationException at org.codehaus.groovy.transform.stc.UnionTypeClassNode.getInnerClasses(UnionTypeClassNode.java:269) at org.codehaus.groovy.transform.trait.Traits.findHelpers(Traits.java:114) at org.codehaus.groovy.transform.trait.Traits.findHelper(Traits.java:104) at org.codehaus.groovy.transform.stc.TraitTypeCheckingExtension.handleMissingMethod(TraitTypeCheckingExtension.java:82) at org.codehaus.groovy.transform.stc.DefaultTypeCheckingExtension.handleMissingMethod(DefaultTypeCheckingExtension.java:110) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:2925) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:317) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:196) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1784) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2119) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2078) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:164) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitClass(StaticTypeCheckingVisitor.java:249) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitClass(StaticCompilationVisitor.java:123) at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:63) at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134) at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:525) at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:61) at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:217) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompile(FileSystemCompiler.java:150) at org.codehaus.groovy.tools.FileSystemCompiler.commandLineCompileWithErrorHandling(FileSystemCompiler.java:180) at org.codehaus.groovy.tools.FileSystemCompiler.main(FileSystemCompiler.java:164) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at
[jira] [Updated] (GROOVY-7949) Disallow static inner classes within anonymous classes
[ https://issues.apache.org/jira/browse/GROOVY-7949?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-7949: --- Description: This just does not make sense, but works: {code} def a = new Hello() { static class Hello { def foo() { "hello" } } } println a.foo() {code} was: This just do not make sense, but works: {code} def a = new Hello() { static class Hello { def foo() { "hello" } } } println a.foo() {code} > Disallow static inner classes within anonymous classes > -- > > Key: GROOVY-7949 > URL: https://issues.apache.org/jira/browse/GROOVY-7949 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov > > This just does not make sense, but works: > {code} > def a = new Hello() { > static class Hello { > def foo() { "hello" } > } > } > println a.foo() > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-7949) Disallow static inner classes within anonymous classes
Daniil Ovchinnikov created GROOVY-7949: -- Summary: Disallow static inner classes within anonymous classes Key: GROOVY-7949 URL: https://issues.apache.org/jira/browse/GROOVY-7949 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov This just do not make sense, but works: {code} def a = new Hello() { static class Hello { def foo() { "hello" } } } println a.foo() {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (GROOVY-7949) Disallow static inner classes within anonymous classes
[ https://issues.apache.org/jira/browse/GROOVY-7949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15527118#comment-15527118 ] Daniil Ovchinnikov commented on GROOVY-7949: Java does not allow static members in inner classes https://docs.oracle.com/javase/specs/jls/se8/html/jls-8.html#jls-8.1.3 > Disallow static inner classes within anonymous classes > -- > > Key: GROOVY-7949 > URL: https://issues.apache.org/jira/browse/GROOVY-7949 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov > > This just does not make sense, but works: > {code} > def a = new Hello() { > static class Hello { > def foo() { "hello" } > } > } > println a.foo() > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-7993) @Singleton fails on empty property name
Daniil Ovchinnikov created GROOVY-7993: -- Summary: @Singleton fails on empty property name Key: GROOVY-7993 URL: https://issues.apache.org/jira/browse/GROOVY-7993 Project: Groovy Issue Type: Bug Affects Versions: 2.4.7 Reporter: Daniil Ovchinnikov {code} @Singleton(property = "") class A {} {code} fails with: {noformat} java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:658) at org.codehaus.groovy.transform.SingletonASTTransformation.getGetterName(SingletonASTTransformation.java:105) at org.codehaus.groovy.transform.SingletonASTTransformation.createField(SingletonASTTransformation.java:81) at org.codehaus.groovy.transform.SingletonASTTransformation.visit(SingletonASTTransformation.java:70) at ... {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8021) Super in traits cause MissingMethodException
Daniil Ovchinnikov created GROOVY-8021: -- Summary: Super in traits cause MissingMethodException Key: GROOVY-8021 URL: https://issues.apache.org/jira/browse/GROOVY-8021 Project: Groovy Issue Type: Bug Components: Static compilation Affects Versions: 2.4.7 Reporter: Daniil Ovchinnikov {code} @CompileStatic trait SimpleTrait { void foo() { super.foo() } } @CompileStatic class Foo implements SimpleTrait {} new Foo().foo() // MissingMethodException {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (GROOVY-8021) Super in traits causes MissingMethodException
[ https://issues.apache.org/jira/browse/GROOVY-8021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15748853#comment-15748853 ] Daniil Ovchinnikov commented on GROOVY-8021: Possible solutions: - prohibit {{super}} within {{@CompileStatic}} traits since there is no way now to determine the superclass in compile time. - fail at least on static compilation of class which implements a trait referencing {{super}}, i.e. {{Foo}} One more question arises, why I get {{MissingMethodException}} from statically compiled code? > Super in traits causes MissingMethodException > - > > Key: GROOVY-8021 > URL: https://issues.apache.org/jira/browse/GROOVY-8021 > Project: Groovy > Issue Type: Bug > Components: Static compilation >Affects Versions: 2.4.7 >Reporter: Daniil Ovchinnikov > > {code} > @CompileStatic > trait SimpleTrait { > void foo() { > super.foo() > } > } > @CompileStatic > class Foo implements SimpleTrait {} > new Foo().foo() // MissingMethodException > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8022) Plus assignment for unusual property
Daniil Ovchinnikov created GROOVY-8022: -- Summary: Plus assignment for unusual property Key: GROOVY-8022 URL: https://issues.apache.org/jira/browse/GROOVY-8022 Project: Groovy Issue Type: Bug Components: Static Type Checker Affects Versions: 2.4.7 Reporter: Daniil Ovchinnikov {code} class A { C plus(B b) { println "plus" new C() } } class B {} class C {} class Foo { A getProp() { println "get" new A() } void setProp(C c) { println "set" } } @CompileStatic class Main { static void main(String[] args) { def foo = new Foo() foo.prop += new B() } } {code} Correctly prints without @CompileStatic: {noformat} get plus set {noformat} With @CompileStatic fails with: {noformat} Error:(32, 9) Groovyc: [Static type checking] - Cannot assign value of type B to variable of type C {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8024) Subscript operator with spread argument
Daniil Ovchinnikov created GROOVY-8024: -- Summary: Subscript operator with spread argument Key: GROOVY-8024 URL: https://issues.apache.org/jira/browse/GROOVY-8024 Project: Groovy Issue Type: Bug Affects Versions: 2.4.7 Reporter: Daniil Ovchinnikov {code} def mm = [:] mm[*[1, 2, 3]] += "sss" println mm {code} {noformat} Error:Groovyc: While compiling untitled1: BUG! exception in phase 'class generation' in source unit '/Users/danyjb/IdeaProjects/untitled1/src/priorities/test.groovy' SpreadExpression should not be visited here at org.codehaus.groovy.classgen.AsmClassGenerator.visitSpreadExpression(AsmClassGenerator.java:687) at org.codehaus.groovy.ast.expr.SpreadExpression.visit(SpreadExpression.java:41) at org.codehaus.groovy.classgen.asm.ExpressionAsVariableSlot.visit(ExpressionAsVariableSlot.java:55) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBytecodeExpression(AsmClassGenerator.java:1984) at org.codehaus.groovy.classgen.BytecodeExpression.visit(BytecodeExpression.java:47) at org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:303) at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCachedCall(InvocationWriter.java:307) at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:392) at org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:104) at org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:88) at org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:459) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:767) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateArrayAssignmentWithOperator(BinaryExpressionHelper.java:553) at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateBinaryExpressionWithAssignment(BinaryExpressionHelper.java:570) at org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:152) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:638) at org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51) at org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:612) at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:357) at org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:620) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42) at org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:84) at org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:158) at org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:566) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115) at org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:430) at org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:387) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126) at org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:507) at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53) at org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:233) at org.codehaus.groovy.control.CompilationUnit$16.call(CompilationUnit.java:813) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1053) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:591) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:569) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:546) {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8049) Trait properties with 'with'
Daniil Ovchinnikov created GROOVY-8049: -- Summary: Trait properties with 'with' Key: GROOVY-8049 URL: https://issues.apache.org/jira/browse/GROOVY-8049 Project: Groovy Issue Type: Bug Affects Versions: 2.4.7 Reporter: Daniil Ovchinnikov {code} @CompileStatic interface I { String getFoo() } @CompileStatic trait T { abstract I getProp() def usage() { prop.with { foo.toUpperCase() // Groovyc: [Static type checking] - Cannot find matching method java.lang.Object#toUpperCase(). Please check if the declared type is right and if the method exists. // works when changed to getFoo().toUpperCase() } } } @CompileStatic class Main implements T { I prop = { "hello" } as I static void main(String[] args) { println new Main().usage() } } {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8046) ClassFormatError void field
Daniil Ovchinnikov created GROOVY-8046: -- Summary: ClassFormatError void field Key: GROOVY-8046 URL: https://issues.apache.org/jira/browse/GROOVY-8046 Project: Groovy Issue Type: Bug Components: Compiler Affects Versions: 2.4.7 Environment: jdk1.8.0_102 Reporter: Daniil Ovchinnikov {code} class MyClass { void field static void main(String[] args) {} } {code} When run: {noformat} Exception in thread "main" java.lang.ClassFormatError: Field "field" in class MyClass has illegal signature "V" at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:264) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:119) {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8050) Reference outer class property via inner class
Daniil Ovchinnikov created GROOVY-8050: -- Summary: Reference outer class property via inner class Key: GROOVY-8050 URL: https://issues.apache.org/jira/browse/GROOVY-8050 Project: Groovy Issue Type: Bug Components: Compiler, Static compilation, Static Type Checker Affects Versions: 2.4.7 Reporter: Daniil Ovchinnikov {code} @CompileStatic class Outer { def foo = 1 Inner createInner() { new Inner() } class Inner {} } @CompileStatic class Main { static void main(String[] args) { def i = new Outer().createInner() println i.foo // [Static type checking] - No such property: foo for class: Outer$Inner // works without @CompileStatic } } {code} I think should work in both static and dynamic contexts or fail in both. Please close this issue if this is by design. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Updated] (GROOVY-8050) Reference outer class property via inner class
[ https://issues.apache.org/jira/browse/GROOVY-8050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8050: --- Description: {code} @CompileStatic class Outer { def foo = 1 Inner createInner() { new Inner() } class Inner {} } @CompileStatic // works without @CompileStatic class Main { static void main(String[] args) { def i = new Outer().createInner() println i.foo // [Static type checking] - No such property: foo for class: Outer$Inner } } {code} I think should work in both static and dynamic contexts or fail in both. Please close this issue if this is by design. was: {code} @CompileStatic class Outer { def foo = 1 Inner createInner() { new Inner() } class Inner {} } @CompileStatic class Main { static void main(String[] args) { def i = new Outer().createInner() println i.foo // [Static type checking] - No such property: foo for class: Outer$Inner // works without @CompileStatic } } {code} I think should work in both static and dynamic contexts or fail in both. Please close this issue if this is by design. > Reference outer class property via inner class > -- > > Key: GROOVY-8050 > URL: https://issues.apache.org/jira/browse/GROOVY-8050 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation, Static Type Checker >Affects Versions: 2.4.7 >Reporter: Daniil Ovchinnikov > > {code} > @CompileStatic > class Outer { > def foo = 1 > Inner createInner() { new Inner() } > class Inner {} > } > @CompileStatic // works without @CompileStatic > class Main { > static void main(String[] args) { > def i = new Outer().createInner() > println i.foo // [Static type checking] - No such property: foo for > class: Outer$Inner > } > } > {code} > I think should work in both static and dynamic contexts or fail in both. > Please close this issue if this is by design. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8051) Reference outer class property within inner class closure
Daniil Ovchinnikov created GROOVY-8051: -- Summary: Reference outer class property within inner class closure Key: GROOVY-8051 URL: https://issues.apache.org/jira/browse/GROOVY-8051 Project: Groovy Issue Type: Bug Components: Compiler, Static compilation, Static Type Checker Affects Versions: 2.4.7 Reporter: Daniil Ovchinnikov {code} @CompileStatic // works without this @CompileStatic class Outer { def foo = 1 Inner createInner() { new Inner() } class Inner { Closure createClosure() { return { foo } } } } @CompileStatic class Main { static void main(String[] args) { def i = new Outer().createInner() def cl = i.createClosure() println cl() } } {code} Fail in runtime with: {noformat} Exception in thread "main" org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'Outer$Inner@23e028a9' with class 'Outer$Inner' to class 'Outer' at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:405) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:319) at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:232) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:603) at Outer$Inner$_createClosure_closure1.doCall(innerclassestest.groovy) at Outer$Inner$_createClosure_closure1.call(innerclassestest.groovy) at Main.main(innerclassestest.groovy:23) {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (GROOVY-8051) Reference outer class property within inner class closure
[ https://issues.apache.org/jira/browse/GROOVY-8051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15821927#comment-15821927 ] Daniil Ovchinnikov commented on GROOVY-8051: Needs to be consistent > Reference outer class property within inner class closure > - > > Key: GROOVY-8051 > URL: https://issues.apache.org/jira/browse/GROOVY-8051 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation, Static Type Checker >Affects Versions: 2.4.7 >Reporter: Daniil Ovchinnikov > > {code} > @CompileStatic // works without this @CompileStatic > class Outer { > def foo = 1 > Inner createInner() { new Inner() } > class Inner { > Closure createClosure() { > return { foo } > } > } > } > @CompileStatic > class Main { > static void main(String[] args) { > def i = new Outer().createInner() > def cl = i.createClosure() > println cl() > } > } > {code} > Fail in runtime with: > {noformat} > Exception in thread "main" > org.codehaus.groovy.runtime.typehandling.GroovyCastException: > Cannot cast object 'Outer$Inner@23e028a9' with class 'Outer$Inner' to class > 'Outer' > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:405) > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:319) > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:232) > at > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:603) > at Outer$Inner$_createClosure_closure1.doCall(innerclassestest.groovy) > at Outer$Inner$_createClosure_closure1.call(innerclassestest.groovy) > at Main.main(innerclassestest.groovy:23) > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Updated] (GROOVY-8050) Reference outer class property via inner class
[ https://issues.apache.org/jira/browse/GROOVY-8050?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8050: --- Description: {code} @CompileStatic class Outer { def foo = 1 Inner createInner() { new Inner() } class Inner {} } @CompileStatic class Main { static void main(String[] args) { def i = new Outer().createInner() println i.foo // [Static type checking] - No such property: foo for class: Outer$Inner // works without @CompileStatic } } {code} I think should work in both static and dynamic contexts or fail in both. Please close this issue if this is by design. was: {code} @CompileStatic class Outer { def foo = 1 Inner createInner() { new Inner() } class Inner {} } @CompileStatic class Main { static void main(String[] args) { def i = new Outer().createInner() println i.foo // [Static type checking] - No such property: foo for class: Outer$Inner // works without @CompileStatic } } {code} I think should work in both static and dynamic contexts or fail in both. Please close this issue if this is by design. > Reference outer class property via inner class > -- > > Key: GROOVY-8050 > URL: https://issues.apache.org/jira/browse/GROOVY-8050 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation, Static Type Checker >Affects Versions: 2.4.7 >Reporter: Daniil Ovchinnikov > > {code} > @CompileStatic > class Outer { > def foo = 1 > Inner createInner() { new Inner() } > class Inner {} > } > @CompileStatic > class Main { > static void main(String[] args) { > def i = new Outer().createInner() > println i.foo // [Static type checking] - No such property: foo for > class: Outer$Inner > // works without @CompileStatic > } > } > {code} > I think should work in both static and dynamic contexts or fail in both. > Please close this issue if this is by design. -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Issue Comment Deleted] (GROOVY-8051) Reference outer class property within inner class closure
[ https://issues.apache.org/jira/browse/GROOVY-8051?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8051: --- Comment: was deleted (was: Needs to be consistent) > Reference outer class property within inner class closure > - > > Key: GROOVY-8051 > URL: https://issues.apache.org/jira/browse/GROOVY-8051 > Project: Groovy > Issue Type: Bug > Components: Compiler, Static compilation, Static Type Checker >Affects Versions: 2.4.7 >Reporter: Daniil Ovchinnikov > > {code} > @CompileStatic // works without this @CompileStatic > class Outer { > def foo = 1 > Inner createInner() { new Inner() } > class Inner { > Closure createClosure() { > return { foo } > } > } > } > @CompileStatic > class Main { > static void main(String[] args) { > def i = new Outer().createInner() > def cl = i.createClosure() > println cl() > } > } > {code} > Fail in runtime with: > {noformat} > Exception in thread "main" > org.codehaus.groovy.runtime.typehandling.GroovyCastException: > Cannot cast object 'Outer$Inner@23e028a9' with class 'Outer$Inner' to class > 'Outer' > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnSAM(DefaultTypeTransformation.java:405) > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.continueCastOnNumber(DefaultTypeTransformation.java:319) > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:232) > at > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.castToType(ScriptBytecodeAdapter.java:603) > at Outer$Inner$_createClosure_closure1.doCall(innerclassestest.groovy) > at Outer$Inner$_createClosure_closure1.call(innerclassestest.groovy) > at Main.main(innerclassestest.groovy:23) > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (GROOVY-8153) Weird .class references with subscript operator
Daniil Ovchinnikov created GROOVY-8153: -- Summary: Weird .class references with subscript operator Key: GROOVY-8153 URL: https://issues.apache.org/jira/browse/GROOVY-8153 Project: Groovy Issue Type: Bug Affects Versions: 2.4.10, 2.5.0-alpha-1 Reporter: Daniil Ovchinnikov Current behaviour: {code} assert String[] == String.class[] assert String[][] == String[].class[] {code} Expected result: {code} def caught caught = false try { String.class[] // def clazz = String.class; a[] } catch (MissingMethodException e) { caught = true } assert caught caught = false try { String[].class[] // def clazz = String[].class; a[] } catch (MissingMethodException e) { caught = true } assert caught {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Created] (GROOVY-8152) Weird .class references
Daniil Ovchinnikov created GROOVY-8152: -- Summary: Weird .class references Key: GROOVY-8152 URL: https://issues.apache.org/jira/browse/GROOVY-8152 Project: Groovy Issue Type: Bug Affects Versions: 2.4.10, 2.5.0-alpha-1 Reporter: Daniil Ovchinnikov {code} println(String) // class java.lang.String println(String.class) // class java.lang.String println(String.class.class) // class java.lang.String println(String.class.class.class) // class java.lang.Class {code} While I understand that the first and the second lines are equivalent, I don't get behaviour of the third, which causes the following: {code} println(String[].class[].class.class[]) // class [[[Ljava.lang.String; {code} Expected result: {code} assert String.class.class == String.class.getClass() assert String[].class.class == String[].class.getClass() {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-8024) Subscript operator with spread argument
[ https://issues.apache.org/jira/browse/GROOVY-8024?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15966272#comment-15966272 ] Daniil Ovchinnikov commented on GROOVY-8024: [~paulk] I'm getting the following behaviour in 2.5.0-alpha-1: {code} def a = ['foo'] def m = [foo: 42] println m.get(*a) // 42 println m.getAt(*a) // 42 println m[*a] // null {code} Is it intended? > Subscript operator with spread argument > --- > > Key: GROOVY-8024 > URL: https://issues.apache.org/jira/browse/GROOVY-8024 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.4.7 >Reporter: Daniil Ovchinnikov >Assignee: Paul King > > {code} > def mm = [:] > mm[*[1, 2, 3]] += "sss" > println mm > {code} > {noformat} > Error:Groovyc: While compiling untitled1: BUG! exception in phase 'class > generation' in source unit > '/Users/danyjb/IdeaProjects/untitled1/src/priorities/test.groovy' > SpreadExpression should not be visited here > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitSpreadExpression(AsmClassGenerator.java:687) > at > org.codehaus.groovy.ast.expr.SpreadExpression.visit(SpreadExpression.java:41) > at > org.codehaus.groovy.classgen.asm.ExpressionAsVariableSlot.visit(ExpressionAsVariableSlot.java:55) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitBytecodeExpression(AsmClassGenerator.java:1984) > at > org.codehaus.groovy.classgen.BytecodeExpression.visit(BytecodeExpression.java:47) > at > org.codehaus.groovy.classgen.asm.CallSiteWriter.makeCallSite(CallSiteWriter.java:303) > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCachedCall(InvocationWriter.java:307) > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:392) > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeCall(InvocationWriter.java:104) > at > org.codehaus.groovy.classgen.asm.InvocationWriter.makeInvokeMethodCall(InvocationWriter.java:88) > at > org.codehaus.groovy.classgen.asm.InvocationWriter.writeInvokeMethod(InvocationWriter.java:459) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitMethodCallExpression(AsmClassGenerator.java:767) > at > org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) > at > org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateArrayAssignmentWithOperator(BinaryExpressionHelper.java:553) > at > org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.evaluateBinaryExpressionWithAssignment(BinaryExpressionHelper.java:570) > at > org.codehaus.groovy.classgen.asm.BinaryExpressionHelper.eval(BinaryExpressionHelper.java:152) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitBinaryExpression(AsmClassGenerator.java:638) > at > org.codehaus.groovy.ast.expr.BinaryExpression.visit(BinaryExpression.java:51) > at > org.codehaus.groovy.classgen.asm.StatementWriter.writeExpressionStatement(StatementWriter.java:612) > at > org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeExpressionStatement(OptimizingStatementWriter.java:357) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitExpressionStatement(AsmClassGenerator.java:620) > at > org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42) > at > org.codehaus.groovy.classgen.asm.StatementWriter.writeBlockStatement(StatementWriter.java:84) > at > org.codehaus.groovy.classgen.asm.OptimizingStatementWriter.writeBlockStatement(OptimizingStatementWriter.java:158) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitBlockStatement(AsmClassGenerator.java:566) > at > org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitStdMethod(AsmClassGenerator.java:430) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitConstructorOrMethod(AsmClassGenerator.java:387) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitMethod(AsmClassGenerator.java:507) > at org.codehaus.groovy.ast.ClassNode.visitContents(ClassNode.java:1078) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:53) > at > org.codehaus.groovy.classgen.AsmClassGenerator.visitClass(AsmClassGenerator.java:233) > at >
[jira] [Created] (GROOVY-8154) Parenthesized class literal with subscript operator
Daniil Ovchinnikov created GROOVY-8154: -- Summary: Parenthesized class literal with subscript operator Key: GROOVY-8154 URL: https://issues.apache.org/jira/browse/GROOVY-8154 Project: Groovy Issue Type: Bug Affects Versions: 2.4.10, 2.5.0-alpha-1 Reporter: Daniil Ovchinnikov Current behaviour: {code} assert (String.class)[] == String[].class {code} Expected {{(String.class)[]}} should fail with {{MissingMethodException: No signature of method: static java.lang.String.getAt() is applicable for argument types: (ArrayList) values: [[]]}} just like: {code} def a = String.class a[] // MissingMethodException {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-8150) Inconsistency in multiple assignment with single variable
[ https://issues.apache.org/jira/browse/GROOVY-8150?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15962831#comment-15962831 ] Daniil Ovchinnikov commented on GROOVY-8150: [~blackdrag] then {{((a.myField)) = b}} should not be parsed too. > Inconsistency in multiple assignment with single variable > - > > Key: GROOVY-8150 > URL: https://issues.apache.org/jira/browse/GROOVY-8150 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.5.0-alpha-1, 2.4.10 >Reporter: Daniil Ovchinnikov > > {code} > def a > def b = [1] > a = b > println "${a} : ${a.class}" // [1] : class java.util.ArrayList > (a) = b > println "${a} : ${a.class}" // 1 : class java.lang.Integer > ((a)) = b > println "${a} : ${a.class}" // [1] : class java.util.ArrayList > {code} > This is confusing. Here are options: > 1. {{((a)) = b}} should be failed to parse. > 2. {{((a)) = b}} should behave like {{(a) = b}}, i.e. number of parentheses > should not matter. > 3. {{((a)) = b}} and {{(a) = b}} should behave like {{a = b}}. This will > match the following case also: > {code} > class A { def myField } > def a = new A() > def b = [1] > a.myField = b > assert a.myField == [1] > (a.myField) = b > assert a.myField == [1] > ((a.myField)) = b > assert a.myField == [1] > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-7956) Allow @DelegatesTo on named arguments
[ https://issues.apache.org/jira/browse/GROOVY-7956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15962897#comment-15962897 ] Daniil Ovchinnikov commented on GROOVY-7956: Another option: {code} def foo(a, @Named b, c, @Named d) { println "$a $b $c $d" // note referring to named parameters as a regular ones } {code} This may be compiled to a regular method with a Map as a first parameter: {code} def foo(Map _it, a, c) { println "$a $_it.b $c $_it.d" } {code} The parameters then may have types and/or default values: {code} def foo(int a, @Named String b = "hello there", c, @Named d) { println "$a $b $c $d" } //compiled def foo(Map _it, int a, c) { _it.putAll(b: "hello there) // default parameters injected here println "$a ${(String)_it.b} $c $_it.d" // cast to string } {code} There is still need to store some metadata in the compiled code, for which this annotation will work GROOVY-7632. This may be implemented as an AST transformation or as a special language feature. Since each transformation slows the IDE, I'd go with new modifier, e.g. {{named}}. {code} def foo(int a, named String b = "hello there", c, named d) { println "$a $b $c $d" } {code} This for sure will break someone's sources, but it's a step for cleaner language. > Allow @DelegatesTo on named arguments > - > > Key: GROOVY-7956 > URL: https://issues.apache.org/jira/browse/GROOVY-7956 > Project: Groovy > Issue Type: New Feature > Components: GEP >Reporter: Graeme Rocher > > In order to aid static compilation for builders we have {{@DelegatesTo}} > which allows statically compiled code to know what the delegate of a closure > is. > This proposal is to allow {{@DelegatesTo}} on {{Map}} types such that IDEs > and the static compiler can resolve the target type the named arguments are > to be used on. > For example: > {code} > class Farm { > void animal(@DelegatesTo(Animal) Map arguments, > @DelegatesTo(AnimalBuilder) Closure callable) { > def animal = new Animal(arguments) > // handle closure > } > } > class Animal { String name } > {code} > The following code would then fail to compile : > {code} > def farm = new Farm() > // compilation failure, no name property on Animal > farm.animal(nam: "Dog") { > } > {code} > It would then be down to IDEs to also provide support for code completion etc. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Comment Edited] (GROOVY-7956) Allow @DelegatesTo on named arguments
[ https://issues.apache.org/jira/browse/GROOVY-7956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15962897#comment-15962897 ] Daniil Ovchinnikov edited comment on GROOVY-7956 at 4/10/17 2:00 PM: - Another option: {code} def foo(a, @Named b, c, @Named d) { println "$a $b $c $d" // note referring to named parameters as a regular ones } {code} This may be compiled to a regular method with a Map as a first parameter: {code} def foo(Map _it, a, c) { println "$a $_it.b $c $_it.d" } {code} The parameters then may have types and/or default values: {code} def foo(int a, @Named String b = "hello there", c, @Named d) { println "$a $b $c $d" } //compiled def foo(Map _it, int a, c) { _it.putAll(b: "hello there) // default parameters injected here println "$a ${(String)_it.b} $c $_it.d" // cast to string } {code} There is still need to store some metadata in the compiled code, for which this annotation will work GROOVY-7632. This may be implemented as an AST transformation or as a special language feature. Since each transformation slows the IDE, I'd go with new modifier, e.g. {{named}}. {code} def foo(int a, named String b = "hello there", c, named d) { println "$a $b $c $d" } {code} This for sure will break someone's sources, but it's a step to cleaner language. was (Author: daniilo): Another option: {code} def foo(a, @Named b, c, @Named d) { println "$a $b $c $d" // note referring to named parameters as a regular ones } {code} This may be compiled to a regular method with a Map as a first parameter: {code} def foo(Map _it, a, c) { println "$a $_it.b $c $_it.d" } {code} The parameters then may have types and/or default values: {code} def foo(int a, @Named String b = "hello there", c, @Named d) { println "$a $b $c $d" } //compiled def foo(Map _it, int a, c) { _it.putAll(b: "hello there) // default parameters injected here println "$a ${(String)_it.b} $c $_it.d" // cast to string } {code} There is still need to store some metadata in the compiled code, for which this annotation will work GROOVY-7632. This may be implemented as an AST transformation or as a special language feature. Since each transformation slows the IDE, I'd go with new modifier, e.g. {{named}}. {code} def foo(int a, named String b = "hello there", c, named d) { println "$a $b $c $d" } {code} This for sure will break someone's sources, but it's a step for cleaner language. > Allow @DelegatesTo on named arguments > - > > Key: GROOVY-7956 > URL: https://issues.apache.org/jira/browse/GROOVY-7956 > Project: Groovy > Issue Type: New Feature > Components: GEP >Reporter: Graeme Rocher > > In order to aid static compilation for builders we have {{@DelegatesTo}} > which allows statically compiled code to know what the delegate of a closure > is. > This proposal is to allow {{@DelegatesTo}} on {{Map}} types such that IDEs > and the static compiler can resolve the target type the named arguments are > to be used on. > For example: > {code} > class Farm { > void animal(@DelegatesTo(Animal) Map arguments, > @DelegatesTo(AnimalBuilder) Closure callable) { > def animal = new Animal(arguments) > // handle closure > } > } > class Animal { String name } > {code} > The following code would then fail to compile : > {code} > def farm = new Farm() > // compilation failure, no name property on Animal > farm.animal(nam: "Dog") { > } > {code} > It would then be down to IDEs to also provide support for code completion etc. -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-8159) Make assert output easy to parse
[ https://issues.apache.org/jira/browse/GROOVY-8159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15971125#comment-15971125 ] Daniil Ovchinnikov commented on GROOVY-8159: This: bq. to recognize in the compiler we do an assert with == and then call an assert function, which would produce a slightly different exception It doesn't have to be rendered in some another way. Just store two additional fields with some data for binary expressions with == operator. > Make assert output easy to parse > > > Key: GROOVY-8159 > URL: https://issues.apache.org/jira/browse/GROOVY-8159 > Project: Groovy > Issue Type: Improvement > Components: groovy-runtime >Affects Versions: 2.4.10 >Reporter: Iurii > Attachments: 1 contains assert.jpg, 2 contains equals.jpg > > > Based on https://youtrack.jetbrains.com/issue/IDEA-171275 > IntelliJ IDEA provides great feature: "Click to see difference" in test > console. > It's very useful because it opens comparison windows where differences are > highlighted. > It's supported for JUnit assertXXX but not for Groovy assert because: > "JUnit's ComparisonFailure contains all necessary data which can be rendered > later while Groovy's PowerAssertionError contains already rendered message > which is hard to parse (if it's even possible)" > Can assert output be improved so that IDE can parse it? -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-8159) Make assert output easy to parse
[ https://issues.apache.org/jira/browse/GROOVY-8159?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15971407#comment-15971407 ] Daniil Ovchinnikov commented on GROOVY-8159: Yes. > Make assert output easy to parse > > > Key: GROOVY-8159 > URL: https://issues.apache.org/jira/browse/GROOVY-8159 > Project: Groovy > Issue Type: Improvement > Components: groovy-runtime >Affects Versions: 2.4.10 >Reporter: Iurii > Attachments: 1 contains assert.jpg, 2 contains equals.jpg > > > Based on https://youtrack.jetbrains.com/issue/IDEA-171275 > IntelliJ IDEA provides great feature: "Click to see difference" in test > console. > It's very useful because it opens comparison windows where differences are > highlighted. > It's supported for JUnit assertXXX but not for Groovy assert because: > "JUnit's ComparisonFailure contains all necessary data which can be rendered > later while Groovy's PowerAssertionError contains already rendered message > which is hard to parse (if it's even possible)" > Can assert output be improved so that IDE can parse it? -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Created] (GROOVY-8157) Flow typing doesn't work with assignment to a parameter
Daniil Ovchinnikov created GROOVY-8157: -- Summary: Flow typing doesn't work with assignment to a parameter Key: GROOVY-8157 URL: https://issues.apache.org/jira/browse/GROOVY-8157 Project: Groovy Issue Type: Bug Components: Static Type Checker Affects Versions: 2.4.10 Reporter: Daniil Ovchinnikov {code} import groovy.transform.CompileStatic class A {} class B extends A { def bbb() {} } interface I { A getA() } @CompileStatic def fooLocalInstanceof(I i) { A a = i.getA() if (a instanceof B) { a.bbb() } } @CompileStatic def fooParameterInstanceof(A a) { if (a instanceof B) { a.bbb() } } @CompileStatic def fooLocalAssignment() { A a = new B() a.bbb() } @CompileStatic def fooParameterAssignment(A a) { a = new B() a.bbb() // Cannot find matching method A#bbb() } {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-6212) SpreadExpression BUG! when slicing a List
[ https://issues.apache.org/jira/browse/GROOVY-6212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15967519#comment-15967519 ] Daniil Ovchinnikov commented on GROOVY-6212: [~paulk] I'm getting the following behaviour in 2.5.0-alpha-1: {code} def a = ['foo'] def m = [foo: 42] println m.get(*a) // 42 println m.getAt(*a) // 42 println m[*a] // null {code} Is it intended? > SpreadExpression BUG! when slicing a List > - > > Key: GROOVY-6212 > URL: https://issues.apache.org/jira/browse/GROOVY-6212 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.1.5, 2.4.0-rc-1 >Reporter: Alexey Rusakovich >Assignee: Paul King > Fix For: 2.5.0-alpha-1 > > > Evaluating > {code} > (1..3)[*0..2] > {code} > throws: {{BUG! exception in phase 'class generation' in source unit > 'ConsoleScript42' SpreadExpression should not be visited here}} > It works fine if I manually call {{getAt}}: > {code} > (1..3).getAt([*0..2]) // [1, 2, 3] > {code} > It also works if I add something besides the spread: > {code} > (1..3)[*0..2, 2] // [1, 2, 3, 3] > {code} > as shown in the Ranges and List-Slicing section of [Getting Started Guide > > Collections|http://groovy.codehaus.org/JN1015-Collections]. > There are other SpreadExpression BUG!s, but I'm not sure if this bug is the > same: > http://jira.codehaus.org/issues/?jql=text%20%7E%20%22SpreadExpression%22 -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Created] (GROOVY-8150) Inconsistency in multiple assignment with single variable
Daniil Ovchinnikov created GROOVY-8150: -- Summary: Inconsistency in multiple assignment with single variable Key: GROOVY-8150 URL: https://issues.apache.org/jira/browse/GROOVY-8150 Project: Groovy Issue Type: Bug Affects Versions: 2.4.10, 2.5.0-alpha-1 Reporter: Daniil Ovchinnikov {code} def a def b = [1] a = b println "${a} : ${a.class}" // [1] : class java.util.ArrayList (a) = b println "${a} : ${a.class}" // 1 : class java.lang.Integer ((a)) = b println "${a} : ${a.class}" // [1] : class java.util.ArrayList {code} This is confusing. Here are options: 1. {{((a)) = b}} should be failed to parse; 2. {{((a)) = b}} should behave like {{(a) = b}}, i.e. number of parentheses should not matter. 3. {{((a)) = b}} and {{(a) = b}} should behave like {{a = b}}. This will match the following case also: {code} class A { def myField } def a = new A() def b = [1] a.myField = b assert a.myField == [1] (a.myField) = b assert a.myField == [1] ((a.myField)) = b assert a.myField == [1] {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Updated] (GROOVY-8150) Inconsistency in multiple assignment with single variable
[ https://issues.apache.org/jira/browse/GROOVY-8150?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8150: --- Description: {code} def a def b = [1] a = b println "${a} : ${a.class}" // [1] : class java.util.ArrayList (a) = b println "${a} : ${a.class}" // 1 : class java.lang.Integer ((a)) = b println "${a} : ${a.class}" // [1] : class java.util.ArrayList {code} This is confusing. Here are options: 1. {{((a)) = b}} should be failed to parse. 2. {{((a)) = b}} should behave like {{(a) = b}}, i.e. number of parentheses should not matter. 3. {{((a)) = b}} and {{(a) = b}} should behave like {{a = b}}. This will match the following case also: {code} class A { def myField } def a = new A() def b = [1] a.myField = b assert a.myField == [1] (a.myField) = b assert a.myField == [1] ((a.myField)) = b assert a.myField == [1] {code} was: {code} def a def b = [1] a = b println "${a} : ${a.class}" // [1] : class java.util.ArrayList (a) = b println "${a} : ${a.class}" // 1 : class java.lang.Integer ((a)) = b println "${a} : ${a.class}" // [1] : class java.util.ArrayList {code} This is confusing. Here are options: 1. {{((a)) = b}} should be failed to parse; 2. {{((a)) = b}} should behave like {{(a) = b}}, i.e. number of parentheses should not matter. 3. {{((a)) = b}} and {{(a) = b}} should behave like {{a = b}}. This will match the following case also: {code} class A { def myField } def a = new A() def b = [1] a.myField = b assert a.myField == [1] (a.myField) = b assert a.myField == [1] ((a.myField)) = b assert a.myField == [1] {code} > Inconsistency in multiple assignment with single variable > - > > Key: GROOVY-8150 > URL: https://issues.apache.org/jira/browse/GROOVY-8150 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.5.0-alpha-1, 2.4.10 >Reporter: Daniil Ovchinnikov > > {code} > def a > def b = [1] > a = b > println "${a} : ${a.class}" // [1] : class java.util.ArrayList > (a) = b > println "${a} : ${a.class}" // 1 : class java.lang.Integer > ((a)) = b > println "${a} : ${a.class}" // [1] : class java.util.ArrayList > {code} > This is confusing. Here are options: > 1. {{((a)) = b}} should be failed to parse. > 2. {{((a)) = b}} should behave like {{(a) = b}}, i.e. number of parentheses > should not matter. > 3. {{((a)) = b}} and {{(a) = b}} should behave like {{a = b}}. This will > match the following case also: > {code} > class A { def myField } > def a = new A() > def b = [1] > a.myField = b > assert a.myField == [1] > (a.myField) = b > assert a.myField == [1] > ((a.myField)) = b > assert a.myField == [1] > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-8283) Field shadowing not considered in STC
[ https://issues.apache.org/jira/browse/GROOVY-8283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16121403#comment-16121403 ] Daniil Ovchinnikov commented on GROOVY-8283: This issue prevents using {{io.vertx.rxjava.core.AbstractVerticle}} in Groovy without workarounds (https://youtrack.jetbrains.com/issue/IDEA-177371) > Field shadowing not considered in STC > - > > Key: GROOVY-8283 > URL: https://issues.apache.org/jira/browse/GROOVY-8283 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code} > import groovy.transform.CompileStatic > @CompileStatic class A {} > @CompileStatic class B {} > @CompileStatic class Parent { > protected A ff = new A() > A getFf() { ff } > } > @CompileStatic class Child extends Parent { > protected B ff = new B() > } > @CompileStatic class Usage extends Child { > def test() { > println ff// A@id > println getFf() // A@id > println this.@ff // B@id > } > def test2() { > I.wantsB(ff)// > ScriptBytecodeAdapter.castToType(((Usage)this).getFf(), B.class)) is > generated (wrong) > I.wantsB(getFf()) // [STC] - Cannot find matching method I#wantsB(A) > I.wantsB(this.@ff) // [STC] - Cannot find matching method I#wantsB(A) > (wrong) > } > } > @CompileStatic class I { > static void wantsB(B b) {} > } > new Usage().test() > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8254) Alias is ignored in constructor call
[ https://issues.apache.org/jira/browse/GROOVY-8254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16085509#comment-16085509 ] Daniil Ovchinnikov commented on GROOVY-8254: If Bar is defined in another file in the same package then alias is used in both cases. I.e. alias takes precedence over classes in the same package. > Alias is ignored in constructor call > > > Key: GROOVY-8254 > URL: https://issues.apache.org/jira/browse/GROOVY-8254 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=foo/Foo.groovy} > package foo > class Foo {} > {code} > {code:title=test/test.groovy} > package test > import foo.Foo as Bar > class Bar {} > def regular = new Bar() > def anonymous = new Bar() {} > println regular.class // class test.Bar > println anonymous.class.superclass // class foo.Foo > {code} > Either both of the invocations should use alias or both of them should use > class defined in the same file. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8263) Import alias introduces weird property
Daniil Ovchinnikov created GROOVY-8263: -- Summary: Import alias introduces weird property Key: GROOVY-8263 URL: https://issues.apache.org/jira/browse/GROOVY-8263 Project: Groovy Issue Type: Bug Components: Compiler Affects Versions: 2.4.12 Reporter: Daniil Ovchinnikov {code:title=com/foo/Bar.java} package com.foo; public class Bar { public static Object getSome() {return 42;} } {code} {code:title=playground.groovy} import static com.foo.Bar.some as getAbc println abc // 42 println getAbc println getGetAbc() {code} AFAIU an alias introduces property into a file which is being compiled (in this case {{getAbc}} and {{getGetAbc()}}). This works as expected. But {{abc}} should fail with MPE, instead it's actually resolved into a {{getSome()}}. Is it a bug or a feature? -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8263) Import alias introduces weird property
[ https://issues.apache.org/jira/browse/GROOVY-8263?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8263: --- Description: {code:title=com/foo/Bar.java} package com.foo; public class Bar { public static Object getSome() {return 42;} } {code} {code:title=playground.groovy} import static com.foo.Bar.some as getAbc println abc // 42 println getAbc println getGetAbc() {code} AFAIU an alias introduces property into a file which is being compiled (in this case {{getAbc}} and {{getGetAbc()}}). This works as expected. But {{abc}} should fail with MPE, instead it's actually resolved into a {{getSome()}}. This happens when alias is itself a valid getter name. Is it a bug or a feature? One more thing to consider. Given {{abc}} is valid, {{getAbc()}} should be valid too. Instead it behaves like {{getAbc.call()}}. was: {code:title=com/foo/Bar.java} package com.foo; public class Bar { public static Object getSome() {return 42;} } {code} {code:title=playground.groovy} import static com.foo.Bar.some as getAbc println abc // 42 println getAbc println getGetAbc() {code} AFAIU an alias introduces property into a file which is being compiled (in this case {{getAbc}} and {{getGetAbc()}}). This works as expected. But {{abc}} should fail with MPE, instead it's actually resolved into a {{getSome()}}. Is it a bug or a feature? > Import alias introduces weird property > -- > > Key: GROOVY-8263 > URL: https://issues.apache.org/jira/browse/GROOVY-8263 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=com/foo/Bar.java} > package com.foo; > public class Bar { > public static Object getSome() {return 42;} > } > {code} > {code:title=playground.groovy} > import static com.foo.Bar.some as getAbc > println abc // 42 > println getAbc > println getGetAbc() > {code} > AFAIU an alias introduces property into a file which is being compiled (in > this case {{getAbc}} and {{getGetAbc()}}). This works as expected. > But {{abc}} should fail with MPE, instead it's actually resolved into a > {{getSome()}}. > This happens when alias is itself a valid getter name. > Is it a bug or a feature? > One more thing to consider. > Given {{abc}} is valid, {{getAbc()}} should be valid too. Instead it behaves > like {{getAbc.call()}}. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8263) Import alias introduces weird property
[ https://issues.apache.org/jira/browse/GROOVY-8263?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8263: --- Description: {code:title=com/foo/Bar.java} package com.foo; public class Bar { public static Object getSome() {return 42;} } {code} {code:title=playground.groovy} import static com.foo.Bar.some as getAbc println abc // 42 println getAbc println getGetAbc() {code} AFAIU an alias introduces property into a file which is being compiled (in this case {{getAbc}} and {{getGetAbc()}} become valid). This works as expected. But {{abc}} should fail with MPE, instead it's actually resolved into a {{getSome()}}. This happens when alias is itself a valid getter name. Is it a bug or a feature? One more thing to consider. Given {{abc}} is valid, {{getAbc()}} should be valid too. Instead it behaves like {{getAbc.call()}}. was: {code:title=com/foo/Bar.java} package com.foo; public class Bar { public static Object getSome() {return 42;} } {code} {code:title=playground.groovy} import static com.foo.Bar.some as getAbc println abc // 42 println getAbc println getGetAbc() {code} AFAIU an alias introduces property into a file which is being compiled (in this case {{getAbc}} and {{getGetAbc()}}). This works as expected. But {{abc}} should fail with MPE, instead it's actually resolved into a {{getSome()}}. This happens when alias is itself a valid getter name. Is it a bug or a feature? One more thing to consider. Given {{abc}} is valid, {{getAbc()}} should be valid too. Instead it behaves like {{getAbc.call()}}. > Import alias introduces weird property > -- > > Key: GROOVY-8263 > URL: https://issues.apache.org/jira/browse/GROOVY-8263 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=com/foo/Bar.java} > package com.foo; > public class Bar { > public static Object getSome() {return 42;} > } > {code} > {code:title=playground.groovy} > import static com.foo.Bar.some as getAbc > println abc // 42 > println getAbc > println getGetAbc() > {code} > AFAIU an alias introduces property into a file which is being compiled (in > this case {{getAbc}} and {{getGetAbc()}} become valid). This works as > expected. > But {{abc}} should fail with MPE, instead it's actually resolved into a > {{getSome()}}. > This happens when alias is itself a valid getter name. > Is it a bug or a feature? > One more thing to consider. > Given {{abc}} is valid, {{getAbc()}} should be valid too. Instead it behaves > like {{getAbc.call()}}. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8264) Setter accessed via getter import alias with setter name
[ https://issues.apache.org/jira/browse/GROOVY-8264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8264: --- Summary: Setter accessed via getter import alias with setter name (was: Setter accessed via import alias of a getter with setter name) > Setter accessed via getter import alias with setter name > > > Key: GROOVY-8264 > URL: https://issues.apache.org/jira/browse/GROOVY-8264 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=com/foo/Bar.java}package com.foo; > public class Bar { > public static Object getSome() { > System.out.println("getter"); > return 42; > } > public static void setSome(Object a) { > System.out.println("setter " + a); > } > } > {code} > {code:title=playground.groovy} > import static com.foo.Bar.getSome as setAbc > setAbc() // prints 'getter' > setAbc(2) // MME: No signature of method: static com.foo.Bar.getSome() is > applicable > abc = 1 // prints 'setter 1', should throw MME > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8264) Setter accessed via import alias of a getter with setter name
Daniil Ovchinnikov created GROOVY-8264: -- Summary: Setter accessed via import alias of a getter with setter name Key: GROOVY-8264 URL: https://issues.apache.org/jira/browse/GROOVY-8264 Project: Groovy Issue Type: Bug Components: Compiler Affects Versions: 2.4.12 Reporter: Daniil Ovchinnikov {code:title=com/foo/Bar.java}package com.foo; public class Bar { public static Object getSome() { System.out.println("getter"); return 42; } public static void setSome(Object a) { System.out.println("setter " + a); } } {code} {code:title=playground.groovy} import static com.foo.Bar.getSome as setAbc setAbc() // prints 'getter' setAbc(2) // MME: No signature of method: static com.foo.Bar.getSome() is applicable abc = 1 // prints 'setter 1', should throw MME {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8264) Wrong method accessed via aliased import
[ https://issues.apache.org/jira/browse/GROOVY-8264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8264: --- Summary: Wrong method accessed via aliased import (was: Wrong meth) > Wrong method accessed via aliased import > > > Key: GROOVY-8264 > URL: https://issues.apache.org/jira/browse/GROOVY-8264 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=com/foo/Bar.java}package com.foo; > public class Bar { > public static Object getSome() { > System.out.println("getter"); > return 42; > } > public static void setSome(Object a) { > System.out.println("setter " + a); > } > } > {code} > {code:title=getterAsSetter.groovy} > import static com.foo.Bar.getSome as setAbc > setAbc() // prints 'getter' as expected > setAbc(2) // throws MME as expected (No signature of method: static > com.foo.Bar.getSome() is applicable) > abc = 2 // prints 'setter 2'; should throw MME, because it's equivalent to > setAbc(2) > {code} > {code:title=setterAsGetter.groovy} > import static com.foo.Bar.setSome as getAbc > getAbc(null) // prints 'setter null' as expected > getAbc() // prints 'setter null' as expected, equivalent to getAbc(null) > abc // prints 'getter'; should print 'setter null', because it's > equivalent to getAbc() > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8264) Wrong meth
[ https://issues.apache.org/jira/browse/GROOVY-8264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8264: --- Summary: Wrong meth (was: Setter accessed via getter import alias with setter name) > Wrong meth > -- > > Key: GROOVY-8264 > URL: https://issues.apache.org/jira/browse/GROOVY-8264 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=com/foo/Bar.java}package com.foo; > public class Bar { > public static Object getSome() { > System.out.println("getter"); > return 42; > } > public static void setSome(Object a) { > System.out.println("setter " + a); > } > } > {code} > {code:title=getterAsSetter.groovy} > import static com.foo.Bar.getSome as setAbc > setAbc() // prints 'getter' as expected > setAbc(2) // throws MME as expected (No signature of method: static > com.foo.Bar.getSome() is applicable) > abc = 2 // prints 'setter 2'; should throw MME, because it's equivalent to > setAbc(2) > {code} > {code:title=setterAsGetter.groovy} > import static com.foo.Bar.setSome as getAbc > getAbc(null) // prints 'setter null' as expected > getAbc() // prints 'setter null' as expected, equivalent to getAbc(null) > abc // prints 'getter'; should print 'setter null', because it's > equivalent to getAbc() > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8264) Setter accessed via getter import alias with setter name
[ https://issues.apache.org/jira/browse/GROOVY-8264?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8264: --- Description: {code:title=com/foo/Bar.java}package com.foo; public class Bar { public static Object getSome() { System.out.println("getter"); return 42; } public static void setSome(Object a) { System.out.println("setter " + a); } } {code} {code:title=getterAsSetter.groovy} import static com.foo.Bar.getSome as setAbc setAbc() // prints 'getter' as expected setAbc(2) // throws MME as expected (No signature of method: static com.foo.Bar.getSome() is applicable) abc = 2 // prints 'setter 2'; should throw MME, because it's equivalent to setAbc(2) {code} {code:title=setterAsGetter.groovy} import static com.foo.Bar.setSome as getAbc getAbc(null) // prints 'setter null' as expected getAbc() // prints 'setter null' as expected, equivalent to getAbc(null) abc // prints 'getter'; should print 'setter null', because it's equivalent to getAbc() {code} was: {code:title=com/foo/Bar.java}package com.foo; public class Bar { public static Object getSome() { System.out.println("getter"); return 42; } public static void setSome(Object a) { System.out.println("setter " + a); } } {code} {code:title=playground.groovy} import static com.foo.Bar.getSome as setAbc setAbc() // prints 'getter' setAbc(2) // MME: No signature of method: static com.foo.Bar.getSome() is applicable abc = 1 // prints 'setter 1', should throw MME {code} > Setter accessed via getter import alias with setter name > > > Key: GROOVY-8264 > URL: https://issues.apache.org/jira/browse/GROOVY-8264 > Project: Groovy > Issue Type: Bug > Components: Compiler >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=com/foo/Bar.java}package com.foo; > public class Bar { > public static Object getSome() { > System.out.println("getter"); > return 42; > } > public static void setSome(Object a) { > System.out.println("setter " + a); > } > } > {code} > {code:title=getterAsSetter.groovy} > import static com.foo.Bar.getSome as setAbc > setAbc() // prints 'getter' as expected > setAbc(2) // throws MME as expected (No signature of method: static > com.foo.Bar.getSome() is applicable) > abc = 2 // prints 'setter 2'; should throw MME, because it's equivalent to > setAbc(2) > {code} > {code:title=setterAsGetter.groovy} > import static com.foo.Bar.setSome as getAbc > getAbc(null) // prints 'setter null' as expected > getAbc() // prints 'setter null' as expected, equivalent to getAbc(null) > abc // prints 'getter'; should print 'setter null', because it's > equivalent to getAbc() > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8254) Alias is ignored in constructor call
Daniil Ovchinnikov created GROOVY-8254: -- Summary: Alias is ignored in constructor call Key: GROOVY-8254 URL: https://issues.apache.org/jira/browse/GROOVY-8254 Project: Groovy Issue Type: Bug Affects Versions: 2.4.12 Reporter: Daniil Ovchinnikov {code:title=foo/Foo.groovy} package foo class Foo {} {code} {code:title=test/test.groovy} package test import foo.Foo as Bar class Bar {} def regular = new Bar() def anonymous = new Bar() {} println regular.class // class test.Bar println anonymous.class.superclass // class foo.Foo {code} Either both of the invocations should use alias or both of them should use class defined in the same file. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8254) Alias is ignored in constructor call
[ https://issues.apache.org/jira/browse/GROOVY-8254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16084571#comment-16084571 ] Daniil Ovchinnikov commented on GROOVY-8254: Please clarify how this should work, so I could change IntelliJ behaviour accordingly. > Alias is ignored in constructor call > > > Key: GROOVY-8254 > URL: https://issues.apache.org/jira/browse/GROOVY-8254 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=foo/Foo.groovy} > package foo > class Foo {} > {code} > {code:title=test/test.groovy} > package test > import foo.Foo as Bar > class Bar {} > def regular = new Bar() > def anonymous = new Bar() {} > println regular.class // class test.Bar > println anonymous.class.superclass // class foo.Foo > {code} > Either both of the invocations should use alias or both of them should use > class defined in the same file. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8243) SAM trait middle coercion via middle interface
Daniil Ovchinnikov created GROOVY-8243: -- Summary: SAM trait middle coercion via middle interface Key: GROOVY-8243 URL: https://issues.apache.org/jira/browse/GROOVY-8243 Project: Groovy Issue Type: Bug Affects Versions: 2.4.10 Reporter: Daniil Ovchinnikov {code} trait T { abstract def foo(int i) def bar(double j) { println "bar $j" } } interface F extends T {} F t = { println "closure $it" } t.foo(42) // `closure 42` t.bar(43) // `closure 43.0`; should be `bar 43.0` {code} Changing variable type to {{T}} works as expected. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8244) SAM trait coercion with default parameters
Daniil Ovchinnikov created GROOVY-8244: -- Summary: SAM trait coercion with default parameters Key: GROOVY-8244 URL: https://issues.apache.org/jira/browse/GROOVY-8244 Project: Groovy Issue Type: Bug Affects Versions: 2.4.10 Reporter: Daniil Ovchinnikov {code} trait T { abstract def foo(a, b = 1) } T t = { o1, o2 -> println o1 assert o2 == 1 } t.foo(42) // Caught: groovy.lang.MissingMethodException: No signature of method: abstractMethod$_run_closure1.doCall() is applicable for argument types: (java.lang.Integer) values: [42] {code} Expected result: it should just work or throw GroovyCastException in case of traits are not SAM candidates -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8243) SAM trait coercion via middle interface
[ https://issues.apache.org/jira/browse/GROOVY-8243?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8243: --- Summary: SAM trait coercion via middle interface (was: SAM trait middle coercion via middle interface) > SAM trait coercion via middle interface > --- > > Key: GROOVY-8243 > URL: https://issues.apache.org/jira/browse/GROOVY-8243 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.4.10 >Reporter: Daniil Ovchinnikov > > {code} > trait T { > abstract def foo(int i) > def bar(double j) { > println "bar $j" > } > } > interface F extends T {} > F t = { println "closure $it" } > t.foo(42) // `closure 42` > t.bar(43) // `closure 43.0`; should be `bar 43.0` > {code} > Changing variable type to {{T}} works as expected. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8243) SAM trait middle coercion via middle interface
[ https://issues.apache.org/jira/browse/GROOVY-8243?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16070345#comment-16070345 ] Daniil Ovchinnikov commented on GROOVY-8243: If traits are not SAM candidates, please throw GroovyCastException on assignment. > SAM trait middle coercion via middle interface > -- > > Key: GROOVY-8243 > URL: https://issues.apache.org/jira/browse/GROOVY-8243 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.4.10 >Reporter: Daniil Ovchinnikov > > {code} > trait T { > abstract def foo(int i) > def bar(double j) { > println "bar $j" > } > } > interface F extends T {} > F t = { println "closure $it" } > t.foo(42) // `closure 42` > t.bar(43) // `closure 43.0`; should be `bar 43.0` > {code} > Changing variable type to {{T}} works as expected. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8241) SAM parameter type inference for explicit parameter
Daniil Ovchinnikov created GROOVY-8241: -- Summary: SAM parameter type inference for explicit parameter Key: GROOVY-8241 URL: https://issues.apache.org/jira/browse/GROOVY-8241 Project: Groovy Issue Type: Bug Components: Static compilation, Static Type Checker Affects Versions: 2.4.10 Reporter: Daniil Ovchinnikov {code} import groovy.transform.CompileStatic import java.util.function.Predicate @CompileStatic static boolean foo(Predicate p) { p.test("foo") } @CompileStatic static def testPredicate() { foo { // it -> it.toUpperCase() true } } {code} Uncomment {{it}}, compiler will say: {noformat} Cannot find matching method java.lang.Object#toUpperCase() {noformat} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8248) MethodSelectionException when calling a overloaded method without arguments
Daniil Ovchinnikov created GROOVY-8248: -- Summary: MethodSelectionException when calling a overloaded method without arguments Key: GROOVY-8248 URL: https://issues.apache.org/jira/browse/GROOVY-8248 Project: Groovy Issue Type: Bug Affects Versions: 2.4.10 Reporter: Daniil Ovchinnikov {code} def methodWithOverload(a, b) { println "$a $b" } def methodWithOverload(a) { methodWithOverload(a, new Object()) } methodWithOverload("hello", "world") methodWithOverload("hello") methodWithOverload() // MSE here {code} {noformat} Caught: org.codehaus.groovy.runtime.metaclass.MethodSelectionException: Could not find which method methodWithOverload() to invoke from this list: public java.lang.Object myscript#methodWithOverload(java.lang.Object) public java.lang.Object myscript#methodWithOverload(java.lang.Object, java.lang.Object) {noformat} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8247) AIOOBE in StaticTypeCheckingVisitor with SAM and explicit closure parameter
[ https://issues.apache.org/jira/browse/GROOVY-8247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16073454#comment-16073454 ] Daniil Ovchinnikov commented on GROOVY-8247: I've created two separate issues because of different stack traces. Please mark GROOVY-8247 as duplicate if it's actually a duplicate. > AIOOBE in StaticTypeCheckingVisitor with SAM and explicit closure parameter > --- > > Key: GROOVY-8247 > URL: https://issues.apache.org/jira/browse/GROOVY-8247 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker >Affects Versions: 2.4.10 >Reporter: Daniil Ovchinnikov > > {code} > def runnable(Runnable r) { > r.run() > } > @CompileStatic > def foo() { > runnable { it -> // note explicit it > println it > } > } > foo() > {code} > {noformat} > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > General error during instruction selection: 0 > java.lang.ArrayIndexOutOfBoundsException: 0 > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferSAMType(StaticTypeCheckingVisitor.java:2424) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferClosureParameterTypes(StaticTypeCheckingVisitor.java:2362) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2326) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:3030) > at > org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:358) > at > org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) > at > org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:71) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:196) > at > org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42) > at > org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166) > at > org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1816) > at > org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2151) > at > org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2110) > at > org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:185) > at > org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:76) > at > org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134) > at > org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178) > at > org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065) > at > org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603) > at > org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581) > at > org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558) > at > groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) > at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) > at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688) > at groovy.lang.GroovyShell.run(GroovyShell.java:517) > at groovy.lang.GroovyShell.run(GroovyShell.java:507) > at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653) > at groovy.ui.GroovyMain.run(GroovyMain.java:384) > at groovy.ui.GroovyMain.process(GroovyMain.java:370) > at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129) > at groovy.ui.GroovyMain.main(GroovyMain.java:109) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at >
[jira] [Created] (GROOVY-8247) AIOOBE in StaticTypeCheckingVisitor with SAM and explicit closure parameter
Daniil Ovchinnikov created GROOVY-8247: -- Summary: AIOOBE in StaticTypeCheckingVisitor with SAM and explicit closure parameter Key: GROOVY-8247 URL: https://issues.apache.org/jira/browse/GROOVY-8247 Project: Groovy Issue Type: Bug Components: Static compilation, Static Type Checker Affects Versions: 2.4.10 Reporter: Daniil Ovchinnikov {code} def runnable(Runnable r) { r.run() } @CompileStatic def foo() { runnable { it -> // note explicit it println it } } foo() {code} {noformat} org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: General error during instruction selection: 0 java.lang.ArrayIndexOutOfBoundsException: 0 at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferSAMType(StaticTypeCheckingVisitor.java:2424) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.inferClosureParameterTypes(StaticTypeCheckingVisitor.java:2362) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallArguments(StaticTypeCheckingVisitor.java:2326) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethodCallExpression(StaticTypeCheckingVisitor.java:3030) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethodCallExpression(StaticCompilationVisitor.java:358) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) at org.codehaus.groovy.ast.CodeVisitorSupport.visitExpressionStatement(CodeVisitorSupport.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitExpressionStatement(ClassCodeVisitorSupport.java:196) at org.codehaus.groovy.ast.stmt.ExpressionStatement.visit(ExpressionStatement.java:42) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:37) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:166) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:104) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:115) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitConstructorOrMethod(StaticTypeCheckingVisitor.java:1816) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitMethod(ClassCodeVisitorSupport.java:126) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.startMethodInference(StaticTypeCheckingVisitor.java:2151) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.visitMethod(StaticTypeCheckingVisitor.java:2110) at org.codehaus.groovy.transform.sc.StaticCompilationVisitor.visitMethod(StaticCompilationVisitor.java:185) at org.codehaus.groovy.transform.sc.StaticCompileTransformation.visit(StaticCompileTransformation.java:76) at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:134) at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:178) at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1065) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558) at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688) at groovy.lang.GroovyShell.run(GroovyShell.java:517) at groovy.lang.GroovyShell.run(GroovyShell.java:507) at groovy.ui.GroovyMain.processOnce(GroovyMain.java:653) at groovy.ui.GroovyMain.run(GroovyMain.java:384) at groovy.ui.GroovyMain.process(GroovyMain.java:370) at groovy.ui.GroovyMain.processArgs(GroovyMain.java:129) at groovy.ui.GroovyMain.main(GroovyMain.java:109) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.groovy.tools.GroovyStarter.rootLoader(GroovyStarter.java:109) at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:131) {noformat} -- This message was sent by Atlassian JIRA
[jira] [Created] (GROOVY-8252) AIOOBE in combination of ncurry and rcurry
Daniil Ovchinnikov created GROOVY-8252: -- Summary: AIOOBE in combination of ncurry and rcurry Key: GROOVY-8252 URL: https://issues.apache.org/jira/browse/GROOVY-8252 Project: Groovy Issue Type: Bug Affects Versions: 2.4.12 Reporter: Daniil Ovchinnikov {code} def c = { a, b, c, d -> println a + b + c + d } c.ncurry(0, "a").rcurry("c", "d")() // note no args passed {code} Expected: MissingMethodException or {{null}} passed. Actual: {noformat} java.lang.ArrayIndexOutOfBoundsException at java_util_concurrent_Callable$call.call(Unknown Source) {noformat} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8152) Weird .class references
[ https://issues.apache.org/jira/browse/GROOVY-8152?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8152: --- Description: {code} println(String) // class java.lang.String println(String.class) // class java.lang.String println(String.class.class) // class java.lang.String println(String.class.class.class) // class java.lang.Class {code} While I understand that the first and the second lines are equivalent, I don't get behaviour of the third, which causes the following to work: {code} println(String[].class[].class.class[]) // class [[[Ljava.lang.String; {code} Expected result: {code} assert String.class.class == String.class.getClass() assert String[].class.class == String[].class.getClass() {code} was: {code} println(String) // class java.lang.String println(String.class) // class java.lang.String println(String.class.class) // class java.lang.String println(String.class.class.class) // class java.lang.Class {code} While I understand that the first and the second lines are equivalent, I don't get behaviour of the third, which causes the following: {code} println(String[].class[].class.class[]) // class [[[Ljava.lang.String; {code} Expected result: {code} assert String.class.class == String.class.getClass() assert String[].class.class == String[].class.getClass() {code} > Weird .class references > --- > > Key: GROOVY-8152 > URL: https://issues.apache.org/jira/browse/GROOVY-8152 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.5.0-alpha-1, 2.4.10 >Reporter: Daniil Ovchinnikov > > {code} > println(String) // class java.lang.String > println(String.class) // class java.lang.String > println(String.class.class) // class java.lang.String > println(String.class.class.class) // class java.lang.Class > {code} > While I understand that the first and the second lines are equivalent, I > don't get behaviour of the third, which causes the following to work: > {code} > println(String[].class[].class.class[]) // class [[[Ljava.lang.String; > {code} > Expected result: > {code} > assert String.class.class == String.class.getClass() > assert String[].class.class == String[].class.getClass() > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Updated] (GROOVY-8154) Parenthesized class literal with subscript operator
[ https://issues.apache.org/jira/browse/GROOVY-8154?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8154: --- Description: Current behaviour: {code} assert (String.class)[] == String[].class {code} Expected: {{(String.class)[]}} should fail with {{MissingMethodException: No signature of method: static java.lang.String.getAt() is applicable for argument types: (ArrayList) values: [[]]}} just like: {code} def a = String.class a[] // MissingMethodException {code} was: Current behaviour: {code} assert (String.class)[] == String[].class {code} Expected {{(String.class)[]}} should fail with {{MissingMethodException: No signature of method: static java.lang.String.getAt() is applicable for argument types: (ArrayList) values: [[]]}} just like: {code} def a = String.class a[] // MissingMethodException {code} > Parenthesized class literal with subscript operator > --- > > Key: GROOVY-8154 > URL: https://issues.apache.org/jira/browse/GROOVY-8154 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.5.0-alpha-1, 2.4.10 >Reporter: Daniil Ovchinnikov > > Current behaviour: > {code} > assert (String.class)[] == String[].class > {code} > Expected: {{(String.class)[]}} should fail with {{MissingMethodException: No > signature of method: static java.lang.String.getAt() is applicable for > argument types: (ArrayList) values: [[]]}} just like: > {code} > def a = String.class > a[] // MissingMethodException > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Commented] (GROOVY-8214) Implicit .call is inconsistent
[ https://issues.apache.org/jira/browse/GROOVY-8214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16036778#comment-16036778 ] Daniil Ovchinnikov commented on GROOVY-8214: All cases work when value returned from property is a {{Closure}}. In {{Closure}} cases explicit method takes precedence: {code} class A { def getFoo() { return { "closure" } } def foo() { "method" } } println new A().foo() // method {code} I see no reason not to allow the same behaviour for all objects with {{.call()}} defined. There is special handling for closures in {{groovy.lang.MetaClassImpl#invokePropertyOrMissing}}. In may be replaced with something like this (pseudocode): {code} if (/*necessary checks*/) return invokeMethod(value, "call", args) {code} > Implicit .call is inconsistent > -- > > Key: GROOVY-8214 > URL: https://issues.apache.org/jira/browse/GROOVY-8214 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov > > {code} > interface Callable { > def call() > } > def callable = new Callable() { > def call() { println "callable local var" } > } > callable.call() > callable() > class ClassWithCallableField { > public ppp = new Callable() { > def call() { println "callable field" } > } > } > def cwcp = new ClassWithCallableField() > cwcp.ppp.call() > cwcp.ppp() // MME > def foo(Callable p) { > p.call() > p() > } > foo new Callable() { > def call() { println "callable parameter" } > } > class ClassWithCallableGetter { > def getGetter() { > new Callable() { > def call() { println "callable getter" } > } > } > } > def cwcg = new ClassWithCallableGetter() > cwcg.getter.call() > cwcg.getter() // MME > class ClassWithCallableFieldInside { > public bbb = new Callable() { > def call() { println "callable field inside class" } > } > def foo() { > bbb.call() > bbb() > } > } > new ClassWithCallableFieldInside().foo() > class ClassWithCallableGetterInside { > def getGetter() { > new Callable() { > def call() { println "callable getter inside class" } > } > } > def foo() { > getter.call() > getter() // MME > } > } > new ClassWithCallableGetterInside().foo() > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Created] (GROOVY-8214) Implicit .call is inconsistent
Daniil Ovchinnikov created GROOVY-8214: -- Summary: Implicit .call is inconsistent Key: GROOVY-8214 URL: https://issues.apache.org/jira/browse/GROOVY-8214 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov {code} interface Callable { def call() } def callable = new Callable() { def call() { println "callable local var" } } callable.call() callable() class ClassWithCallableField { public ppp = new Callable() { def call() { println "callable field" } } } def cwcp = new ClassWithCallableField() cwcp.ppp.call() cwcp.ppp() // MME def foo(Callable p) { p.call() p() } foo new Callable() { def call() { println "callable parameter" } } class ClassWithCallableGetter { def getGetter() { new Callable() { def call() { println "callable getter" } } } } def cwcg = new ClassWithCallableGetter() cwcg.getter.call() cwcg.getter() // MME class ClassWithCallableFieldInside { public bbb = new Callable() { def call() { println "callable field inside class" } } def foo() { bbb.call() bbb() } } new ClassWithCallableFieldInside().foo() class ClassWithCallableGetterInside { def getGetter() { new Callable() { def call() { println "callable getter inside class" } } } def foo() { getter.call() getter() // MME } } new ClassWithCallableGetterInside().foo() {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Created] (GROOVY-8215) Implicit .call doesn't work with operators
Daniil Ovchinnikov created GROOVY-8215: -- Summary: Implicit .call doesn't work with operators Key: GROOVY-8215 URL: https://issues.apache.org/jira/browse/GROOVY-8215 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov {code} interface Callable { def call(it) } class ClassWithPlusClosure { def getPlus() { return { println it } } } def cwpc = new ClassWithPlusClosure() cwpc.getPlus().call(1) // explicit cwpc.plus.call(2) // plus as a property cwpc.plus(3) // implicit .call on plus property cwpc + 4// works as expected class ClassWithPlusCallable { def getPlus() { new Callable() { def call(it) { println it } } } } def cwpcallable = new ClassWithPlusCallable() cwpcallable.getPlus().call(1) cwpcallable.plus.call(2) cwpcallable.plus(3) // MME; see linked issue cwpcallable + 4 // MME {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Updated] (GROOVY-8215) Implicit .call doesn't work with operators
[ https://issues.apache.org/jira/browse/GROOVY-8215?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8215: --- Description: {code} interface Callable { def call(it) } class ClassWithPlusClosure { def getPlus() { return { println it } } } def cwpc = new ClassWithPlusClosure() cwpc.getPlus().call(1) // explicit cwpc.plus.call(2) // plus as a property cwpc.plus(3)// implicit .call on plus property cwpc + 4// works as expected class ClassWithPlusCallable { def getPlus() { new Callable() { def call(it) { println it } } } } def cwpcallable = new ClassWithPlusCallable() cwpcallable.getPlus().call(1) cwpcallable.plus.call(2) cwpcallable.plus(3) // MME; see linked issue cwpcallable + 4 // MME {code} was: {code} interface Callable { def call(it) } class ClassWithPlusClosure { def getPlus() { return { println it } } } def cwpc = new ClassWithPlusClosure() cwpc.getPlus().call(1) // explicit cwpc.plus.call(2) // plus as a property cwpc.plus(3) // implicit .call on plus property cwpc + 4// works as expected class ClassWithPlusCallable { def getPlus() { new Callable() { def call(it) { println it } } } } def cwpcallable = new ClassWithPlusCallable() cwpcallable.getPlus().call(1) cwpcallable.plus.call(2) cwpcallable.plus(3) // MME; see linked issue cwpcallable + 4 // MME {code} > Implicit .call doesn't work with operators > -- > > Key: GROOVY-8215 > URL: https://issues.apache.org/jira/browse/GROOVY-8215 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov > > {code} > interface Callable { > def call(it) > } > class ClassWithPlusClosure { > def getPlus() { return { println it } } > } > def cwpc = new ClassWithPlusClosure() > cwpc.getPlus().call(1) // explicit > cwpc.plus.call(2) // plus as a property > cwpc.plus(3)// implicit .call on plus property > cwpc + 4// works as expected > class ClassWithPlusCallable { > def getPlus() { > new Callable() { > def call(it) { println it } > } > } > } > def cwpcallable = new ClassWithPlusCallable() > cwpcallable.getPlus().call(1) > cwpcallable.plus.call(2) > cwpcallable.plus(3) // MME; see linked issue > cwpcallable + 4 // MME > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)
[jira] [Created] (GROOVY-8309) Cannot DGM.plus() two lists with different types
Daniil Ovchinnikov created GROOVY-8309: -- Summary: Cannot DGM.plus() two lists with different types Key: GROOVY-8309 URL: https://issues.apache.org/jira/browse/GROOVY-8309 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov {code:title=Java} void foo(List s, List i) { DefaultGroovyMethods.plus(s, i); } {code} Expected: Javac should infer return type as {{List}}, but it can't. Possible fix: define {{DGM.plus}} with wildcard types {{? extends T}} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8355) Instanceof inference does not work on field assigning
[ https://issues.apache.org/jira/browse/GROOVY-8355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16209333#comment-16209333 ] Daniil Ovchinnikov commented on GROOVY-8355: I think that {{str = "str"}} is more _telling the compiler that the type is a String_ than {{if (str instanceof String) {}}. > Instanceof inference does not work on field assigning > - > > Key: GROOVY-8355 > URL: https://issues.apache.org/jira/browse/GROOVY-8355 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker >Reporter: Alexey Afanasiev > > If instanceof inference works as expected > [https://issues.apache.org/jira/browse/GROOVY-8293] So probably this code > should work to: > {code} > import groovy.transform.CompileStatic > @CompileStatic > class Foo { > Object str = new Object() > def bar() { > str = "str" > str.toUpperCase() // here compile error > } > } > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8355) Instanceof inference does not work on field assigning
[ https://issues.apache.org/jira/browse/GROOVY-8355?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16209340#comment-16209340 ] Daniil Ovchinnikov commented on GROOVY-8355: It turns out that in the example above the user should write: {code} str = "str" if (str instanceof String) { str.toUppercase() } {code} > Instanceof inference does not work on field assigning > - > > Key: GROOVY-8355 > URL: https://issues.apache.org/jira/browse/GROOVY-8355 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker >Reporter: Alexey Afanasiev > > If instanceof inference works as expected > [https://issues.apache.org/jira/browse/GROOVY-8293] So probably this code > should work to: > {code} > import groovy.transform.CompileStatic > @CompileStatic > class Foo { > Object str = new Object() > def bar() { > str = "str" > str.toUpperCase() // here compile error > } > } > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8354) Star imports allow partially-qualified types
[ https://issues.apache.org/jira/browse/GROOVY-8354?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16210913#comment-16210913 ] Daniil Ovchinnikov commented on GROOVY-8354: [~emilles] You are forgetting that a package cannot be referenced as it makes little sense contrary to referencing a class. I got a lot of troubles trying to support this _bug_ in IDEA. > Star imports allow partially-qualified types > > > Key: GROOVY-8354 > URL: https://issues.apache.org/jira/browse/GROOVY-8354 > Project: Groovy > Issue Type: Bug >Reporter: Eric Milles > > Star imports like {{import java.lang.*}} allow partially-qualified references > like {{reflect.Field}} to work. It appears this only works with explicit > star imports in a compilation unit, not default imports. > Some may call this a feature, but I couldn't find any description of it in > the [language > documentation|http://docs.groovy-lang.org/latest/html/documentation/#_star_import]. > And this bug results in a lot of extra work during type resolution, in > addition to the confusion it causes for Java developers. > I'm expecting an error for this, but it works just fine. > {code} > import groovy.transform.* > @builder.Builder > class Buildable { > Number number > String string > } > println Buildable.builder().build() > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8362) Nested class is resolved via another nested class with package name
[ https://issues.apache.org/jira/browse/GROOVY-8362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16215789#comment-16215789 ] Daniil Ovchinnikov commented on GROOVY-8362: I can provide pull requests for issues opened by me if somebody could explain if this is really a bug or an undocumented feature. > Nested class is resolved via another nested class with package name > --- > > Key: GROOVY-8362 > URL: https://issues.apache.org/jira/browse/GROOVY-8362 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code:title=bugs/bugs.groovy} > package bugs > class Current { > static class bugs { > static class Target {} > } > static usage() { > new Target() // error expected > } > } > println Current.usage() // bugs.Current$bugs$Target@20d28811 > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8358) Inner class resolution fails
[ https://issues.apache.org/jira/browse/GROOVY-8358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8358: --- Description: {code} package bugs class Outer implements OuterI { static class Current extends CurrentParent { static usage() { new Target() } } } class CurrentParent implements CurrentParentI {} interface CurrentParentI { static class Target {} } interface OuterI { static class Target {} } println Outer.Current.usage() // bugs.OuterI$Target@3eb7fc54 {code} If {{CurrentParent}} definition is moved before {{Outer}}, then {{new Target}} will be resolved to {{bugs.CurrentParentI$Target}}: {code} package bugs class CurrentParent implements CurrentParentI {} class Outer implements OuterI { class Current extends CurrentParent { static usage() { new Target() } } } interface CurrentParentI { static class Target {} } interface OuterI { static class Target {} } println Outer.Current.usage() // bugs.CurrentParentI$Target@3eb7fc54 {code} Moving classes must not affect results of compilation. was: {code} package bugs class Outer implements OuterI { class Current extends CurrentParent { static usage() { new Target() } } } class CurrentParent implements CurrentParentI {} interface CurrentParentI { static class Target {} } interface OuterI { static class Target {} } println Outer.Current.usage() // bugs.OuterI$Target@3eb7fc54 {code} If {{CurrentParent}} definition is moved before {{Outer}}, then {{new Target}} will be resolved to {{bugs.CurrentParentI$Target}}: {code} package bugs class CurrentParent implements CurrentParentI {} class Outer implements OuterI { class Current extends CurrentParent { static usage() { new Target() } } } interface CurrentParentI { static class Target {} } interface OuterI { static class Target {} } println Outer.Current.usage() // bugs.CurrentParentI$Target@3eb7fc54 {code} Moving classes must not affect results of compilation. > Inner class resolution fails > > > Key: GROOVY-8358 > URL: https://issues.apache.org/jira/browse/GROOVY-8358 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code} > package bugs > class Outer implements OuterI { > static class Current extends CurrentParent { > static usage() { > new Target() > } > } > } > class CurrentParent implements CurrentParentI {} > interface CurrentParentI { > static class Target {} > } > interface OuterI { > static class Target {} > } > println Outer.Current.usage() // bugs.OuterI$Target@3eb7fc54 > {code} > If {{CurrentParent}} definition is moved before {{Outer}}, then {{new > Target}} will be resolved to {{bugs.CurrentParentI$Target}}: > {code} > package bugs > class CurrentParent implements CurrentParentI {} > class Outer implements OuterI { > class Current extends CurrentParent { > static usage() { > new Target() > } > } > } > interface CurrentParentI { > static class Target {} > } > interface OuterI { > static class Target {} > } > println Outer.Current.usage() // bugs.CurrentParentI$Target@3eb7fc54 > {code} > Moving classes must not affect results of compilation. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8359) Inner class is not resolved if compiled separately
[ https://issues.apache.org/jira/browse/GROOVY-8359?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8359: --- Description: {code:title=classes.groovy} package bugs class CurrentParent { static class Target {} } {code} {code:title=bug.groovy} package bugs class Current extends CurrentParent { static usage() { new Target() } } {code} This works if files are compiled together, but fails if files are compiled one by one with {{Error:(5, 5) Groovyc: unable to resolve class Target}} was: {code:title=classes.groovy} package bugs class CurrentParent { static class Target {} } {code} {code:title=bug.groovy} package bugs class Current extends CurrentParent { static usage() { new Target() } } {code} This works if files are compiled together, but fails if files are compiled one by one with {{// Error:(5, 5) Groovyc: unable to resolve class Target}} > Inner class is not resolved if compiled separately > -- > > Key: GROOVY-8359 > URL: https://issues.apache.org/jira/browse/GROOVY-8359 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code:title=classes.groovy} > package bugs > class CurrentParent { > static class Target {} > } > {code} > {code:title=bug.groovy} > package bugs > class Current extends CurrentParent { > static usage() { > new Target() > } > } > {code} > This works if files are compiled together, but fails if files are compiled > one by one with {{Error:(5, 5) Groovyc: unable to resolve class Target}} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8358) Inner class resolution fails
Daniil Ovchinnikov created GROOVY-8358: -- Summary: Inner class resolution fails Key: GROOVY-8358 URL: https://issues.apache.org/jira/browse/GROOVY-8358 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov Priority: Critical {code} package bugs class Outer implements OuterI { class Current extends CurrentParent { static usage() { new Target() } } } class CurrentParent implements CurrentParentI {} interface CurrentParentI { static class Target {} } interface OuterI { static class Target {} } println Outer.Current.usage() // bugs.OuterI$Target@3eb7fc54 {code} If {{CurrentParent}} definition is moved before {{Outer}}, then {{new Target}} will be resolved to {{bugs.CurrentParentI$Target}}: {code} package bugs class CurrentParent implements CurrentParentI {} class Outer implements OuterI { class Current extends CurrentParent { static usage() { new Target() } } } interface CurrentParentI { static class Target {} } interface OuterI { static class Target {} } println Outer.Current.usage() // bugs.CurrentParentI$Target@3eb7fc54 {code} Moving classes must not affect results of compilation. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8358) Inner class resolution behaves differently depending on class order
[ https://issues.apache.org/jira/browse/GROOVY-8358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8358: --- Summary: Inner class resolution behaves differently depending on class order (was: Inner class resolution fails) > Inner class resolution behaves differently depending on class order > --- > > Key: GROOVY-8358 > URL: https://issues.apache.org/jira/browse/GROOVY-8358 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code} > package bugs > class Outer implements OuterI { > static class Current extends CurrentParent { > static usage() { > new Target() > } > } > } > class CurrentParent implements CurrentParentI {} > interface CurrentParentI { > static class Target {} > } > interface OuterI { > static class Target {} > } > println Outer.Current.usage() // bugs.OuterI$Target@3eb7fc54 > {code} > If {{CurrentParent}} definition is moved before {{Outer}}, then {{new > Target}} will be resolved to {{bugs.CurrentParentI$Target}}: > {code} > package bugs > class CurrentParent implements CurrentParentI {} > class Outer implements OuterI { > class Current extends CurrentParent { > static usage() { > new Target() > } > } > } > interface CurrentParentI { > static class Target {} > } > interface OuterI { > static class Target {} > } > println Outer.Current.usage() // bugs.CurrentParentI$Target@3eb7fc54 > {code} > Moving classes must not affect results of compilation. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8359) Inner class is not resolved if compiled separately
Daniil Ovchinnikov created GROOVY-8359: -- Summary: Inner class is not resolved if compiled separately Key: GROOVY-8359 URL: https://issues.apache.org/jira/browse/GROOVY-8359 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov Priority: Critical {code:title=classes.groovy} package bugs class CurrentParent { static class Target {} } {code} {code:title=bug.groovy} package bugs class Current extends CurrentParent { static usage() { new Target() } } {code} This works if files are compiled together, but fails if files are compiled one by one with {{// Error:(5, 5) Groovyc: unable to resolve class Target}} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8365) Static and static star imports allow non fully qualified names
[ https://issues.apache.org/jira/browse/GROOVY-8365?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8365: --- Description: {code:title=bugs/classes.groovy} package bugs class ClassInTheSamePackage { static foo() { 42 } static class Inner {} } {code} {code:title=bugs/test.groovy} package bugs import static ClassInTheSamePackage.* println foo() // 42 println new Inner() // bugs.ClassInTheSamePackage$Inner@159f197 {code} Expected: {{ClassInTheSamePackage}} should be unresolved, and consequently {{foo}} and {{Inner}} will not resolve too OR this "feature" should be documented. was: {code:title=bugs/classes.groovy} package bugs class ClassInTheSamePackage { static foo() { 42 } static class Inner {} } {code} {code:title=bugs/test.groovy} package bugs import static ClassInTheSamePackage.* println foo() // 42 println new Inner() // bugs.ClassInTheSamePackage$Inner@159f197 {code} Expected: {{ClassInTheSamePackage}} is unresolved, and consequently {{foo}} and {{Inner}} are unresolved too. > Static and static star imports allow non fully qualified names > -- > > Key: GROOVY-8365 > URL: https://issues.apache.org/jira/browse/GROOVY-8365 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov > > {code:title=bugs/classes.groovy} > package bugs > class ClassInTheSamePackage { > static foo() { 42 } > static class Inner {} > } > {code} > {code:title=bugs/test.groovy} > package bugs > import static ClassInTheSamePackage.* > println foo() // 42 > println new Inner() // bugs.ClassInTheSamePackage$Inner@159f197 > {code} > Expected: {{ClassInTheSamePackage}} should be unresolved, and consequently > {{foo}} and {{Inner}} will not resolve too > OR this "feature" should be documented. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8365) Static and static star imports allow non fully qualified names
Daniil Ovchinnikov created GROOVY-8365: -- Summary: Static and static star imports allow non fully qualified names Key: GROOVY-8365 URL: https://issues.apache.org/jira/browse/GROOVY-8365 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov {code:title=bugs/classes.groovy} package bugs class ClassInTheSamePackage { static foo() { 42 } static class Inner {} } {code} {code:title=bugs/test.groovy} package bugs import static ClassInTheSamePackage.* println foo() // 42 println new Inner() // bugs.ClassInTheSamePackage$Inner@159f197 {code} Expected: {{ClassInTheSamePackage}} is unresolved, and consequently {{foo}} and {{Inner}} are unresolved too. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8394) @CompileStatic doesn't respect resolve strategy on closures
Daniil Ovchinnikov created GROOVY-8394: -- Summary: @CompileStatic doesn't respect resolve strategy on closures Key: GROOVY-8394 URL: https://issues.apache.org/jira/browse/GROOVY-8394 Project: Groovy Issue Type: Bug Components: Static compilation, Static Type Checker Affects Versions: 2.4.13 Reporter: Daniil Ovchinnikov {code} class Root { Parent parent = new Parent() def parent(@DelegatesTo(Parent) Closure cl) { cl.delegate = parent cl() } } class Parent { Child child = new Child() def child(@DelegatesTo(Child) Closure cl) { cl.delegate = child cl() } def foo() { "parent" } } class Child { def foo() { "child" } } @groovy.transform.CompileStatic def usage() { new Root().parent { child { foo() } } } println usage() {code} Expected result: {{parent}} Actual result: {{child}} Closure inside {{child }} call has default resolve strategy, i.e. owner first. Its owner is a closure passed to {{parent }}, which is delegated to {{Parent}}, which in turn has the method {{foo}}. Works properly without {{@CompileStatic}}. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8389) Static import of a property messes with instance method
Daniil Ovchinnikov created GROOVY-8389: -- Summary: Static import of a property messes with instance method Key: GROOVY-8389 URL: https://issues.apache.org/jira/browse/GROOVY-8389 Project: Groovy Issue Type: Bug Components: Static compilation, Static Type Checker Affects Versions: 2.4.13, 2.5.0-beta-2 Reporter: Daniil Ovchinnikov {code:title=bugs.groovy} import static A.bar class A { static bar = "A" } def bar() { "bar" } @groovy.transform.CompileStatic def usage() { bar() } println usage() {code} {noformat} 13: [Static type checking] - Cannot find matching method A#bar(). Please check if the declared type is right and if the method exists. @ line 13, column 3. bar() ^ {noformat} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Commented] (GROOVY-8254) Alias is ignored in constructor call
[ https://issues.apache.org/jira/browse/GROOVY-8254?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16251745#comment-16251745 ] Daniil Ovchinnikov commented on GROOVY-8254: AFAIU there are no differences in how aliased/regular imports are treated by compiler. I.e. in case of {code} import test.Bar import foo.Foo as Bar {code} the second import will overwrite the first one and vice versa, because essentially these imports are both _aliased_: {code} import test.Bar as Bar import foo.Foo as Bar {code} I suppose anonymous class references should obey the same rules as reference in new expression, i.e. prefer a class in the same file over any import. > Alias is ignored in constructor call > > > Key: GROOVY-8254 > URL: https://issues.apache.org/jira/browse/GROOVY-8254 > Project: Groovy > Issue Type: Bug >Affects Versions: 2.4.12 >Reporter: Daniil Ovchinnikov > > {code:title=foo/Foo.groovy} > package foo > class Foo {} > {code} > {code:title=test/test.groovy} > package test > import foo.Foo as Bar > class Bar {} > def regular = new Bar() > def anonymous = new Bar() {} > println regular.class // class test.Bar > println anonymous.class.superclass // class foo.Foo > {code} > Either both of the invocations should use alias or both of them should use > class defined in the same file. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8370) Compiler allows to extend/implement a class from its generic
Daniil Ovchinnikov created GROOVY-8370: -- Summary: Compiler allows to extend/implement a class from its generic Key: GROOVY-8370 URL: https://issues.apache.org/jira/browse/GROOVY-8370 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov Priority: Major {code} class A extends T implements T {} {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Comment Edited] (GROOVY-7956) Allow @DelegatesTo on named arguments
[ https://issues.apache.org/jira/browse/GROOVY-7956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15865747#comment-15865747 ] Daniil Ovchinnikov edited comment on GROOVY-7956 at 11/9/17 12:32 PM: -- EDIT: I don't think this is the best solution, but I leave this comment for history. I vote for: {code}@MapDescription(value = Point, required=['x']) void methodDescribed(Map point) { println "$p.x, $p.y" } // with ability to annotate parameters void methodDescribed2(someParameter, @MapDescription(Point) Map point) { println "$p.x, $p.y" } {code} The second allows such calls to be checked: {{methodDescribed2(42, \[x: 1, y: 2])}} If {{required}} is empty then all properties should be considered required. was (Author: daniilo): I vote for: {code}@MapDescription(value = Point, required=['x']) void methodDescribed(Map point) { println "$p.x, $p.y" } // with ability to annotate parameters void methodDescribed2(someParameter, @MapDescription(Point) Map point) { println "$p.x, $p.y" } {code} The second allows such calls to be checked: {{methodDescribed2(42, \[x: 1, y: 2])}} If {{required}} is empty then all properties should be considered required. > Allow @DelegatesTo on named arguments > - > > Key: GROOVY-7956 > URL: https://issues.apache.org/jira/browse/GROOVY-7956 > Project: Groovy > Issue Type: New Feature > Components: GEP >Reporter: Graeme Rocher > > In order to aid static compilation for builders we have {{@DelegatesTo}} > which allows statically compiled code to know what the delegate of a closure > is. > This proposal is to allow {{@DelegatesTo}} on {{Map}} types such that IDEs > and the static compiler can resolve the target type the named arguments are > to be used on. > For example: > {code} > class Farm { > void animal(@DelegatesTo(Animal) Map arguments, > @DelegatesTo(AnimalBuilder) Closure callable) { > def animal = new Animal(arguments) > // handle closure > } > } > class Animal { String name } > {code} > The following code would then fail to compile : > {code} > def farm = new Farm() > // compilation failure, no name property on Animal > farm.animal(nam: "Dog") { > } > {code} > It would then be down to IDEs to also provide support for code completion etc. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8403) Trait FieldHelper is not marked synthetic
Daniil Ovchinnikov created GROOVY-8403: -- Summary: Trait FieldHelper is not marked synthetic Key: GROOVY-8403 URL: https://issues.apache.org/jira/browse/GROOVY-8403 Project: Groovy Issue Type: Bug Components: Compiler Reporter: Daniil Ovchinnikov -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Created] (GROOVY-8602) Safe index doesn't work with map arguments
Daniil Ovchinnikov created GROOVY-8602: -- Summary: Safe index doesn't work with map arguments Key: GROOVY-8602 URL: https://issues.apache.org/jira/browse/GROOVY-8602 Project: Groovy Issue Type: Bug Affects Versions: 3.0.0-alpha-2 Reporter: Daniil Ovchinnikov {{a[b:2]}} works. {{a?[b:2]}} produces {{Unexpected input: ''; Expecting ':' @ ...}} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8650) New line between prefix operator and operand
Daniil Ovchinnikov created GROOVY-8650: -- Summary: New line between prefix operator and operand Key: GROOVY-8650 URL: https://issues.apache.org/jira/browse/GROOVY-8650 Project: Groovy Issue Type: Bug Components: parser Affects Versions: 3.0.0-alpha-2 Reporter: Daniil Ovchinnikov The following code is parsed properly in previous versions, but fails in 3.0: {code:java} def c = -- 1 println c // 0{code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8641) Cannot qualify path expression with soft keyword
Daniil Ovchinnikov created GROOVY-8641: -- Summary: Cannot qualify path expression with soft keyword Key: GROOVY-8641 URL: https://issues.apache.org/jira/browse/GROOVY-8641 Project: Groovy Issue Type: Bug Components: parser Affects Versions: 3.0.0-alpha-2 Reporter: Daniil Ovchinnikov {{in.foo}} (and others) in valid path expression in Groovy < 3.0. The following code is parsed and run properly in previous versions, but fails in 3.0: {code} def delegate = new Object() { def getProperty(String name) { println name return this } } delegate.with { in.foo // Unexpected input: 'delegate.with {\n in.foo\n' @ line 9, column 9. def.foo trait.foo as.foo } {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8642) New lines in qualified name cause errors
Daniil Ovchinnikov created GROOVY-8642: -- Summary: New lines in qualified name cause errors Key: GROOVY-8642 URL: https://issues.apache.org/jira/browse/GROOVY-8642 Project: Groovy Issue Type: Bug Components: parser Affects Versions: 3.0.0-alpha-2 Reporter: Daniil Ovchinnikov {code:java} import java. // Unexpected input: '\n'; Expecting '*' @ line 1, column 13. lang. Object {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8642) New lines in qualified name cause errors
[ https://issues.apache.org/jira/browse/GROOVY-8642?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8642: --- Description: The following code is parsed properly in previous versions, but fails in 3.0: {code:java} import java. // Unexpected input: '\n'; Expecting '*' @ line 1, column 13. lang. Object {code} was: {code:java} import java. // Unexpected input: '\n'; Expecting '*' @ line 1, column 13. lang. Object {code} > New lines in qualified name cause errors > > > Key: GROOVY-8642 > URL: https://issues.apache.org/jira/browse/GROOVY-8642 > Project: Groovy > Issue Type: Bug > Components: parser >Affects Versions: 3.0.0-alpha-2 >Reporter: Daniil Ovchinnikov >Priority: Major > > The following code is parsed properly in previous versions, but fails in 3.0: > {code:java} > import java. // Unexpected input: '\n'; Expecting '*' @ line 1, column 13. > lang. > Object > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8613) CCE in elvis assignment evaluation
Daniil Ovchinnikov created GROOVY-8613: -- Summary: CCE in elvis assignment evaluation Key: GROOVY-8613 URL: https://issues.apache.org/jira/browse/GROOVY-8613 Project: Groovy Issue Type: Bug Components: Static compilation, Static Type Checker Affects Versions: 3.0.0-alpha-2 Reporter: Daniil Ovchinnikov {code:java} @groovy.transform.CompileStatic def foo() { def a = 0 a ?= 1 println a // 1 def b = 0 b ?= "hello" println b // expected: "hello", actual: "GroovyCastException: Cannot cast 'String' to 'int'" } foo() {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8613) GCE in elvis assignment evaluation
[ https://issues.apache.org/jira/browse/GROOVY-8613?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8613: --- Summary: GCE in elvis assignment evaluation (was: CCE in elvis assignment evaluation) > GCE in elvis assignment evaluation > -- > > Key: GROOVY-8613 > URL: https://issues.apache.org/jira/browse/GROOVY-8613 > Project: Groovy > Issue Type: Bug > Components: Static compilation, Static Type Checker >Affects Versions: 3.0.0-alpha-2 >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code:java} > @groovy.transform.CompileStatic > def foo() { > def a = 0 > a ?= 1 > println a // 1 > def b = 0 > b ?= "hello" > println b // expected: "hello", actual: "GroovyCastException: Cannot cast > 'String' to 'int'" > } > foo() > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Updated] (GROOVY-8602) Safe index doesn't work with map arguments
[ https://issues.apache.org/jira/browse/GROOVY-8602?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8602: --- Priority: Critical (was: Major) > Safe index doesn't work with map arguments > -- > > Key: GROOVY-8602 > URL: https://issues.apache.org/jira/browse/GROOVY-8602 > Project: Groovy > Issue Type: Bug >Affects Versions: 3.0.0-alpha-2 >Reporter: Daniil Ovchinnikov >Priority: Critical > > {{a[b:2]}} works. > {{a?[b:2]}} produces {{Unexpected input: ''; Expecting ':' @ ...}} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8633) MME on Class receiver via method closure
Daniil Ovchinnikov created GROOVY-8633: -- Summary: MME on Class receiver via method closure Key: GROOVY-8633 URL: https://issues.apache.org/jira/browse/GROOVY-8633 Project: Groovy Issue Type: Bug Affects Versions: 2.5.0, 3.0.0-alpha-2 Reporter: Daniil Ovchinnikov {code} def c = Integer println c.toGenericString() // public final class java.lang.Integer def cl = c. println cl() // groovy.lang.MissingMethodException: No signature of method: java.lang.Integer.toGenericString() is applicable for argument types: () values: [] {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Created] (GROOVY-8361) Class is resolved via aliased static import
Daniil Ovchinnikov created GROOVY-8361: -- Summary: Class is resolved via aliased static import Key: GROOVY-8361 URL: https://issues.apache.org/jira/browse/GROOVY-8361 Project: Groovy Issue Type: Bug Reporter: Daniil Ovchinnikov Priority: Critical {code:title=unrelatedPackage/Container.groovy} package unrelatedPackage class Container { static class Target {} } {code} {code:title=bugs/bugs.groovy} package bugs import static unrelatedPackage.Container.Target as Unrelated println new Target() {code} {{Target}} reference is expected to be unresolved -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8361) Class is resolved via aliased static import
[ https://issues.apache.org/jira/browse/GROOVY-8361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8361: --- Description: {code:title=unrelatedPackage/Container.groovy} package unrelatedPackage class Container { static class Target {} } {code} {code:title=bugs/bugs.groovy} package bugs import static unrelatedPackage.Container.Target as Unrelated println new Target() // reference is expected to be unresolved {code} was: {code:title=unrelatedPackage/Container.groovy} package unrelatedPackage class Container { static class Target {} } {code} {code:title=bugs/bugs.groovy} package bugs import static unrelatedPackage.Container.Target as Unrelated println new Target() {code} {{Target}} reference is expected to be unresolved > Class is resolved via aliased static import > --- > > Key: GROOVY-8361 > URL: https://issues.apache.org/jira/browse/GROOVY-8361 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code:title=unrelatedPackage/Container.groovy} > package unrelatedPackage > class Container { > static class Target {} > } > {code} > {code:title=bugs/bugs.groovy} > package bugs > import static unrelatedPackage.Container.Target as Unrelated > println new Target() // reference is expected to be unresolved > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8358) Nested class resolution behaves differently depending on class order
[ https://issues.apache.org/jira/browse/GROOVY-8358?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8358: --- Summary: Nested class resolution behaves differently depending on class order (was: Inner class resolution behaves differently depending on class order) > Nested class resolution behaves differently depending on class order > > > Key: GROOVY-8358 > URL: https://issues.apache.org/jira/browse/GROOVY-8358 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code} > package bugs > class Outer implements OuterI { > static class Current extends CurrentParent { > static usage() { > new Target() > } > } > } > class CurrentParent implements CurrentParentI {} > interface CurrentParentI { > static class Target {} > } > interface OuterI { > static class Target {} > } > println Outer.Current.usage() // bugs.OuterI$Target@3eb7fc54 > {code} > If {{CurrentParent}} definition is moved before {{Outer}}, then {{new > Target}} will be resolved to {{bugs.CurrentParentI$Target}}: > {code} > package bugs > class CurrentParent implements CurrentParentI {} > class Outer implements OuterI { > class Current extends CurrentParent { > static usage() { > new Target() > } > } > } > interface CurrentParentI { > static class Target {} > } > interface OuterI { > static class Target {} > } > println Outer.Current.usage() // bugs.CurrentParentI$Target@3eb7fc54 > {code} > Moving classes must not affect results of compilation. -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8359) Nested class is not resolved if compiled separately
[ https://issues.apache.org/jira/browse/GROOVY-8359?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8359: --- Summary: Nested class is not resolved if compiled separately (was: Inner class is not resolved if compiled separately) > Nested class is not resolved if compiled separately > --- > > Key: GROOVY-8359 > URL: https://issues.apache.org/jira/browse/GROOVY-8359 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code:title=classes.groovy} > package bugs > class CurrentParent { > static class Target {} > } > {code} > {code:title=bug.groovy} > package bugs > class Current extends CurrentParent { > static usage() { > new Target() > } > } > {code} > This works if files are compiled together, but fails if files are compiled > one by one with {{Error:(5, 5) Groovyc: unable to resolve class Target}} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Updated] (GROOVY-8361) Nested class is resolved via aliased static import
[ https://issues.apache.org/jira/browse/GROOVY-8361?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniil Ovchinnikov updated GROOVY-8361: --- Summary: Nested class is resolved via aliased static import (was: Class is resolved via aliased static import) > Nested class is resolved via aliased static import > -- > > Key: GROOVY-8361 > URL: https://issues.apache.org/jira/browse/GROOVY-8361 > Project: Groovy > Issue Type: Bug >Reporter: Daniil Ovchinnikov >Priority: Critical > > {code:title=unrelatedPackage/Container.groovy} > package unrelatedPackage > class Container { > static class Target {} > } > {code} > {code:title=bugs/bugs.groovy} > package bugs > import static unrelatedPackage.Container.Target as Unrelated > println new Target() // reference is expected to be unresolved > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)