From dev-return-7236-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Tue Jan 19 18:30:12 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-he-de.apache.org (mxout1-he-de.apache.org [95.216.194.37]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id AD171180608 for ; Tue, 19 Jan 2021 19:30:12 +0100 (CET) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-he-de.apache.org (ASF Mail Server at mxout1-he-de.apache.org) with SMTP id BD22265042 for ; Tue, 19 Jan 2021 18:30:11 +0000 (UTC) Received: (qmail 82484 invoked by uid 500); 19 Jan 2021 18:29:57 -0000 Mailing-List: contact dev-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list dev@groovy.apache.org Received: (qmail 82263 invoked by uid 99); 19 Jan 2021 18:29:56 -0000 Received: from spamproc1-he-fi.apache.org (HELO spamproc1-he-fi.apache.org) (95.217.134.168) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 19 Jan 2021 18:29:56 +0000 Received: from localhost (localhost [127.0.0.1]) by spamproc1-he-fi.apache.org (ASF Mail Server at spamproc1-he-fi.apache.org) with ESMTP id 48DABC0115 for ; Tue, 19 Jan 2021 18:29:56 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamproc1-he-fi.apache.org X-Spam-Flag: NO X-Spam-Score: -2.402 X-Spam-Level: X-Spam-Status: No, score=-2.402 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, NICE_REPLY_A=-2.403, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamproc1-he-fi.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=gmx.net Received: from mx1-ec2-va.apache.org ([116.203.227.195]) by localhost (spamproc1-he-fi.apache.org [95.217.134.168]) (amavisd-new, port 10024) with ESMTP id l3CYEqQGDYzV for ; Tue, 19 Jan 2021 18:29:55 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=212.227.17.22; helo=mout.gmx.net; envelope-from=blackdrag@gmx.org; receiver= Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by mx1-ec2-va.apache.org (ASF Mail Server at mx1-ec2-va.apache.org) with ESMTPS id 07587BCC64 for ; Tue, 19 Jan 2021 18:29:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1611080988; bh=+5WvIWrgIYsSXVIgA/jjPqBjF+vf3khPLkFlX7nuzz0=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=G1JkBrTT3TAmvFDeU2OYDNwCNiP+U3YJjndmX/Ge490KUDsrcSSlECaBTmpIkDVTi EaYZn/fdUIlR21wpTHVQHwvN56dTVoInCy+ILRQ/y/uZIjOUUq0AiklASmFIU8orxm A1Jy8Mrl+GbJmO4D5GfMzje2SMCHFh5mf8IbGkK4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.1.104] ([212.25.6.111]) by mail.gmx.com (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MmlTC-1liNas1FtW-00jr5z for ; Tue, 19 Jan 2021 19:29:48 +0100 Subject: Re: Getting return type of generated Closure at runtime To: dev@groovy.apache.org References: <141cb555-b3ed-9bf0-5509-d632656f6467@seznam.cz> <77625d84-5fc8-f4c0-e76a-ceec5f7e446e@seznam.cz> <9877C975-33DE-44DC-81CD-FDE1CD02B96E@ocs.cz> <9bc59f21-49d4-2f90-c63f-8616792e9742@seznam.cz> From: Jochen Theodorou Message-ID: <0b598159-a425-5d59-72b7-7867ae690bae@gmx.org> Date: Tue, 19 Jan 2021 19:29:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <9bc59f21-49d4-2f90-c63f-8616792e9742@seznam.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:cIBNvE2PbT0AvJASvlUEJun5x7eANMZYh0PwOuR6Lf0UxTQ37Zt xOqSRDZeMfK0og6Lo3ztTAMldkxVkg0BuOxtsp6GFBPnM2CBcXkEvF1Fi1sQzh7uUMooSKS 6kgX4oBaYd+L2Jd2uzr938iixJBnqkgaA4WRgus6/mKyiEZqAq3Ct15hjI5Jy25Fn0t+T52 u8HUBt1oxLEBDT16xMyJw== X-UI-Out-Filterresults: notjunk:1;V03:K0:0bWy+qjUEn8=:STYFQYyHzhkiW5kFrttHEF ALvDwWZy7FU8MtCPFVbT4XXHpNHW5KynTN/Wu8D4a899um2nkZYKmFVjWTadw7NitHJVEiJ8a JYPYFS2LJOdEEvpXlB0IdeHbdmdhMaG62wvvo3Rv4JhoePTRjuoOXBXpmo2fquTt+q6OkaUC4 yh/bbwKK307YKTYubnc0EtroPk3ytSEa1rxru79DWlDh/dThj3sYluLjYcbV3a5j/ntkloWXp FO/BmOxspYtG5NXRU+OD58A7BmHYB6x/m1HfK8Ek970M67dmrz1TmQQ9yHYh4P/SkjGw3p0if AU2dzt8aQ2EAD/RhnxjYGetfGHDYv02/WkmE0b38DTMwxKtI3CFMD13/QzlYuBSSpOOd/S301 zsACphj0OvFUiWxFIh4kKzx8ZH0BDDhUtblTqmmcQwsZ4Scs7luMUAGsQ9GQvkh51JFfygnwI ns/sK4rDiOp581LSbdzBn1fbAD8EyU94idWtcfYQMvmqxP/SeW3/JYu9xg84ZI6o1RQ1RQl06 ynOKfmsSTpYSTeJU+qHf9VCkjQWqTIOqS3DdFZYQ2P0aXtqfCQVhDv2Jex/eVqLaPKHqzzeS6 qdAzWanbpDjxfAXZ/WvTv73xQSn2hHyEEWsgmcgS++sRtjJyGx9KTFp351lJCweD+HUSle+YR bVsNW9voxsX9UGN3AmG/zYp/sKLNM6be2CGWBWtJjY4Tv+C1Ss5kwuK3Uz5yNEPRfgj4fKLaB 6W5q2h/DTreReMmOD3XHN6kjZGqS8YzqDlX66QkHXJMoPs++kFks40yG7RDaZzGKCQyolvnk1 jUxmo4wPkGtVvOkg0XjuB5CHsnlx0+4Rb1EBmWrSdPl3cZYcNRCWIu6L8DuWf0oxiScKFbHCP /J+mp2mnO1p7u343Z54g== On 19.01.21 09:28, Jan Lukavsk=C3=BD wrote: > Hi OC, > > I'm pretty sure Closure has a return type, that is what the type > parametr V in Closure stands for. When source is compiled using at > least @TypeChecked, the return type (e.g. long as in the example I gave) > should be known and (I suppose) accessible during runtime somehow. There is a return type inferred by the static compiler for a Closure in Groovy. But the compiler is of course at compile time, not runtime. Though in case of >>>>> String script =3D "def a =3D { 1L }"; >>>>> Closure closure =3D (Closure) compile(script).run(); you could of course have access to the compiler. Basically you would progress the AST and then find the Closure node and get the inferred return type from it.. I am not 100% sure, but I think we do not store the type in the generics information, otherwise there would be another potential way bye Jochen