Fix race condition in SkylarkType.of
Fix race condition in SkylarkType.of(), whereby .equals() but not same (==) types were created, by making Simple.of() synchronized.
Also make SkylarkType#includes() more robust by using .equals() instead of == (it's a little bit slower in the case of Simple types once fixed, but also works on complex types that don't hash-cons their values).
Also, distinguish SkylarkList (printed as list) and java.util.List (printed as List) and similarly for tuple vs Tuple, when printing types in debugging messages.
--
MOS_MIGRATED_REVID=87490176
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 7aad74f..9da4ed2 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
@@ -61,8 +61,8 @@
public void testDataTypeNames() throws Exception {
assertEquals("string", EvalUtils.getDataTypeName("foo"));
assertEquals("int", EvalUtils.getDataTypeName(3));
- assertEquals("tuple", EvalUtils.getDataTypeName(makeTuple(1, 2, 3)));
- assertEquals("list", EvalUtils.getDataTypeName(makeList(1, 2, 3)));
+ assertEquals("Tuple", EvalUtils.getDataTypeName(makeTuple(1, 2, 3)));
+ assertEquals("List", EvalUtils.getDataTypeName(makeList(1, 2, 3)));
assertEquals("dict", EvalUtils.getDataTypeName(makeDict()));
assertEquals("FilesetEntry", EvalUtils.getDataTypeName(makeFilesetEntry()));
assertEquals("None", EvalUtils.getDataTypeName(Environment.NONE));