aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/syntax/DotExpression.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/syntax/DotExpression.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/DotExpression.java42
1 files changed, 26 insertions, 16 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/DotExpression.java b/src/main/java/com/google/devtools/build/lib/syntax/DotExpression.java
index ed45d6079f..b41f274c37 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/DotExpression.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/DotExpression.java
@@ -118,6 +118,32 @@ public final class DotExpression extends Expression {
*/
public static Object eval(Object objValue, String name,
Location loc, Environment env) throws EvalException, InterruptedException {
+
+ Iterable<MethodDescriptor> methods =
+ objValue instanceof Class<?>
+ ? FuncallExpression.getMethods((Class<?>) objValue, name)
+ : FuncallExpression.getMethods(objValue.getClass(), name);
+
+ if (methods != null) {
+ Optional<MethodDescriptor> method =
+ Streams.stream(methods)
+ .filter(methodDescriptor -> methodDescriptor.getAnnotation().structField())
+ .findFirst();
+ if (method.isPresent() && method.get().getAnnotation().structField()) {
+ return FuncallExpression.callMethod(
+ method.get(),
+ name,
+ objValue,
+ FuncallExpression.extraInterpreterArgs(
+ method.get().getAnnotation(),
+ /* ast = */ null,
+ loc,
+ env).toArray(),
+ loc,
+ env);
+ }
+ }
+
if (objValue instanceof SkylarkClassObject) {
try {
return ((SkylarkClassObject) objValue).getValue(name);
@@ -142,22 +168,6 @@ public final class DotExpression extends Expression {
}
}
- Iterable<MethodDescriptor> methods =
- objValue instanceof Class<?>
- ? FuncallExpression.getMethods((Class<?>) objValue, name)
- : FuncallExpression.getMethods(objValue.getClass(), name);
-
- if (methods != null) {
- Optional<MethodDescriptor> method =
- Streams.stream(methods)
- .filter(methodDescriptor -> methodDescriptor.getAnnotation().structField())
- .findFirst();
- if (method.isPresent() && method.get().getAnnotation().structField()) {
- return FuncallExpression.callMethod(
- method.get(), name, objValue, new Object[] {}, loc, env);
- }
- }
-
return null;
}