bazel syntax: remove deprecated list constructors
- rename Sequence.createImmutable to StarlarkList.immutableCopyOf
- delete StarlarkList.of(StarlarkThread, ...)
and StarlarkList.copyOf(StarlarkThread, ...)
Mutability is now always an explicit parameter.
StarlarkThread is no longer relevant to StarlarkList
- deprecate Dict constructors that take a StarlarkThread,
and provide (only a few) Mutability variants.
This CL makes only the minimum change to Dict to support
the changes to StarlarkList. A follow-up CL will
eliminate the deprecated constructors. In some cases
"(Mutability) null" is required to avoid overload ambiguity.
This is a breaking change for copybara.
BEGIN_PUBLIC
bazel syntax: remove deprecated list constructors
END_PUBLIC
PiperOrigin-RevId: 281805867
diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java
index c7fecbb..667e582 100644
--- a/src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java
+++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/skylark/SkylarkRepositoryContextTest.java
@@ -45,8 +45,9 @@
import com.google.devtools.build.lib.syntax.Expression;
import com.google.devtools.build.lib.syntax.FuncallExpression;
import com.google.devtools.build.lib.syntax.FunctionSignature;
+import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.ParserInput;
-import com.google.devtools.build.lib.syntax.Sequence;
+import com.google.devtools.build.lib.syntax.StarlarkList;
import com.google.devtools.build.lib.syntax.StarlarkSemantics;
import com.google.devtools.build.lib.syntax.StarlarkThread;
import com.google.devtools.build.lib.testutil.Scratch;
@@ -59,7 +60,6 @@
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -376,7 +376,7 @@
"$remotable",
true,
"exec_properties",
- Dict.of(null, "OSFamily", "Linux"));
+ Dict.of((Mutability) null, "OSFamily", "Linux"));
RepositoryRemoteExecutor repoRemoteExecutor = Mockito.mock(RepositoryRemoteExecutor.class);
ExecutionResult executionResult =
@@ -397,7 +397,7 @@
// Act
SkylarkExecutionResult skylarkExecutionResult =
context.execute(
- Sequence.createImmutable(Arrays.asList("/bin/cmd", "arg1")),
+ StarlarkList.of(/*mutability=*/ null, "/bin/cmd", "arg1"),
/*timeout=*/ 10,
/* uncheckedEnvironment=*/ Dict.empty(),
/* quiet= */ true,
diff --git a/src/test/java/com/google/devtools/build/lib/packages/TargetUtilsTest.java b/src/test/java/com/google/devtools/build/lib/packages/TargetUtilsTest.java
index baa85f4..d140af0 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/TargetUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/TargetUtilsTest.java
@@ -19,6 +19,7 @@
import com.google.common.collect.Lists;
import com.google.devtools.build.lib.packages.util.PackageLoadingTestCase;
import com.google.devtools.build.lib.syntax.Dict;
+import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.Starlark;
import java.util.Map;
import org.junit.Test;
@@ -197,12 +198,14 @@
Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(
- Dict.of(null, "supports-worker", "1"), noTag, /* allowTagsPropagation */ true);
+ Dict.of((Mutability) null, "supports-worker", "1"),
+ noTag, /* allowTagsPropagation */
+ true);
assertThat(execInfo).containsExactly("supports-worker", "1");
execInfo =
TargetUtils.getFilteredExecutionInfo(
- Dict.of(null, "some-custom-tag", "1", "no-cache", "1"),
+ Dict.of((Mutability) null, "some-custom-tag", "1", "no-cache", "1"),
noTag,
/* allowTagsPropagation */ true);
assertThat(execInfo).containsExactly("no-cache", "1");
@@ -214,7 +217,8 @@
"tests/BUILD",
"sh_binary(name = 'tag1', srcs=['sh.sh'], tags=['supports-workers', 'no-cache'])");
Rule tag1 = (Rule) getTarget("//tests:tag1");
- Dict<String, String> executionRequirementsUnchecked = Dict.of(null, "no-remote", "1");
+ Dict<String, String> executionRequirementsUnchecked =
+ Dict.of((Mutability) null, "no-remote", "1");
Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(
@@ -229,7 +233,8 @@
"tests/BUILD",
"sh_binary(name = 'tag1', srcs=['sh.sh'], tags=['supports-workers', 'no-cache'])");
Rule tag1 = (Rule) getTarget("//tests:tag1");
- Dict<String, String> executionRequirementsUnchecked = Dict.of(null, "no-cache", "1");
+ Dict<String, String> executionRequirementsUnchecked =
+ Dict.of((Mutability) null, "no-cache", "1");
Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(
@@ -261,7 +266,8 @@
"tests/BUILD",
"sh_binary(name = 'tag1', srcs=['sh.sh'], tags=['supports-workers', 'no-cache'])");
Rule tag1 = (Rule) getTarget("//tests:tag1");
- Dict<String, String> executionRequirementsUnchecked = Dict.of(null, "no-remote", "1");
+ Dict<String, String> executionRequirementsUnchecked =
+ Dict.of((Mutability) null, "no-remote", "1");
Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(
diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java
index 73df135..b670186 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/SkylarkCcToolchainConfigureTest.java
@@ -14,6 +14,7 @@
package com.google.devtools.build.lib.rules.cpp;
import com.google.devtools.build.lib.packages.util.ResourceLoader;
+import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.StarlarkList;
import com.google.devtools.build.lib.syntax.util.EvaluationTestCase;
import com.google.devtools.build.lib.testutil.TestConstants;
@@ -28,24 +29,25 @@
@Test
public void testSplitEscaped() throws Exception {
+ Mutability mu = null;
newTest()
- .testExpression("split_escaped('a:b:c', ':')", StarlarkList.of(thread, "a", "b", "c"))
- .testExpression("split_escaped('a%:b', ':')", StarlarkList.of(thread, "a:b"))
- .testExpression("split_escaped('a%%b', ':')", StarlarkList.of(thread, "a%b"))
- .testExpression("split_escaped('a:::b', ':')", StarlarkList.of(thread, "a", "", "", "b"))
- .testExpression("split_escaped('a:b%:c', ':')", StarlarkList.of(thread, "a", "b:c"))
- .testExpression("split_escaped('a%%:b:c', ':')", StarlarkList.of(thread, "a%", "b", "c"))
- .testExpression("split_escaped(':a', ':')", StarlarkList.of(thread, "", "a"))
- .testExpression("split_escaped('a:', ':')", StarlarkList.of(thread, "a", ""))
- .testExpression("split_escaped('::a::', ':')", StarlarkList.of(thread, "", "", "a", "", ""))
- .testExpression("split_escaped('%%%:a%%%%:b', ':')", StarlarkList.of(thread, "%:a%%", "b"))
- .testExpression("split_escaped('', ':')", StarlarkList.of(thread))
- .testExpression("split_escaped('%', ':')", StarlarkList.of(thread, "%"))
- .testExpression("split_escaped('%%', ':')", StarlarkList.of(thread, "%"))
- .testExpression("split_escaped('%:', ':')", StarlarkList.of(thread, ":"))
- .testExpression("split_escaped(':', ':')", StarlarkList.of(thread, "", ""))
- .testExpression("split_escaped('a%%b', ':')", StarlarkList.of(thread, "a%b"))
- .testExpression("split_escaped('a%:', ':')", StarlarkList.of(thread, "a:"));
+ .testExpression("split_escaped('a:b:c', ':')", StarlarkList.of(mu, "a", "b", "c"))
+ .testExpression("split_escaped('a%:b', ':')", StarlarkList.of(mu, "a:b"))
+ .testExpression("split_escaped('a%%b', ':')", StarlarkList.of(mu, "a%b"))
+ .testExpression("split_escaped('a:::b', ':')", StarlarkList.of(mu, "a", "", "", "b"))
+ .testExpression("split_escaped('a:b%:c', ':')", StarlarkList.of(mu, "a", "b:c"))
+ .testExpression("split_escaped('a%%:b:c', ':')", StarlarkList.of(mu, "a%", "b", "c"))
+ .testExpression("split_escaped(':a', ':')", StarlarkList.of(mu, "", "a"))
+ .testExpression("split_escaped('a:', ':')", StarlarkList.of(mu, "a", ""))
+ .testExpression("split_escaped('::a::', ':')", StarlarkList.of(mu, "", "", "a", "", ""))
+ .testExpression("split_escaped('%%%:a%%%%:b', ':')", StarlarkList.of(mu, "%:a%%", "b"))
+ .testExpression("split_escaped('', ':')", StarlarkList.of(mu))
+ .testExpression("split_escaped('%', ':')", StarlarkList.of(mu, "%"))
+ .testExpression("split_escaped('%%', ':')", StarlarkList.of(mu, "%"))
+ .testExpression("split_escaped('%:', ':')", StarlarkList.of(mu, ":"))
+ .testExpression("split_escaped(':', ':')", StarlarkList.of(mu, "", ""))
+ .testExpression("split_escaped('a%%b', ':')", StarlarkList.of(mu, "a%b"))
+ .testExpression("split_escaped('a%:', ':')", StarlarkList.of(mu, "a:"));
}
private ModalTestCase newTest(String... skylarkOptions) throws IOException {
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java
index 2f464ae..8dab70b 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkActionProviderTest.java
@@ -27,6 +27,7 @@
import com.google.devtools.build.lib.packages.SkylarkProvider.SkylarkKey;
import com.google.devtools.build.lib.packages.StructImpl;
import com.google.devtools.build.lib.syntax.Dict;
+import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.Sequence;
import java.util.List;
import java.util.stream.Collectors;
@@ -132,7 +133,8 @@
(Sequence<Dict<String, String>>) fooProvider.getValue("envs");
assertThat(envs)
.containsExactly(
- Dict.of(null, "foo", "bar", "pet", "puppy"), Dict.of(null, "pet", "bunny"));
+ Dict.of((Mutability) null, "foo", "bar", "pet", "puppy"),
+ Dict.of((Mutability) null, "pet", "bunny"));
Sequence<Sequence<Artifact>> inputs =
(Sequence<Sequence<Artifact>>) fooProvider.getValue("inputs");
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
index e647599..1f14a23 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleClassFunctionsTest.java
@@ -50,16 +50,17 @@
import com.google.devtools.build.lib.syntax.Dict;
import com.google.devtools.build.lib.syntax.EvalException;
import com.google.devtools.build.lib.syntax.EvalUtils;
+import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.ParserInput;
import com.google.devtools.build.lib.syntax.SkylarkNestedSet;
import com.google.devtools.build.lib.syntax.StarlarkFile;
import com.google.devtools.build.lib.syntax.StarlarkList;
-import com.google.devtools.build.lib.syntax.StarlarkThread;
import com.google.devtools.build.lib.syntax.SyntaxError;
import com.google.devtools.build.lib.syntax.Tuple;
import com.google.devtools.build.lib.testutil.MoreAsserts;
import com.google.devtools.build.lib.util.FileTypeSet;
import java.util.Collection;
+import javax.annotation.Nullable;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -1274,19 +1275,19 @@
return StructProvider.STRUCT.create(ImmutableMap.of(field, value), "no field '%'");
}
- private static StructImpl makeBigStruct(StarlarkThread thread) {
+ private static StructImpl makeBigStruct(@Nullable Mutability mu) {
// struct(a=[struct(x={1:1}), ()], b=(), c={2:2})
return StructProvider.STRUCT.create(
ImmutableMap.<String, Object>of(
"a",
StarlarkList.<Object>of(
- thread,
+ mu,
StructProvider.STRUCT.create(
- ImmutableMap.<String, Object>of("x", Dict.<Object, Object>of(thread, 1, 1)),
+ ImmutableMap.<String, Object>of("x", Dict.<Object, Object>of(mu, 1, 1)),
"no field '%s'"),
Tuple.of()),
"b", Tuple.of(),
- "c", Dict.<Object, Object>of(thread, 2, 2)),
+ "c", Dict.<Object, Object>of(mu, 2, 2)),
"no field '%s'");
}
@@ -1295,8 +1296,8 @@
assertThat(EvalUtils.isImmutable(makeStruct("a", 1))).isTrue();
}
- private static StarlarkList<Object> makeList(StarlarkThread thread) {
- return StarlarkList.<Object>of(thread, 1, 2, 3);
+ private static StarlarkList<Object> makeList(@Nullable Mutability mu) {
+ return StarlarkList.<Object>of(mu, 1, 2, 3);
}
@Test
@@ -1305,9 +1306,10 @@
assertThat(EvalUtils.isImmutable(makeStruct("a", makeList(null)))).isTrue();
assertThat(EvalUtils.isImmutable(makeBigStruct(null))).isTrue();
- assertThat(EvalUtils.isImmutable(Tuple.<Object>of(makeList(ev.getStarlarkThread())))).isFalse();
- assertThat(EvalUtils.isImmutable(makeStruct("a", makeList(ev.getStarlarkThread())))).isFalse();
- assertThat(EvalUtils.isImmutable(makeBigStruct(ev.getStarlarkThread()))).isFalse();
+ Mutability mu = ev.getStarlarkThread().mutability();
+ assertThat(EvalUtils.isImmutable(Tuple.<Object>of(makeList(mu)))).isFalse();
+ assertThat(EvalUtils.isImmutable(makeStruct("a", makeList(mu)))).isFalse();
+ assertThat(EvalUtils.isImmutable(makeBigStruct(mu))).isFalse();
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
index 35020bc..fb134dd 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
@@ -48,6 +48,7 @@
import com.google.devtools.build.lib.rules.python.PyProviderUtils;
import com.google.devtools.build.lib.skylark.util.SkylarkTestCase;
import com.google.devtools.build.lib.syntax.Dict;
+import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.Sequence;
import com.google.devtools.build.lib.syntax.SkylarkNestedSet;
import com.google.devtools.build.lib.syntax.Starlark;
@@ -2174,7 +2175,7 @@
Object substitutionsUnchecked = eval("action.substitutions");
assertThat(substitutionsUnchecked).isInstanceOf(Dict.class);
- assertThat(substitutionsUnchecked).isEqualTo(Dict.of(null, "a", "b"));
+ assertThat(substitutionsUnchecked).isEqualTo(Dict.of((Mutability) null, "a", "b"));
}
private void setUpCoverageInstrumentedTest() throws Exception {
diff --git a/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/SkylarkDebugServerTest.java b/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/SkylarkDebugServerTest.java
index a0ee468..4f889ee9 100644
--- a/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/SkylarkDebugServerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylarkdebug/server/SkylarkDebugServerTest.java
@@ -42,9 +42,9 @@
import com.google.devtools.build.lib.syntax.EvalUtils;
import com.google.devtools.build.lib.syntax.Mutability;
import com.google.devtools.build.lib.syntax.ParserInput;
-import com.google.devtools.build.lib.syntax.Sequence;
import com.google.devtools.build.lib.syntax.Starlark;
import com.google.devtools.build.lib.syntax.StarlarkFile;
+import com.google.devtools.build.lib.syntax.StarlarkList;
import com.google.devtools.build.lib.syntax.StarlarkThread;
import com.google.devtools.build.lib.testutil.Scratch;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
@@ -366,8 +366,7 @@
.addScope(
Scope.newBuilder()
.setName("global")
- .addBinding(
- getValueProto("x", Sequence.createImmutable(ImmutableList.of(1, 2, 3)))))
+ .addBinding(getValueProto("x", StarlarkList.of(/*mutability=*/ null, 1, 2, 3))))
.build());
}
@@ -391,7 +390,7 @@
Value xValue = frames.getFrame(0).getScope(0).getBinding(0);
assertValuesEqualIgnoringId(
- xValue, getValueProto("x", Sequence.createImmutable(ImmutableList.of(1, 2, 3))));
+ xValue, getValueProto("x", StarlarkList.of(/*mutability=*/ null, 1, 2, 3)));
List<Value> children = getChildren(xValue);
@@ -522,7 +521,7 @@
ListFramesResponse frames = listFrames(threadId);
assertThat(frames.getFrame(0).getScope(0).getBindingList())
- .contains(getValueProto("x", Sequence.createImmutable(ImmutableList.of(5, 6))));
+ .contains(getValueProto("x", StarlarkList.of(/*mutability=*/ null, 5, 6)));
}
@Test
@@ -556,7 +555,7 @@
ListFramesResponse frames = listFrames(threadId);
assertThat(frames.getFrame(0).getScope(0).getBindingList())
- .contains(getValueProto("x", Sequence.createImmutable(ImmutableList.of(1, 2, 3, 4))));
+ .contains(getValueProto("x", StarlarkList.of(/*mutability=*/ null, 1, 2, 3, 4)));
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvalUtilsTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvalUtilsTest.java
index 95f27fa..365b8c6 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EvalUtilsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EvalUtilsTest.java
@@ -36,7 +36,7 @@
public class EvalUtilsTest extends EvaluationTestCase {
private static StarlarkList<Object> makeList(StarlarkThread thread) {
- return StarlarkList.of(thread, 1, 2, 3);
+ return StarlarkList.of(thread == null ? null : thread.mutability(), 1, 2, 3);
}
private static Dict<Object, Object> makeDict(StarlarkThread thread) {
@@ -96,8 +96,8 @@
Starlark.NONE,
Tuple.of(1, 2, 3),
Tuple.of("1", "2", "3"),
- StarlarkList.of(thread, 1, 2, 3),
- StarlarkList.of(thread, "1", "2", "3"),
+ StarlarkList.of(thread.mutability(), 1, 2, 3),
+ StarlarkList.of(thread.mutability(), "1", "2", "3"),
Dict.of(thread, "key", 123),
Dict.of(thread, 123, "value"),
StructProvider.STRUCT.create(ImmutableMap.of("key", (Object) "value"), "no field %s"),
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
index 21a47036..0685ece 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/EvaluationTest.java
@@ -283,7 +283,7 @@
// list
Object x = eval("[1,2] + [3,4]");
assertThat((Iterable<Object>) x).containsExactly(1, 2, 3, 4).inOrder();
- assertThat(x).isEqualTo(StarlarkList.of(thread, 1, 2, 3, 4));
+ assertThat(x).isEqualTo(StarlarkList.of(thread.mutability(), 1, 2, 3, 4));
assertThat(EvalUtils.isImmutable(x)).isFalse();
// tuple
@@ -475,7 +475,7 @@
@Test
public void testListConcatenation() throws Exception {
newTest()
- .testExpression("[1, 2] + [3, 4]", StarlarkList.of(thread, 1, 2, 3, 4))
+ .testExpression("[1, 2] + [3, 4]", StarlarkList.of(thread.mutability(), 1, 2, 3, 4))
.testExpression("(1, 2) + (3, 4)", Tuple.of(1, 2, 3, 4))
.testIfExactError(
"unsupported operand type(s) for +: 'list' and 'tuple'", "[1, 2] + (3, 4)")
@@ -485,16 +485,17 @@
@Test
public void testListMultiply() throws Exception {
+ Mutability mu = thread.mutability();
newTest()
- .testExpression("[1, 2, 3] * 1", StarlarkList.of(thread, 1, 2, 3))
- .testExpression("[1, 2] * 2", StarlarkList.of(thread, 1, 2, 1, 2))
- .testExpression("[1, 2] * 3", StarlarkList.of(thread, 1, 2, 1, 2, 1, 2))
- .testExpression("[1, 2] * 4", StarlarkList.of(thread, 1, 2, 1, 2, 1, 2, 1, 2))
- .testExpression("[8] * 5", StarlarkList.of(thread, 8, 8, 8, 8, 8))
+ .testExpression("[1, 2, 3] * 1", StarlarkList.of(mu, 1, 2, 3))
+ .testExpression("[1, 2] * 2", StarlarkList.of(mu, 1, 2, 1, 2))
+ .testExpression("[1, 2] * 3", StarlarkList.of(mu, 1, 2, 1, 2, 1, 2))
+ .testExpression("[1, 2] * 4", StarlarkList.of(mu, 1, 2, 1, 2, 1, 2, 1, 2))
+ .testExpression("[8] * 5", StarlarkList.of(mu, 8, 8, 8, 8, 8))
.testExpression("[ ] * 10", StarlarkList.empty())
.testExpression("[1, 2] * 0", StarlarkList.empty())
.testExpression("[1, 2] * -4", StarlarkList.empty())
- .testExpression("2 * [1, 2]", StarlarkList.of(thread, 1, 2, 1, 2))
+ .testExpression("2 * [1, 2]", StarlarkList.of(mu, 1, 2, 1, 2))
.testExpression("10 * []", StarlarkList.empty())
.testExpression("0 * [1, 2]", StarlarkList.empty())
.testExpression("-4 * [1, 2]", StarlarkList.empty());
@@ -569,7 +570,7 @@
public void testListComprehensionOnDictionaryCompositeExpression() throws Exception {
new BuildTest()
.setUp("d = {1:'a',2:'b'}", "l = [d[x] for x in d]")
- .testLookup("l", StarlarkList.of(thread, "a", "b"));
+ .testLookup("l", StarlarkList.of(thread.mutability(), "a", "b"));
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
index 6b8bb04..0ecc3cf 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java
@@ -1084,7 +1084,7 @@
" modified_list = v + ['extra_string']",
" return modified_list",
"m = func(mock)")
- .testLookup("m", StarlarkList.of(thread, "b", "c", "extra_string"));
+ .testLookup("m", StarlarkList.of(thread.mutability(), "b", "c", "extra_string"));
}
@Test
@@ -1555,7 +1555,7 @@
" return value",
"",
"f()[1] += 1") // `f()` should be called only once here
- .testLookup("counter", StarlarkList.of(thread, 1));
+ .testLookup("counter", StarlarkList.of(thread.mutability(), 1));
// Check key position.
new SkylarkTest()
@@ -1568,7 +1568,7 @@
" return 1",
"",
"value[f()] += 1") // `f()` should be called only once here
- .testLookup("counter", StarlarkList.of(thread, 1));
+ .testLookup("counter", StarlarkList.of(thread.mutability(), 1));
}
@Test
@@ -1608,8 +1608,9 @@
"",
"f(ordinary)[0] = g(ordinary)[1]",
"f(augmented)[0] += g(augmented)[1]")
- .testLookup("ordinary", StarlarkList.of(thread, "g", "f")) // This order is consistent
- .testLookup("augmented", StarlarkList.of(thread, "f", "g")); // with Python
+ .testLookup(
+ "ordinary", StarlarkList.of(thread.mutability(), "g", "f")) // This order is consistent
+ .testLookup("augmented", StarlarkList.of(thread.mutability(), "f", "g")); // with Python
}
@Test
@@ -1741,7 +1742,7 @@
public void testDictAssignmentAsLValueSideEffects() throws Exception {
new SkylarkTest()
.setUp("def func(d):", " d['b'] = 2", "d = {'a' : 1}", "func(d)")
- .testLookup("d", Dict.of(null, "a", 1, "b", 2));
+ .testLookup("d", Dict.of((Mutability) null, "a", 1, "b", 2));
}
@Test
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkListTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkListTest.java
index a404505..da8b41d 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkListTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkListTest.java
@@ -155,7 +155,8 @@
@Test
public void testListConcat() throws Exception {
- assertThat(eval("[1, 2] + [3, 4]")).isEqualTo(Sequence.createImmutable(Tuple.of(1, 2, 3, 4)));
+ assertThat(eval("[1, 2] + [3, 4]"))
+ .isEqualTo(StarlarkList.of(/*mutability=*/ null, 1, 2, 3, 4));
}
@Test
@@ -317,7 +318,8 @@
public void testGetSkylarkType_GivesExpectedClassesForListsAndTuples() throws Exception {
Class<?> emptyTupleClass = Tuple.empty().getClass();
Class<?> tupleClass = Tuple.of(1, "a", "b").getClass();
- Class<?> mutableListClass = StarlarkList.copyOf(thread, Tuple.of(1, 2, 3)).getClass();
+ Class<?> mutableListClass =
+ StarlarkList.copyOf(thread.mutability(), Tuple.of(1, 2, 3)).getClass();
assertThat(EvalUtils.getSkylarkType(mutableListClass)).isEqualTo(StarlarkList.class);
assertThat(EvalUtils.getSkylarkType(emptyTupleClass)).isEqualTo(Tuple.class);
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/StarlarkFileTest.java b/src/test/java/com/google/devtools/build/lib/syntax/StarlarkFileTest.java
index 0d1fafe..20267d9 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/StarlarkFileTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/StarlarkFileTest.java
@@ -58,7 +58,7 @@
// input1.BUILD contains:
// x = [1,2,'foo',4] + [1,2, "%s%d" % ('foo', 1)]
assertThat(thread.moduleLookup("x"))
- .isEqualTo(Sequence.createImmutable(Tuple.of(1, 2, "foo", 4, 1, 2, "foo1")));
+ .isEqualTo(StarlarkList.of(/*mutability=*/ null, 1, 2, "foo", 4, 1, 2, "foo1"));
}
@Test