commit | 7f266408e95c50af158df1108fe6bffc3030eec7 | [log] [tgz] |
---|---|---|
author | adonovan <adonovan@google.com> | Mon Apr 20 10:15:47 2020 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Mon Apr 20 10:17:08 2020 -0700 |
tree | dd9d35cd3861175d77f939438d05fa8e5ed8747b | |
parent | 8a312b666b098c43a99a8ee628cc64809ab3dec4 [diff] |
bazel syntax: hide BaseFunction and matchSignature commit c568d844b6c73160273e60096fa9507d6755acde replaced most uses of BaseFunction with StarlarkCallable, which abstracts all function-like values. This change removes BaseFunction from the API, and a follow-up will merge it into its sole remaining subclass, StarlarkFunction. Most of the classes that implemented BaseFunction did so only for its trivial toString, repr, and isImmutable methods, which have been copied as needed, and in some cases tweaked. SkylarkProvider formerly used BaseFunction and matchSignature to match arguments to schema fields, but provider instantiation can be done more efficiently by permuting the argument array directly, without allocating any hash tables or indeed any additional memory at all. Thanks to Murali Ganapathy for the algorithm. This also unifies the schemaful and schemaless cases. This sets the stage for removing FunctionSignature from the API. Its only remaining uses are in the doc tools. --- Also, this CL causes ParamDescriptor to no longer use SkylarkType internally to validate arguments and to describe types for error messages. Parameter types are now represented as a union of Class symbols. Validation uses instanceof. Error messages are produced using getDataTypeNameFromClass. The reason this change is bundled in this CL is that SkylarkType.of (a conceptual mess) uses fragile heuristics to decide whether a value is a "function" based on whether it implements BaseFunction; this breaks when changed to use StarlarkCallable. Type errors in the function call machinery now report only what they test, that is, the top-level constructor: "want list", not "want list of strings". The old messages were a bit of a lie because the call would happily accept lists of other types unless the function implementation performed an explicit element type check. Such checks continue to produce detailed errors: "got list of X, want list of Y". The 'generic1' annotation no longer affects the interpreter; it is purely for documentation. The only remaining use of SkylarkType is for Depsets. A follow-up change will make the necessary renamings and simplifications. PiperOrigin-RevId: 307424087
{Fast, Correct} - Choose two
Build and test software of any size, quickly and reliably.
Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.
One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.
Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.
Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.
Follow our tutorials:
See CONTRIBUTING.md