Deindent the error checking logic in CollapseProperties
This is a behavior no-op, but looks more readable to me.
@@ -162,10 +162,14 @@ class CollapseProperties implements CompilerPass {
private Set<Name> checkNamespaces() {
ImmutableSet.Builder<Name> escaped = ImmutableSet.builder();
for (Name name : nameMap.values()) {
- if (name.isNamespaceObjectLit()
- && (name.getAliasingGets() > 0
- || name.getLocalSets() + name.getGlobalSets() > 1
- || name.getDeleteProps() > 0)) {
+ if (!name.isNamespaceObjectLit()) {
+ continue;
+ }
+ if (name.getAliasingGets() == 0
+ && name.getLocalSets() + name.getGlobalSets() <= 1
+ && name.getDeleteProps() == 0) {
+ continue;
+ }
boolean initialized = name.getDeclaration() != null;
for (Ref ref : name.getRefs()) {
if (ref == name.getDeclaration()) {
@@ -176,9 +180,7 @@ class CollapseProperties implements CompilerPass {
if (initialized) {
warnAboutNamespaceRedefinition(name, ref);
}
- } else if (
- ref.type == Ref.Type.SET_FROM_GLOBAL
- || ref.type == Ref.Type.SET_FROM_LOCAL) {
+ } else if (ref.type == Ref.Type.SET_FROM_GLOBAL || ref.type == Ref.Type.SET_FROM_LOCAL) {
if (initialized && !isSafeNamespaceReinit(ref)) {
warnAboutNamespaceRedefinition(name, ref);
}
@@ -191,7 +193,6 @@ class CollapseProperties implements CompilerPass {
}
}
}
- }
return escaped.build();
}
