Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 42575200B78 for ; Fri, 2 Sep 2016 20:52:43 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 40C38160AAE; Fri, 2 Sep 2016 18:52:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 61383160A8C for ; Fri, 2 Sep 2016 20:52:42 +0200 (CEST) Received: (qmail 24882 invoked by uid 500); 2 Sep 2016 18:52:41 -0000 Mailing-List: contact users-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@groovy.apache.org Delivered-To: mailing list users@groovy.apache.org Received: (qmail 24872 invoked by uid 99); 2 Sep 2016 18:52:41 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Sep 2016 18:52:41 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 20EE9C3138 for ; Fri, 2 Sep 2016 18:52:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.492 X-Spam-Level: ** X-Spam-Status: No, score=2.492 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001, URI_HEX=1.313] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx2-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 6PwLQCKab5h5 for ; Fri, 2 Sep 2016 18:52:39 +0000 (UTC) Received: from mail-oi0-f49.google.com (mail-oi0-f49.google.com [209.85.218.49]) by mx2-lw-eu.apache.org (ASF Mail Server at mx2-lw-eu.apache.org) with ESMTPS id 646875F3F3 for ; Fri, 2 Sep 2016 18:52:38 +0000 (UTC) Received: by mail-oi0-f49.google.com with SMTP id m11so48166876oif.1 for ; Fri, 02 Sep 2016 11:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=4ZFb01p9Ies2tCFTL0vaayxbAgC2k9FXurMVKEcisQM=; b=k7ANzDJDiZCxizb/Vpd+Qva7JzOqwBHHVN+GyADP+zzyw46ACccY79/d4ph2Ki52KC 3Hhdspn99hsUiZygnrIMWA7tqEA26jWev8mV3EH/Vf1NhS1r4P11sryBRPeymz/ulbf6 bL/pfrWkvF52dakXho4m1sOlXk7zhpzvHCuWB/rpBgJJl2XQFRDy38VCzXW+OQp8p9nG kBw22uX8UAEm3eIKofQec89aYAJdNp2wSWqdrsfAPdTyMeX4Lz2HtxnKoqXua9C7BEMC 77y1qKbbwanpscoLECErew6F19J9p44rkhtNK4fk/oHYNOUXFLc18tXbHFWkD04xDFaT 9oPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=4ZFb01p9Ies2tCFTL0vaayxbAgC2k9FXurMVKEcisQM=; b=hX6dsIkHHdSdKVxnBCFrVYOc0XCpu1b5anR0sKogIoWN/ZCFpjz6W44/BxrSWDr5rZ 2oOwjsqaKVQ6yUVz6TlogRfR+HrHK3FQbY97eWikpZGrqmeAC0iyIzoVXKF4vppG/f2k U85uYOgEAYtIT/8WUbltqotY1UsYaaaOcHPAbSdYKICHJdRip/SoPQw1U1n7KKTfn1Zv o63Xw4wN2VDI5BKJlEJFWVvy4QDFT259m3lCzXXZNVDFu/O1pZ8aHm76kYVYI46baX9E GWYV/1FOVe9PSqFxr5Y5mKie6xDUQ0bTKQQqyseXOt/srvYFJ+al7IyEwRBDMyi1C+bc EXGQ== X-Gm-Message-State: AE9vXwO8K60k3Kj2j2tYH4GFKAfb/GlSkcvFpibRymULC3VpTL4tvWMtXPy7N1L+f9YgmNUsMPB/f2czcWmiUQ== X-Received: by 10.202.252.135 with SMTP id a129mr21235903oii.4.1472842357030; Fri, 02 Sep 2016 11:52:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.58.136 with HTTP; Fri, 2 Sep 2016 11:52:36 -0700 (PDT) In-Reply-To: <1472821533660-5735162.post@n5.nabble.com> References: <1472821533660-5735162.post@n5.nabble.com> From: =?UTF-8?Q?C=C3=A9dric_Champeau?= Date: Fri, 2 Sep 2016 20:52:36 +0200 Message-ID: Subject: Re: Static type checking To: users@groovy.apache.org Content-Type: multipart/alternative; boundary=001a113df280804364053b8ad57c archived-at: Fri, 02 Sep 2016 18:52:43 -0000 --001a113df280804364053b8ad57c Content-Type: text/plain; charset=UTF-8 This is clearly a bug. Can you file a JIRA issue for this? 2016-09-02 15:05 GMT+02:00 cazacugmihai : > Hi, > > I have a problem running this code: > > import groovy.transform.CompileStatic > import java.util.function.Function > > @CompileStatic > class Test { > static void main(String[] args) { > // this code fails > Function fct = { Integer n -> > -n > } > > // this one works but it is too verbose > // Function fct = ({ Integer n -> > // -n > // } as Function) > > println fct.apply(10) > } > } > > The error: > > Test.groovy: 9: [Static type checking] - Incompatible generic argument > types. Cannot assign java.util.function.Function groovy.lang.Closure> to: java.util.function.Function > @ line 9, column 36. > Function fct = { Integer n -> > ^ > 1 error > > [Finished in 0.5s] > > Is there a bug in groovy related to @CompileStatic or maybe I am missing > something else? I just don't want to write redundant code. > > Thanks, > Mihai > > > > -- > View this message in context: http://groovy.329449.n5. > nabble.com/Static-type-checking-tp5735162.html > Sent from the Groovy Users mailing list archive at Nabble.com. > --001a113df280804364053b8ad57c Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
This is clearly a bug. Can you file a JIRA issue for this?=

2016-09-02 = 15:05 GMT+02:00 cazacugmihai <cazacugmihai@gmail.com>:<= br>
Hi,

I have a problem running this code:

import groovy.transform.CompileStatic
import java.util.function.Function

@CompileStatic
class Test {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 static void main(String[] args) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0// this code fails =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Function<Integer= , Integer> fct =3D { Integer n ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 -n
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // this one works b= ut it is too verbose
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // Function<Inte= ger, Integer> fct =3D ({ Integer n ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 //=C2=A0 =C2=A0 =C2= =A0 -n
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 // } as Function<= ;Integer, Integer>)

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 println fct.apply(1= 0)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 }
}

The error:

Test.groovy: 9: [Static type checking] - Incompatible generic argument
types. Cannot assign java.util.function.Function <java.lang.Integer,
groovy.lang.Closure> to: java.util.function.Function <Integer, Intege= r>
=C2=A0@ line 9, column 36.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Function<Integer= , Integer> fct =3D { Integer n ->
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^
1 error

[Finished in 0.5s]

Is there a bug in groovy related to @CompileStatic or maybe I am missing something else? I just don't want to write redundant code.

Thanks,
Mihai



--
View this message in context: = http://groovy.329449.n5.nabble.com/Static-type-checking-tp5735162= .html
Sent from the Groovy Users mailing list archive at Nabble.com.

--001a113df280804364053b8ad57c--