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/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
index 9448c32..5d44265 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/EvalUtils.java
@@ -212,10 +212,10 @@
} else if (c.equals(Void.TYPE) || c.equals(Environment.NoneType.class)) {
return "None";
} else if (List.class.isAssignableFrom(c)) {
- // TODO(bazel-team): for better debugging, we should distinguish "java tuple" and "java list"
- // from "tuple" and "list" -- or better yet, only use one set of pure data structures
- // everywhere and eliminate all calls to .append and .extend from the code base.
- return isTuple(c) ? "tuple" : "list";
+ // NB: the capital here is a subtle way to distinguish java Tuple and java List
+ // from native SkylarkList tuple and list.
+ // TODO(bazel-team): refactor SkylarkList and use it everywhere.
+ return isTuple(c) ? "Tuple" : "List";
} else if (GlobList.class.isAssignableFrom(c)) {
return "glob list";
} else if (Map.class.isAssignableFrom(c)) {