Return-Path: X-Original-To: apmail-groovy-notifications-archive@minotaur.apache.org Delivered-To: apmail-groovy-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B8E0619B73 for ; Mon, 4 Apr 2016 00:57:25 +0000 (UTC) Received: (qmail 87628 invoked by uid 500); 4 Apr 2016 00:57:25 -0000 Delivered-To: apmail-groovy-notifications-archive@groovy.apache.org Received: (qmail 87601 invoked by uid 500); 4 Apr 2016 00:57:25 -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 87582 invoked by uid 99); 4 Apr 2016 00:57:25 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Apr 2016 00:57:25 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 79DC82C14F6 for ; Mon, 4 Apr 2016 00:57:25 +0000 (UTC) Date: Mon, 4 Apr 2016 00:57:25 +0000 (UTC) From: "John Wagenleitner (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-3948) Replacing method on ExpandoMetaClass doesn't work MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/GROOVY-3948?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15223579#comment-15223579 ] John Wagenleitner commented on GROOVY-3948: ------------------------------------------- Added a test to try to prevent future regression: https://github.com/apache/groovy/commit/c04e4df42ca3ed25570acc730d87807012c39887 > Replacing method on ExpandoMetaClass doesn't work > ------------------------------------------------- > > Key: GROOVY-3948 > URL: https://issues.apache.org/jira/browse/GROOVY-3948 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime > Affects Versions: 1.6.7 > Environment: Groovy Shell (1.6.7, JVM: 1.5.0_20) > Reporter: Lajos Papp > Fix For: 2.2.0 > > > {code} > Expando.metaClass.foo={-> def directBar=delegate.bar() > println "directBar=${directBar}" > def invokedBar=delegate.invokeMethod('bar',null) > println "invokedBar=$invokedBar" > } > e=new Expando() > e.metaClass.bar={->1} > e.foo() > //directBar=1 > //invokedBar=1 > e.metaClass.bar={->2} > e.foo() > //directBar=1 > //invokedBar=2 > {code} > for some reason delegate.bar() != delegate.invokeMethod('bar',null) > looks like at the direct call the closure got cached ... > if the previous example continues with: > {code} > x=new Expando() > x.metaClass.bar={->3} > e.foo() > //directBar=2 > //invokedBar=2 > {code} > creating the new 'x' object has side effect on the 'e' objects metaclass? -- This message was sent by Atlassian JIRA (v6.3.4#6332)