commit | 858039031b3fcfb58ab589e06b1e6db493a9e740 | [log] [tgz] |
---|---|---|
author | adonovan <adonovan@google.com> | Thu Apr 16 14:46:57 2020 -0700 |
committer | Copybara-Service <copybara-worker@google.com> | Thu Apr 16 14:48:51 2020 -0700 |
tree | aaeca8f6ec66f8ec0c782098b1e9451ad2fc216e | |
parent | f0ccbe78507f6ca54343622f1794396fc1e66b95 [diff] |
bazel syntax: rationalize the type check operators This change introduces {Dict,Sequence}.{,noneable}Cast. These four conversion operators cast an arbitrary value to a Sequence<T> or Dict<K,V>, replacing these 9 previous functions: - Dict.{castSkylarkDictOrNoneToDict,getContents} - Sequence.{castList,castSkylarkListOrNoneToList,getContents} - SkylarkType.{cast,cast',checkType,castMap} The functions don't allocate an unmodifiable wrapper, as Dict and List are already unmodifiable through the java.util interfaces, so this is just wasteful allocation and indirection. Also, there is no a priori allocation of Formattable error messages. A number of messes (e.g. unsound casts) were cleaned up throughout. The new operators do not accept a Location, and report error using Starlark.errorf. (This whole CL started as a subtask of a subtask to eliminate the Location parameter of EvalException, and this sub-sub-task is an experiment to see whether removing Location parameters that don't correspond to program counter locations is a UI regression. SRCTU.createTarget is the only place where this appears to be a problem. For now I've added a small kludge, but in a follow-up I will change it to report events, not throw exceptions, so that it can report multiple errors at arbitrary locations. Depset might benefit from a similar {noneable,}Cast treatment, but this too is left for a follow-up. This is a breaking API change for copybara. RELNOTES: N/A PiperOrigin-RevId: 306925434
{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