Skip to content

Commit

Permalink
Automated rollback of commit d3dd9d1.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

Breaks lots of tests with "method 'getattr' returns an object of invalid type SingletonSet" error; see b/123520324

*** Original change description ***

Convert MethodLibrary's SkylarkSignature methods to SkylarkCallable

Note that converted parameter @param annotations need legacyNamed = true (and in some places, noneable = True) to retain compatibility with the bugginess of SkylarkSignature.

This facilitates followup to clean up these methods / parameters -- given the refactor, we can enforce some of these parameters are positional-only (subject to an --incompatible flag)

Progress toward #5010

RELNOTES: None.
PiperOrigin-RevId: 231264758
  • Loading branch information
tetromino authored and Copybara-Service committed Jan 28, 2019
1 parent 2098474 commit 973c4e7
Show file tree
Hide file tree
Showing 16 changed files with 594 additions and 517 deletions.
10 changes: 0 additions & 10 deletions src/main/java/com/google/devtools/build/docgen/ApiExporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.devtools.build.lib.skylarkinterface.SkylarkInterfaceUtils;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.syntax.BaseFunction;
import com.google.devtools.build.lib.syntax.BuiltinCallable;
import com.google.devtools.build.lib.syntax.FuncallExpression;
import com.google.devtools.build.lib.syntax.FunctionSignature;
import com.google.devtools.build.lib.syntax.MethodDescriptor;
Expand Down Expand Up @@ -94,15 +93,6 @@ private static void appendGlobals(Builtins.Builder builtins, Map<String, Object>
Value.Builder value = Value.newBuilder();
if (obj instanceof BaseFunction) {
value = collectFunctionInfo((BaseFunction) obj);
} else if (obj instanceof BuiltinCallable) {
BuiltinCallable builtinCallable = (BuiltinCallable) obj;
MethodDescriptor descriptor =
builtinCallable.getMethodDescriptor(SkylarkSemantics.DEFAULT_SEMANTICS);
value =
collectFunctionInfo(
descriptor.getName(),
SkylarkSignatureProcessor.getSignatureForCallable(
descriptor.getName(), descriptor, null, null));
} else {
value.setName(entry.getKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ public Object call(
FuncallExpression ast,
Environment env)
throws EvalException, InterruptedException {
MethodDescriptor methodDescriptor = getMethodDescriptor(env.getSemantics());
MethodDescriptor methodDescriptor =
FuncallExpression.getMethod(env.getSemantics(), obj.getClass(), methodName);

// TODO(cparsons): Profiling should be done at the MethodDescriptor level.
try (SilentCloseable c =
Expand All @@ -54,10 +55,6 @@ public Object call(
}
}

public MethodDescriptor getMethodDescriptor(SkylarkSemantics semantics) {
return FuncallExpression.getMethod(semantics, obj.getClass(), methodName);
}

@Override
public void repr(SkylarkPrinter printer) {
printer.append("<built-in function " + methodName + ">");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ private EvalException unexpectedKeywordArgumentException(
String.format(
"unexpected keyword%s %s",
unexpectedKeywords.size() > 1 ? "s" : "",
Joiner.on(", ").join(Iterables.transform(unexpectedKeywords, s -> "'" + s + "'"))),
Joiner.on(",").join(Iterables.transform(unexpectedKeywords, s -> "'" + s + "'"))),
method,
objClass);
}
Expand Down
Loading

0 comments on commit 973c4e7

Please sign in to comment.