Minor, assert value != null in EnumValue

Similar to ArrayValue, AnnotationValue, etc.
This commit is contained in:
Alexander Udalov
2014-03-03 22:11:32 +04:00
parent c74b8e72c7
commit 981c40286f
2 changed files with 9 additions and 4 deletions
@@ -36,6 +36,14 @@ public class EnumValue extends CompileTimeConstant<ClassDescriptor> {
return type;
}
@NotNull
@Override
public ClassDescriptor getValue() {
ClassDescriptor value = super.getValue();
assert value != null : "Guaranteed by constructor";
return value;
}
@Override
public <R, D> R accept(AnnotationArgumentVisitor<R, D> visitor, D data) {
return visitor.visitEnumValue(this, data);
@@ -21,7 +21,6 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.Annotated;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.annotations.Annotations;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
@@ -56,9 +55,7 @@ public class InlineUtil {
}
else {
assert argument instanceof EnumValue : "Inline annotation parameter should be inline entry but was: " + argument + "!";
ClassDescriptor value = ((EnumValue) argument).getValue();
assert value != null : "Value for enum value should be not null " + argument;
String name = value.getName().asString();
String name = ((EnumValue) argument).getValue().getName().asString();
return name.equals(InlineStrategy.IN_PLACE.name()) ? InlineStrategy.IN_PLACE : InlineStrategy.AS_FUNCTION;
}
}