Better assertion messages in TypeParameterDescriptor

This commit is contained in:
Andrey Breslav
2012-03-28 13:14:16 +04:00
parent 98887a09d1
commit 25323d560d
@@ -95,25 +95,28 @@ public class TypeParameterDescriptor extends DeclarationDescriptorImpl implement
upperBounds);
}
public void setInitialized() {
if (initialized) {
throw new IllegalStateException();
}
initialized = true;
}
private void checkInitialized() {
if (!initialized) {
throw new IllegalStateException();
throw new IllegalStateException("Type parameter descriptor in not initialized: " + nameForAssertions());
}
}
private void checkUninitialized() {
if (initialized) {
throw new IllegalStateException();
throw new IllegalStateException("Type parameter descriptor is already initialized: " + nameForAssertions());
}
}
private String nameForAssertions() {
DeclarationDescriptor owner = getContainingDeclaration();
return getName() + " declared in " + (owner == null ? "<no owner>" : owner.getName());
}
public void setInitialized() {
checkUninitialized();
initialized = true;
}
public boolean isReified() {
checkInitialized();
return reified;