aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-05-15 09:27:31 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-05-15 09:29:09 -0700
commitc1b5c94114789a15632c4b99bc965462956216d7 (patch)
treec70b04e52bff05cf6da876437db29a373c346ac5 /src/main/java/com/google/devtools/build
parentff8162d01409db34893de98bd840a51c5f13e257 (diff)
Adds a ?null check and return false? code block in equals() method overridden by classes which would?ve otherwise thrown an NPE.
PiperOrigin-RevId: 196680390
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r--src/main/java/com/google/devtools/build/lib/syntax/SkylarkType.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkType.java b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkType.java
index 9e394d977d..524f06e4d5 100644
--- a/src/main/java/com/google/devtools/build/lib/syntax/SkylarkType.java
+++ b/src/main/java/com/google/devtools/build/lib/syntax/SkylarkType.java
@@ -247,6 +247,9 @@ public abstract class SkylarkType implements Serializable {
return type;
}
@Override public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
return this == other
|| (this.getClass() == other.getClass() && this.type.equals(((Simple) other).getType()));
}
@@ -359,6 +362,9 @@ public abstract class SkylarkType implements Serializable {
}
@Override public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
if (this == other) {
return true;
} else if (this.getClass() == other.getClass()) {
@@ -424,6 +430,9 @@ public abstract class SkylarkType implements Serializable {
return false;
}
@Override public boolean equals(Object other) {
+ if (other == null) {
+ return false;
+ }
if (this.getClass() == other.getClass()) {
Union o = (Union) other;
if (types.containsAll(o.types) && o.types.containsAll(types)) {