Make CompileTimeConstant abstract class
This commit is contained in:
+1
-1
@@ -533,7 +533,7 @@ private fun createUnconvertibleCompileTimeConstant(value: Any?): CompileTimeCons
|
||||
private fun createStringConstant(value: CompileTimeConstant<*>?): StringValue? {
|
||||
return when (value) {
|
||||
null -> null
|
||||
is IntegerValueTypeConstant -> createStringConstant(value.getValue().getCompileTimeConstantForNumberType(TypeUtils.NO_EXPECTED_TYPE))
|
||||
is IntegerValueTypeConstant -> createStringConstant(value.getValue()!!.getCompileTimeConstantForNumberType(TypeUtils.NO_EXPECTED_TYPE))
|
||||
is StringValue -> value
|
||||
is IntValue, is ByteValue, is ShortValue, is LongValue,
|
||||
is CharValue,
|
||||
|
||||
@@ -22,18 +22,10 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class AnnotationValue implements CompileTimeConstant<AnnotationDescriptor> {
|
||||
public class AnnotationValue extends CompileTimeConstant<AnnotationDescriptor> {
|
||||
|
||||
private final AnnotationDescriptor value;
|
||||
|
||||
public AnnotationValue(@NotNull AnnotationDescriptor value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public AnnotationDescriptor getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,28 +17,22 @@
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ArrayValue implements CompileTimeConstant<List<CompileTimeConstant<?>>> {
|
||||
public class ArrayValue extends CompileTimeConstant<List<CompileTimeConstant<?>>> {
|
||||
|
||||
private final List<CompileTimeConstant<?>> value;
|
||||
private final JetType type;
|
||||
|
||||
public ArrayValue(@NotNull List<CompileTimeConstant<?>> value, @NotNull JetType type) {
|
||||
this.value = value;
|
||||
super(value);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public List<CompileTimeConstant<?>> getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
|
||||
|
||||
@@ -21,15 +21,13 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class BooleanValue implements CompileTimeConstant<Boolean> {
|
||||
public class BooleanValue extends CompileTimeConstant<Boolean> {
|
||||
|
||||
public static final BooleanValue FALSE = new BooleanValue(false);
|
||||
public static final BooleanValue TRUE = new BooleanValue(true);
|
||||
|
||||
private final boolean value;
|
||||
|
||||
private BooleanValue(boolean value) {
|
||||
this.value = value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -37,11 +35,6 @@ public class BooleanValue implements CompileTimeConstant<Boolean> {
|
||||
return value ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class ByteValue implements CompileTimeConstant<Byte> {
|
||||
public class ByteValue extends CompileTimeConstant<Byte> {
|
||||
public static final Function<Long, ByteValue> CREATE = new Function<Long, ByteValue>() {
|
||||
@Override
|
||||
public ByteValue apply(@Nullable Long input) {
|
||||
@@ -32,15 +32,8 @@ public class ByteValue implements CompileTimeConstant<Byte> {
|
||||
}
|
||||
};
|
||||
|
||||
private final byte value;
|
||||
|
||||
public ByteValue(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -21,17 +21,10 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class CharValue implements CompileTimeConstant<Character> {
|
||||
|
||||
private final char value;
|
||||
public class CharValue extends CompileTimeConstant<Character> {
|
||||
|
||||
public CharValue(char value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Character getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+14
-4
@@ -17,15 +17,25 @@
|
||||
package org.jetbrains.jet.lang.resolve.constants;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public interface CompileTimeConstant<T> {
|
||||
T getValue();
|
||||
public abstract class CompileTimeConstant<T> {
|
||||
protected final T value;
|
||||
|
||||
protected CompileTimeConstant(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public T getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns);
|
||||
public abstract JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns);
|
||||
|
||||
<R, D> R accept(AnnotationArgumentVisitor<R, D> visitor, D data);
|
||||
public abstract <R, D> R accept(AnnotationArgumentVisitor<R, D> visitor, D data);
|
||||
}
|
||||
|
||||
@@ -21,16 +21,10 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class DoubleValue implements CompileTimeConstant<Double> {
|
||||
private final double value;
|
||||
public class DoubleValue extends CompileTimeConstant<Double> {
|
||||
|
||||
public DoubleValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -22,17 +22,10 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class EnumValue implements CompileTimeConstant<ClassDescriptor> {
|
||||
private final ClassDescriptor value;
|
||||
public class EnumValue extends CompileTimeConstant<ClassDescriptor> {
|
||||
|
||||
public EnumValue(@NotNull ClassDescriptor value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ClassDescriptor getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -22,7 +22,11 @@ import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public abstract class ErrorValue implements CompileTimeConstant<Void> {
|
||||
public abstract class ErrorValue extends CompileTimeConstant<Void> {
|
||||
|
||||
public ErrorValue() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated // Should not be called, for this is not a real value, but a indication of an error
|
||||
|
||||
@@ -21,16 +21,10 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class FloatValue implements CompileTimeConstant<Float> {
|
||||
private final float value;
|
||||
public class FloatValue extends CompileTimeConstant<Float> {
|
||||
|
||||
public FloatValue(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class IntValue implements CompileTimeConstant<Integer> {
|
||||
public class IntValue extends CompileTimeConstant<Integer> {
|
||||
public static final Function<Long, IntValue> CREATE = new Function<Long, IntValue>() {
|
||||
@Override
|
||||
public IntValue apply(@Nullable Long input) {
|
||||
@@ -32,15 +32,8 @@ public class IntValue implements CompileTimeConstant<Integer> {
|
||||
}
|
||||
};
|
||||
|
||||
private final int value;
|
||||
|
||||
public IntValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
-10
@@ -27,12 +27,10 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class IntegerValueTypeConstant implements CompileTimeConstant<IntegerValueTypeConstructor> {
|
||||
|
||||
private final IntegerValueTypeConstructor value;
|
||||
public class IntegerValueTypeConstant extends CompileTimeConstant<IntegerValueTypeConstructor> {
|
||||
|
||||
public IntegerValueTypeConstant(long value) {
|
||||
this.value = new IntegerValueTypeConstructor(value);
|
||||
super(new IntegerValueTypeConstructor(value));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -49,12 +47,6 @@ public class IntegerValueTypeConstant implements CompileTimeConstant<IntegerValu
|
||||
return visitor.visitNumberTypeValue(this, data);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public IntegerValueTypeConstructor getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return value.toString();
|
||||
|
||||
@@ -21,12 +21,10 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
public class JavaClassValue implements CompileTimeConstant<JetType> {
|
||||
|
||||
private final JetType value;
|
||||
public class JavaClassValue extends CompileTimeConstant<JetType> {
|
||||
|
||||
public JavaClassValue(JetType value) {
|
||||
this.value = value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class LongValue implements CompileTimeConstant<Long> {
|
||||
public class LongValue extends CompileTimeConstant<Long> {
|
||||
public static final Function<Long, LongValue> CREATE = new Function<Long, LongValue>() {
|
||||
@Override
|
||||
public LongValue apply(@Nullable Long input) {
|
||||
@@ -31,15 +31,8 @@ public class LongValue implements CompileTimeConstant<Long> {
|
||||
}
|
||||
};
|
||||
|
||||
private final long value;
|
||||
|
||||
public LongValue(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -21,16 +21,12 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class NullValue implements CompileTimeConstant<Void> {
|
||||
public class NullValue extends CompileTimeConstant<Void> {
|
||||
|
||||
public static final NullValue NULL = new NullValue();
|
||||
|
||||
private NullValue() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Void getValue() {
|
||||
return null;
|
||||
super(null);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class ShortValue implements CompileTimeConstant<Short> {
|
||||
public class ShortValue extends CompileTimeConstant<Short> {
|
||||
public static final Function<Long, ShortValue> CREATE = new Function<Long, ShortValue>() {
|
||||
@Override
|
||||
public ShortValue apply(@Nullable Long input) {
|
||||
@@ -32,15 +32,8 @@ public class ShortValue implements CompileTimeConstant<Short> {
|
||||
}
|
||||
};
|
||||
|
||||
private final short value;
|
||||
|
||||
public ShortValue(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -21,17 +21,11 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
|
||||
public class StringValue implements CompileTimeConstant<String> {
|
||||
public class StringValue extends CompileTimeConstant<String> {
|
||||
|
||||
private final String value;
|
||||
|
||||
public StringValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return value;
|
||||
super(value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user