Skip to content
Permalink
Browse files
GROOVY-10290: Dynamic Groovy code in Gradle doesn't compile because o…
…f $getLookup() method is not static
  • Loading branch information
paulk-asert committed Feb 16, 2022
1 parent 42410f0 commit 02ebb321c6578a8268e5d7096455b1cb916e9068
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
@@ -707,7 +707,7 @@ private static ClassNode getConstructorArgumentType(final Expression arg, final
private void printMethod(PrintWriter out, ClassNode clazz, MethodNode methodNode) {
if (methodNode.isStaticConstructor()) return;
if (methodNode.isPrivate() || !Utilities.isJavaIdentifier(methodNode.getName())) return;
if (methodNode.isSynthetic() && methodNode.getName().equals("$getStaticMetaClass")) return;
if (methodNode.isSynthetic() && (methodNode.getName().equals("$getStaticMetaClass") || methodNode.getName().equals("$getLookup"))) return;

printAnnotations(out, methodNode);
if (!isInterfaceOrTrait(clazz)) {
@@ -0,0 +1,46 @@
/*
* 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 org.codehaus.groovy.tools.stubgenerator

final class Groovy10290 extends StringSourcesStubTestCase {

@Override
Map<String, String> provideSources() {
[
'ResettableExpectations.java': '''
public interface ResettableExpectations { }
''',
'SFTPServer.groovy': '''
class SFTPServer implements ResettableExpectations {
static interface SftpExpectation { }
@groovy.transform.CompileStatic
static class SftpExpectOne implements SftpExpectation { }
static class SftpExpectOnePath extends SftpExpectOne { }
class SftpExpectOneOpen extends SftpExpectOnePath { }
}
'''
]
}

@Override
void verifyStubs() {
String stub = stubJavaSourceFor('SFTPServer')
assert !stub.contains('$getLookup')
}
}

0 comments on commit 02ebb32

Please sign in to comment.