[jira] [Created] (GROOVY-8244) SAM trait coercion with default parameters

2017-06-30 Thread Daniil Ovchinnikov (JIRA)
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

2017-06-30 Thread Daniil Ovchinnikov (JIRA)

 [ 
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

2017-06-30 Thread Daniil Ovchinnikov (JIRA)

[ 
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-8243) SAM trait middle coercion via middle interface

2017-06-30 Thread Daniil Ovchinnikov (JIRA)
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-8242) Javadoc for Newify is missing some attribute values

2017-06-30 Thread Eric Milles (JIRA)
Eric Milles created GROOVY-8242:
---

 Summary: Javadoc for Newify is missing some attribute values
 Key: GROOVY-8242
 URL: https://issues.apache.org/jira/browse/GROOVY-8242
 Project: Groovy
  Issue Type: Bug
Reporter: Eric Milles
Priority: Minor


I was looking at thw Newify AST transform.  Some of the Javadoc appears 
incorrect since the annotation requires a value.

{code}
 * or this ("Ruby-style"):
 * 
 * {@code @Newify} class MyTreeProcessor {  --  Is this supposed to be 
@Newify([Tree,Leaf])?
 * def myTree = Tree.new(Tree.new(Leaf.new("A"), Leaf.new("B")), 
Leaf.new("C"))
 * def process() { ... }
 * }
 * 
{code}

{code}
 * An example showing how to use the annotation at different levels:
 * 
 * {@code @Newify(auto=false, value=Foo)}
 * class Main {
 * {@code @Newify} // turn auto on for field  --  Is this supposed to be 
@Newify(BigInteger)?
 * def field1 = java.math.BigInteger.new(42)
 * def field2, field3, field4
 *
 * {@code @Newify(Bar)}
 * def process() {
 * field2 = Bar("my bar")
 * }
 *
 * {@code @Newify(Baz)}
 * Main() {
 * field3 = Foo("my foo")
 * field4 = Baz("my baz")
 * }
 * }
 * 
{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)


[jira] [Created] (GROOVY-8241) SAM parameter type inference for explicit parameter

2017-06-30 Thread Daniil Ovchinnikov (JIRA)
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)