Refactoring: reuse method, remove warnings, don't process descriptors substituted to null twice

This commit is contained in:
Nikolay Krasko
2013-01-28 18:52:29 +04:00
parent 9b807a6c30
commit 2ec9e10f14
@@ -53,10 +53,13 @@ public class SubstitutingScope implements JetScope {
} }
DeclarationDescriptor substituted = substitutedDescriptors.get(descriptor); DeclarationDescriptor substituted = substitutedDescriptors.get(descriptor);
if (substituted == null) { if (substituted == null && !substitutedDescriptors.containsKey(descriptor)) {
substituted = descriptor.substitute(substitutor); substituted = descriptor.substitute(substitutor);
//noinspection ConstantConditions
substitutedDescriptors.put(descriptor, substituted); substitutedDescriptors.put(descriptor, substituted);
} }
//noinspection unchecked //noinspection unchecked
return (D) substituted; return (D) substituted;
} }
@@ -129,7 +132,7 @@ public class SubstitutingScope implements JetScope {
@NotNull @NotNull
@Override @Override
public Collection<DeclarationDescriptor> getDeclarationsByLabel(LabelName labelName) { public Collection<DeclarationDescriptor> getDeclarationsByLabel(@NotNull LabelName labelName) {
throw new UnsupportedOperationException(); // TODO throw new UnsupportedOperationException(); // TODO
} }
@@ -142,14 +145,7 @@ public class SubstitutingScope implements JetScope {
@Override @Override
public Collection<DeclarationDescriptor> getAllDescriptors() { public Collection<DeclarationDescriptor> getAllDescriptors() {
if (allDescriptors == null) { if (allDescriptors == null) {
allDescriptors = Sets.newHashSet(); allDescriptors = substitute(workerScope.getAllDescriptors());
for (DeclarationDescriptor descriptor : workerScope.getAllDescriptors()) {
DeclarationDescriptor substitute = substitute(descriptor);
// assert substitute != null : descriptor;
if (substitute != null) {
allDescriptors.add(substitute);
}
}
} }
return allDescriptors; return allDescriptors;
} }