[jira] [Comment Edited] (GROOVY-7859) Erroneous method pointer expressions pass STC
[ https://issues.apache.org/jira/browse/GROOVY-7859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17643037#comment-17643037 ] Eric Milles edited comment on GROOVY-7859 at 12/4/22 4:23 PM: -- For pointer or reference, the following is current behavior: {code:groovy} @groovy.transform.TypeChecked void test7859() { def x = 'abc'. // STC: Cannot find matching method java.lang.String#bar x = String. // instance method closure that requires String as first argument x = String. // instance extension method closure that requires String as first argument } {code} was (Author: emilles): For pointer or reference, the following is current behavior: {code:groovy} @groovy.transform.CompileStatic void test7859() { def x = 'abc'. // STC: Cannot find matching method java.lang.String#bar x = String. // instance method closure that requires String as first argument x = String. // instance extension method closure that requires String as first argument } {code} > Erroneous method pointer expressions pass STC > - > > Key: GROOVY-7859 > URL: https://issues.apache.org/jira/browse/GROOVY-7859 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Affects Versions: 2.4.7 >Reporter: Shil Sinha >Assignee: Shil Sinha >Priority: Major > Fix For: 3.0.14, 4.0.7 > > > Method pointer expressions are not type checked (with STC enabled). The > following example should not compile for a number of reasons: > {code} > @groovy.transform.TypeChecked > void test() { > def x = 'abc'. //bar is not a String method > x() // groovy.lang.MissingMethodException > x = String. //length is a non-static method > x() // java.lang.IllegalArgumentException: object is not an instance of > declaring class > x = String. //size is a non-static extension method > x() // java.lang.ClassCastException: java.lang.Class cannot be cast to > java.lang.String > } > test() > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (GROOVY-7859) Erroneous method pointer expressions pass STC
[ https://issues.apache.org/jira/browse/GROOVY-7859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16204662#comment-16204662 ] Eric Milles edited comment on GROOVY-7859 at 10/14/17 3:19 PM: --- I also found that {{String.}} (for example) is not usable. {code} assert ['ABC','XYZ'].collect(String.) == ['abc','xyz'] groovy.lang.MissingMethodException: No signature of method: java.lang.String.toLowerCase() is applicable for argument types: (java.lang.String) values: [ABC] Possible solutions: toLowerCase(), toLowerCase(java.util.Locale), toUpperCase(), toUpperCase(java.util.Locale) at Script1.run(Script1.groovy:1) {code} Should I file a separate bug report for this? was (Author: emilles): I also found that {{String.}} (for example) is not usable. It results in: {code} assert ['ABC','XYZ'].collect(String.) == ['abc','xyz'] groovy.lang.MissingMethodException: No signature of method: java.lang.String.toLowerCase() is applicable for argument types: (java.lang.String) values: [ABC] Possible solutions: toLowerCase(), toLowerCase(java.util.Locale), toUpperCase(), toUpperCase(java.util.Locale) at Script1.run(Script1.groovy:1) {code} Should I file a separate bug report for this? > Erroneous method pointer expressions pass STC > - > > Key: GROOVY-7859 > URL: https://issues.apache.org/jira/browse/GROOVY-7859 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Affects Versions: 2.4.7 >Reporter: Shil Sinha >Assignee: Shil Sinha > > Method pointer expressions are not type checked (with STC enabled). The > following example should not compile for a number of reasons: > {code} > @groovy.transform.TypeChecked > void test() { > def x = 'abc'. //bar is not a String method > x() // groovy.lang.MissingMethodException > x = String. //length is a non-static method > x() // java.lang.IllegalArgumentException: object is not an instance of > declaring class > x = String. //size is a non-static extension method > x() // java.lang.ClassCastException: java.lang.Class cannot be cast to > java.lang.String > } > test() > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)
[jira] [Comment Edited] (GROOVY-7859) Erroneous method pointer expressions pass STC
[ https://issues.apache.org/jira/browse/GROOVY-7859?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16165804#comment-16165804 ] Paul King edited comment on GROOVY-7859 at 9/14/17 6:20 AM: The corresponding method reference equivalents using the Parrot parser suffer from the same errors: {code} x = 'abc'::bar x = String::length x = String::size {code} This is to be expected given the current implementation. was (Author: paulk): The corresponding method reference equivalent using the Parrot parser suffer from the same errors: {code} x = 'abc'::bar x = String::length x = String::size {code} This is to be expected given the current implementation. > Erroneous method pointer expressions pass STC > - > > Key: GROOVY-7859 > URL: https://issues.apache.org/jira/browse/GROOVY-7859 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker >Affects Versions: 2.4.7 >Reporter: Shil Sinha >Assignee: Shil Sinha > > Method pointer expressions are not type checked (with STC enabled). The > following example should not compile for a number of reasons: > {code} > @groovy.transform.TypeChecked > void test() { > def x = 'abc'. //bar is not a String method > x() // groovy.lang.MissingMethodException > x = String. //length is a non-static method > x() // java.lang.IllegalArgumentException: object is not an instance of > declaring class > x = String. //size is a non-static extension method > x() // java.lang.ClassCastException: java.lang.Class cannot be cast to > java.lang.String > } > test() > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029)