Skip to content

Commit

Permalink
Delete flag incompatible_disallow_hashing_frozen_mutables
Browse files Browse the repository at this point in the history
#7800

RELNOTES: None.
PiperOrigin-RevId: 278886996
  • Loading branch information
laurentlb authored and copybara-github committed Nov 6, 2019
1 parent 9331632 commit 5f713b3
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,18 +343,6 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl
help = "If set to true, the default value of the `allow_empty` argument of glob() is False.")
public boolean incompatibleDisallowEmptyGlob;

@Option(
name = "incompatible_disallow_hashing_frozen_mutables",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help = "If set to true, freezing a mutable object will not make it hashable.")
public boolean incompatibleDisallowHashingFrozenMutables;

@Option(
name = "incompatible_disallow_legacy_javainfo",
defaultValue = "true",
Expand Down Expand Up @@ -741,7 +729,6 @@ public StarlarkSemantics toSkylarkSemantics() {
.incompatibleRestrictStringEscapes(incompatibleRestrictStringEscapes)
.incompatibleDisallowDictLookupUnhashableKeys(
incompatibleDisallowDictLookupUnhashableKeys)
.incompatibleDisallowHashingFrozenMutables(incompatibleDisallowHashingFrozenMutables)
.build();
return INTERNER.intern(semantics);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ public int compare(Object o1, Object o2) {
*/
public static void checkValidDictKey(Object o, StarlarkThread thread) throws EvalException {
// TODO(bazel-team): check that all recursive elements are both Immutable AND Comparable.
if (thread != null && thread.getSemantics().incompatibleDisallowHashingFrozenMutables()) {
if (isHashable(o)) {
return;
}
} else if (isImmutable(o)) {
if (isHashable(o)) {
return;
}
// Same error message as Python (that makes it a TypeError).
Expand All @@ -149,11 +145,11 @@ public static boolean isHashable(Object o) {

/**
* Is this object known or assumed to be recursively immutable by Skylark?
*
* @param o an Object
* @return true if the object is known to be an immutable value.
*/
// NB: This is used as the basis for accepting objects in SkylarkNestedSet-s,
// as well as for accepting objects as keys for Skylark dict-s.
// NB: This is used as the basis for accepting objects in SkylarkNestedSet-s.
public static boolean isImmutable(Object o) {
if (o instanceof SkylarkValue) {
return ((SkylarkValue) o).isImmutable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,6 @@ public boolean flagValue(FlagIdentifier flagIdentifier) {

public abstract boolean experimentalAllowTagsPropagation();

public abstract boolean incompatibleDisallowHashingFrozenMutables();

@Memoized
@Override
public abstract int hashCode();
Expand Down Expand Up @@ -300,7 +298,6 @@ public static Builder builderWithDefaults() {
.incompatibleDepsetForLibrariesToLinkGetter(true)
.incompatibleRestrictStringEscapes(false)
.incompatibleDisallowDictLookupUnhashableKeys(false)
.incompatibleDisallowHashingFrozenMutables(true)
.build();

/** Builder for {@link StarlarkSemantics}. All fields are mandatory. */
Expand Down Expand Up @@ -399,8 +396,6 @@ public abstract Builder incompatibleDisallowRuleExecutionPlatformConstraintsAllo

public abstract Builder incompatibleDisallowDictLookupUnhashableKeys(boolean value);

public abstract Builder incompatibleDisallowHashingFrozenMutables(boolean value);

public abstract StarlarkSemantics build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ private static StarlarkSemanticsOptions buildRandomOptions(Random rand) throws E
"--incompatible_visibility_private_attributes_at_definition=" + rand.nextBoolean(),
"--incompatible_restrict_string_escapes=" + rand.nextBoolean(),
"--incompatible_disallow_dict_lookup_unhashable_keys=" + rand.nextBoolean(),
"--incompatible_disallow_hashing_frozen_mutables=" + rand.nextBoolean(),
"--internal_skylark_flag_test_canary=" + rand.nextBoolean());
}

Expand Down Expand Up @@ -221,7 +220,6 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.incompatibleVisibilityPrivateAttributesAtDefinition(rand.nextBoolean())
.incompatibleRestrictStringEscapes(rand.nextBoolean())
.incompatibleDisallowDictLookupUnhashableKeys(rand.nextBoolean())
.incompatibleDisallowHashingFrozenMutables(rand.nextBoolean())
.internalSkylarkFlagTestCanary(rand.nextBoolean())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3239,20 +3239,8 @@ public void testIdentifierAssignmentFromOuterScopeForbidden() throws Exception {
assertContainsEvent("local variable 'a' is referenced before assignment");
}

@Test
public void testHashFrozenList() throws Exception {
setSkylarkSemanticsOptions("--incompatible_disallow_hashing_frozen_mutables=false");
scratch.file("test/extension.bzl", "y = []");

scratch.file(
"test/BUILD", "load('//test:extension.bzl', 'y')", "{y: 1}", "cc_library(name = 'r')");

getConfiguredTarget("//test:r");
}

@Test
public void testHashFrozenListForbidden() throws Exception {
setSkylarkSemanticsOptions("--incompatible_disallow_hashing_frozen_mutables=true");
scratch.file("test/extension.bzl", "y = []");

scratch.file(
Expand All @@ -3265,7 +3253,6 @@ public void testHashFrozenListForbidden() throws Exception {

@Test
public void testHashFrozenDeepMutableForbidden() throws Exception {
setSkylarkSemanticsOptions("--incompatible_disallow_hashing_frozen_mutables=true");
scratch.file("test/extension.bzl", "y = {}");

scratch.file(
Expand Down

0 comments on commit 5f713b3

Please sign in to comment.