From notifications-return-13529-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Thu Aug 9 14:21:03 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3146618065B for ; Thu, 9 Aug 2018 14:21:03 +0200 (CEST) Received: (qmail 22003 invoked by uid 500); 9 Aug 2018 12:21:02 -0000 Mailing-List: contact notifications-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 notifications@groovy.apache.org Received: (qmail 21994 invoked by uid 99); 9 Aug 2018 12:21:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Aug 2018 12:21:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id D3B34180518 for ; Thu, 9 Aug 2018 12:21:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.301 X-Spam-Level: X-Spam-Status: No, score=-110.301 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id B-M4vshWFejo for ; Thu, 9 Aug 2018 12:21:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id E31465F20B for ; Thu, 9 Aug 2018 12:21:00 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 777A3E0047 for ; Thu, 9 Aug 2018 12:21:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 322FC23F9A for ; Thu, 9 Aug 2018 12:21:00 +0000 (UTC) Date: Thu, 9 Aug 2018 12:21:00 +0000 (UTC) From: "Paul King (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-8732) @CompileStatic refers to private field in parent class MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GROOVY-8732?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D165= 74756#comment-16574756 ]=20 Paul King commented on GROOVY-8732: ----------------------------------- After the above PR the bytecode for your example becomes: {code} ALOAD 0 CHECKCAST Child INVOKEVIRTUAL Child.getThing ()LThing; INVOKEINTERFACE Thing.call ()V (itf) ACONST_NULL POP RETURN {code} > @CompileStatic refers to private field in parent class > ------------------------------------------------------ > > Key: GROOVY-8732 > URL: https://issues.apache.org/jira/browse/GROOVY-8732 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.4.15, 2.6.0-alpha-4, 3.0.0-alpha-3, 2.5.1 > Reporter: L=C3=B3r=C3=A1nt Pint=C3=A9r > Priority: Major > > {code} > import groovy.transform.CompileStatic > @CompileStatic > interface Thing { > void call() > } > @CompileStatic > class ThingImpl implements Thing { > void call() {} > } > @CompileStatic > class Parent { > private final ThingImpl thing > public Thing getThing() { null } > } > @CompileStatic > class Child extends Parent { > public void doSomething() { > thing.call() > } > } > {code} > Compile via: {{groovyc Example.groovy}}. > The line {{thing.call}} in {{Child.doSomething()}} calls {{getThing()}}, = but then ends up referring to the returned value according to the private f= ield's type from {{Parent}} ({{ThingImpl}}) instead of the actual returned = type ({{Thing}}). The private field from {{Parent}} (or its type) should no= t be visible to {{Child}} at all. > {code} > public void doSomething(); > descriptor: ()V > flags: (0x0001) ACC_PUBLIC > Code: > stack=3D1, locals=3D1, args_size=3D1 > 0: aload_0 > 1: invokevirtual #20 // Method Parent.getThing:(= )LThing; > 4: checkcast #22 // class ThingImpl > 7: invokevirtual #25 // Method ThingImpl.call:()= V > 10: aconst_null > 11: pop > 12: return > {code} > This is causing now problems for Gradle plugins compiled against Grade 4.= 9 or before trying to run on Gradle 4.9, because we've made a change to an = internal type (`ProjectInternal`) that ended up being referred to via this = bug in compiled and released code. See https://github.com/gradle/gradle/iss= ues/6027 -- This message was sent by Atlassian JIRA (v7.6.3#76005)