-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.1.0] Add set data type to Starlark (#25111)
Cherry-pick of the following 2 commits: 1. Add set data type to Starlark Experimental feature guarded by --experimental_enable_starlark_set. This is the Bazel implementation of bazelbuild/starlark#264 Replicates the Python 3 set API and (in almost all respects) the starlark-go implementation, with the notable exception of explicitly not supporting (partial) ordering of sets. Note that there are no set-valued attributes (nor plans to add any), and set-valued select() expressions are not supported. RELNOTES: Add a set data type to Starlark, guarded by the --experimental_enable_starlark_set flag. PiperOrigin-RevId: 695886977 Change-Id: Id1e178bd3dd354619f188c4375d8a1256bd55f75 Cherry-picked from c5e08d4 2. Enable Starlark sets by default Now that the Starlark language spec has been approved: https://github.com/bazelbuild/starlark/blob/master/spec.md#sets Require elements of arguments to StarlarkSet methods to be hashable, matching the final version of the language spec. Take the opportunity to update our documentation to match the spec whenever reasonable (modulo minor differences in terminology and formatting). RELNOTES: Flip --experimental_enable_starlark_set and enable the Starlark set data type by default. PiperOrigin-RevId: 707659085 Change-Id: Ibcad59838f9709e980d7b69f4957b8f0fede51c6 Cherry-picked from 8ae2570
- Loading branch information
Showing
11 changed files
with
1,338 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/java/net/starlark/java/eval/StarlarkMembershipTestable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2024 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package net.starlark.java.eval; | ||
|
||
/** | ||
* A Starlark value that support membership tests ({@code key in object} and {@code key not in | ||
* object}). | ||
*/ | ||
public interface StarlarkMembershipTestable extends StarlarkValue { | ||
/** Returns whether the key is in the object. */ | ||
boolean containsKey(StarlarkSemantics semantics, Object key) throws EvalException; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.