diff options
author | cparsons <cparsons@google.com> | 2018-05-01 10:32:30 -0700 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-05-01 10:33:46 -0700 |
commit | 2415cb4ab69ec05d2e7ba15c75a20e2d2da2fc90 (patch) | |
tree | 33a8c5810973f58ff8c084b14078be87cc2bf5ad /src/main/java/com/google/devtools/build/lib/skylarkinterface | |
parent | 2e4f703d361823fa12df9ddb57f21189743b2c74 (diff) |
Use a new pattern for builtin Provider objects with @SkylarkCallable.
This deprecates the old NativeProvider pattern.
The new pattern is demonstrated using AppleStaticLibraryInfo.
RELNOTES: None.
PiperOrigin-RevId: 194956883
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/skylarkinterface')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java index 3ee297993a..7788b478d8 100644 --- a/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java +++ b/src/main/java/com/google/devtools/build/lib/skylarkinterface/SkylarkInterfaceUtils.java @@ -95,15 +95,16 @@ public class SkylarkInterfaceUtils { * Returns the {@link SkylarkCallable} annotation for the given method, if it exists, and * null otherwise. The first annotation of an overridden version of the method that is found * will be returned, starting with {@code classObj} and following its base classes and - * interfaces recursively, skipping any annotation inside a class not marked + * interfaces recursively. This skips any method annotated inside a class that is not + * marked {@link SkylarkModule} or is not a subclass of a class or interface marked * {@link SkylarkModule}. */ @Nullable public static SkylarkCallable getSkylarkCallable(Class<?> classObj, Method method) { try { Method superMethod = classObj.getMethod(method.getName(), method.getParameterTypes()); - boolean classAnnotatedForCallables = classObj.isAnnotationPresent(SkylarkModule.class) - || classObj.isAnnotationPresent(SkylarkGlobalLibrary.class); + boolean classAnnotatedForCallables = getParentWithSkylarkModule(classObj) != null + || hasSkylarkGlobalLibrary(classObj); if (classAnnotatedForCallables && superMethod.isAnnotationPresent(SkylarkCallable.class)) { return superMethod.getAnnotation(SkylarkCallable.class); |