From 433eaf8c62f809d531bb9984b126252172f8287c Mon Sep 17 00:00:00 2001 From: John Wagenleitner Date: Sun, 2 Apr 2017 08:34:47 -0700 Subject: [PATCH] GROOVY-8140: Invoke method not returning MOP super method if isCallToSuper --- src/main/groovy/lang/MetaClassImpl.java | 5 --- src/test/groovy/bugs/Groovy8140Bug.groovy | 48 +++++++++++++++++++++++ 2 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 src/test/groovy/bugs/Groovy8140Bug.groovy diff --git a/src/main/groovy/lang/MetaClassImpl.java b/src/main/groovy/lang/MetaClassImpl.java index 93c013b86ef..a059a4fea5b 100644 --- a/src/main/groovy/lang/MetaClassImpl.java +++ b/src/main/groovy/lang/MetaClassImpl.java @@ -492,11 +492,6 @@ private void replaceWithMOPCalls(final CachedMethod[] mopMethods) { class MOPIter extends MethodIndexAction { boolean useThis; - @Override - public boolean skipClass(Class clazz) { - return !useThis && clazz == theClass; - } - @Override public void methodNameAction(Class clazz, MetaMethodIndex.Entry e) { if (useThis) { diff --git a/src/test/groovy/bugs/Groovy8140Bug.groovy b/src/test/groovy/bugs/Groovy8140Bug.groovy new file mode 100644 index 00000000000..4de5c883d46 --- /dev/null +++ b/src/test/groovy/bugs/Groovy8140Bug.groovy @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.bugs + + +class Groovy8140Bug extends GroovyTestCase { + + void testGetMethodCallToSuperReturnsMOPSuperMethod() { + assertScript ''' + import org.codehaus.groovy.runtime.InvokerHelper + + class A { + @Override + public String toString() { + return "base" + } + } + + class B extends A { + @Override + public String toString() { + return "x" + super.toString() + } + } + + MetaClass mc = InvokerHelper.getMetaClass(B.class) + def method = mc.getMethodWithCaching(B.class, "toString", null, true) + assert method.getName() ==~ /super[$]\\d+[$]toString/ + ''' + } + +}