Move IS_PURE for constant inside CompileTimeConstant
This commit is contained in:
+8
-8
@@ -172,30 +172,30 @@ public final class JavaAnnotationArgumentResolver {
|
||||
return new StringValue((String) value, canBeUseInAnnotation);
|
||||
}
|
||||
else if (value instanceof Byte) {
|
||||
return new ByteValue((Byte) value, canBeUseInAnnotation);
|
||||
return new ByteValue((Byte) value, canBeUseInAnnotation, false);
|
||||
}
|
||||
else if (value instanceof Short) {
|
||||
return new ShortValue((Short) value, canBeUseInAnnotation);
|
||||
return new ShortValue((Short) value, canBeUseInAnnotation, false);
|
||||
}
|
||||
else if (value instanceof Character) {
|
||||
return new CharValue((Character) value, canBeUseInAnnotation);
|
||||
return new CharValue((Character) value, canBeUseInAnnotation, false);
|
||||
}
|
||||
else if (value instanceof Integer) {
|
||||
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
|
||||
Integer integer = (Integer) value;
|
||||
if (builtIns.getShortType().equals(expectedType)) {
|
||||
return new ShortValue(integer.shortValue(), canBeUseInAnnotation);
|
||||
return new ShortValue(integer.shortValue(), canBeUseInAnnotation, false);
|
||||
}
|
||||
else if (builtIns.getByteType().equals(expectedType)) {
|
||||
return new ByteValue(integer.byteValue(), canBeUseInAnnotation);
|
||||
return new ByteValue(integer.byteValue(), canBeUseInAnnotation, false);
|
||||
}
|
||||
else if (builtIns.getCharType().equals(expectedType)) {
|
||||
return new CharValue((char) integer.intValue(), canBeUseInAnnotation);
|
||||
return new CharValue((char) integer.intValue(), canBeUseInAnnotation, false);
|
||||
}
|
||||
return new IntValue(integer, canBeUseInAnnotation);
|
||||
return new IntValue(integer, canBeUseInAnnotation, false);
|
||||
}
|
||||
else if (value instanceof Long) {
|
||||
return new LongValue((Long) value, canBeUseInAnnotation);
|
||||
return new LongValue((Long) value, canBeUseInAnnotation, false);
|
||||
}
|
||||
else if (value instanceof Float) {
|
||||
return new FloatValue((Float) value, canBeUseInAnnotation);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public class AnnotationValue extends CompileTimeConstant<AnnotationDescriptor> {
|
||||
|
||||
public AnnotationValue(@NotNull AnnotationDescriptor value) {
|
||||
super(value, true);
|
||||
super(value, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -28,7 +28,7 @@ public class ArrayValue extends CompileTimeConstant<List<CompileTimeConstant<?>>
|
||||
private final JetType type;
|
||||
|
||||
public ArrayValue(@NotNull List<CompileTimeConstant<?>> value, @NotNull JetType type, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
super(value, canBeUsedInAnnotations, false);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
public class BooleanValue extends CompileTimeConstant<Boolean> {
|
||||
|
||||
public BooleanValue(boolean value, boolean canBeUseInAnnotation) {
|
||||
super(value, canBeUseInAnnotation);
|
||||
super(value, canBeUseInAnnotation, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class ByteValue extends CompileTimeConstant<Byte> {
|
||||
|
||||
public ByteValue(byte value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
public ByteValue(byte value, boolean canBeUsedInAnnotations, boolean pure) {
|
||||
super(value, canBeUsedInAnnotations, pure);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class CharValue extends CompileTimeConstant<Character> {
|
||||
|
||||
public CharValue(char value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
public CharValue(char value, boolean canBeUsedInAnnotations, boolean pure) {
|
||||
super(value, canBeUsedInAnnotations, pure);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+8
-1
@@ -25,16 +25,23 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public abstract class CompileTimeConstant<T> {
|
||||
protected final T value;
|
||||
private final boolean canBeUsedInAnnotations;
|
||||
// if false = constant type cannot be changed, ex. val a: Long = 1.toInt() (should be a TYPE_MISMATCH error, 1.toInt() isn't pure)
|
||||
private final boolean isPure;
|
||||
|
||||
protected CompileTimeConstant(T value, boolean canBeUsedInAnnotations) {
|
||||
protected CompileTimeConstant(T value, boolean canBeUsedInAnnotations, boolean pure) {
|
||||
this.value = value;
|
||||
this.canBeUsedInAnnotations = canBeUsedInAnnotations;
|
||||
this.isPure = pure;
|
||||
}
|
||||
|
||||
public boolean canBeUsedInAnnotations() {
|
||||
return canBeUsedInAnnotations;
|
||||
}
|
||||
|
||||
public boolean isPure() {
|
||||
return isPure;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getValue() {
|
||||
return value;
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
public class DoubleValue extends CompileTimeConstant<Double> {
|
||||
|
||||
public DoubleValue(double value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
super(value, canBeUsedInAnnotations, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public class EnumValue extends CompileTimeConstant<ClassDescriptor> {
|
||||
|
||||
public EnumValue(@NotNull ClassDescriptor value) {
|
||||
super(value, true);
|
||||
super(value, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public abstract class ErrorValue extends CompileTimeConstant<Void> {
|
||||
|
||||
public ErrorValue() {
|
||||
super(null, true);
|
||||
super(null, true, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
public class FloatValue extends CompileTimeConstant<Float> {
|
||||
|
||||
public FloatValue(float value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
super(value, canBeUsedInAnnotations, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class IntValue extends CompileTimeConstant<Integer> {
|
||||
|
||||
public IntValue(int value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
public IntValue(int value, boolean canBeUsedInAnnotations, boolean pure) {
|
||||
super(value, canBeUsedInAnnotations, pure);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ public class IntegerValueTypeConstant extends CompileTimeConstant<Number> {
|
||||
private final IntegerValueTypeConstructor typeConstructor;
|
||||
|
||||
public IntegerValueTypeConstant(@NotNull Number value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
super(value, canBeUsedInAnnotations, true);
|
||||
this.typeConstructor = new IntegerValueTypeConstructor(value.longValue());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
public class JavaClassValue extends CompileTimeConstant<JetType> {
|
||||
|
||||
public JavaClassValue(@NotNull JetType value) {
|
||||
super(value, true);
|
||||
super(value, true, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class LongValue extends CompileTimeConstant<Long> {
|
||||
|
||||
public LongValue(long value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
public LongValue(long value, boolean canBeUsedInAnnotations, boolean pure) {
|
||||
super(value, canBeUsedInAnnotations, pure);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -26,7 +26,7 @@ public class NullValue extends CompileTimeConstant<Void> {
|
||||
public static final NullValue NULL = new NullValue();
|
||||
|
||||
private NullValue() {
|
||||
super(null, false);
|
||||
super(null, false, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,8 +23,8 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class ShortValue extends CompileTimeConstant<Short> {
|
||||
|
||||
public ShortValue(short value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
public ShortValue(short value, boolean canBeUsedInAnnotations, boolean pure) {
|
||||
super(value, canBeUsedInAnnotations, pure);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,9 +23,8 @@ import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class StringValue extends CompileTimeConstant<String> {
|
||||
|
||||
|
||||
public StringValue(String value, boolean canBeUsedInAnnotations) {
|
||||
super(value, canBeUsedInAnnotations);
|
||||
super(value, canBeUsedInAnnotations, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user