added 'toString' "IntegerValueType(1)" to number value types
for debug and erroneously appeared in the places where it can be seen by user
This commit is contained in:
+20
-7
@@ -25,15 +25,16 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DoubleValueTypeConstructor extends NumberValueTypeConstructor {
|
public class DoubleValueTypeConstructor extends NumberValueTypeConstructor {
|
||||||
private static final DoubleValueTypeConstructor INSTANCE = new DoubleValueTypeConstructor();
|
private final double value;
|
||||||
|
|
||||||
public static DoubleValueTypeConstructor create(double value) {
|
|
||||||
return INSTANCE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final List<JetType> supertypes;
|
private final List<JetType> supertypes;
|
||||||
|
|
||||||
private DoubleValueTypeConstructor() {
|
|
||||||
|
public static DoubleValueTypeConstructor create(double value) {
|
||||||
|
return new DoubleValueTypeConstructor(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DoubleValueTypeConstructor(double value) {
|
||||||
|
this.value = value;
|
||||||
// order of types matters
|
// order of types matters
|
||||||
// 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type
|
// 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type
|
||||||
// for expected type 'Any' result type 'Double' should be returned
|
// for expected type 'Any' result type 'Double' should be returned
|
||||||
@@ -45,4 +46,16 @@ public class DoubleValueTypeConstructor extends NumberValueTypeConstructor {
|
|||||||
public Collection<JetType> getSupertypes() {
|
public Collection<JetType> getSupertypes() {
|
||||||
return supertypes;
|
return supertypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
DoubleValueTypeConstructor that = (DoubleValueTypeConstructor) o;
|
||||||
|
|
||||||
|
if (Double.compare(that.value, value) != 0) return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-14
@@ -24,6 +24,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class IntegerValueTypeConstructor extends NumberValueTypeConstructor {
|
public class IntegerValueTypeConstructor extends NumberValueTypeConstructor {
|
||||||
|
private final long value;
|
||||||
private final Collection<JetType> supertypes = Lists.newArrayList();
|
private final Collection<JetType> supertypes = Lists.newArrayList();
|
||||||
|
|
||||||
public static IntegerValueTypeConstructor create(long value) {
|
public static IntegerValueTypeConstructor create(long value) {
|
||||||
@@ -34,6 +35,7 @@ public class IntegerValueTypeConstructor extends NumberValueTypeConstructor {
|
|||||||
// order of types matters
|
// order of types matters
|
||||||
// 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type
|
// 'getPrimitiveNumberType' returns first of supertypes that is a subtype of expected type
|
||||||
// for expected type 'Any' result type 'Int' should be returned
|
// for expected type 'Any' result type 'Int' should be returned
|
||||||
|
this.value = value;
|
||||||
checkBoundsAndAddSuperType(value, (long) Integer.MIN_VALUE, (long) Integer.MAX_VALUE, KotlinBuiltIns.getInstance().getIntType());
|
checkBoundsAndAddSuperType(value, (long) Integer.MIN_VALUE, (long) Integer.MAX_VALUE, KotlinBuiltIns.getInstance().getIntType());
|
||||||
checkBoundsAndAddSuperType(value, (long) Byte.MIN_VALUE, (long) Byte.MAX_VALUE, KotlinBuiltIns.getInstance().getByteType());
|
checkBoundsAndAddSuperType(value, (long) Byte.MIN_VALUE, (long) Byte.MAX_VALUE, KotlinBuiltIns.getInstance().getByteType());
|
||||||
checkBoundsAndAddSuperType(value, (long) Short.MIN_VALUE, (long) Short.MAX_VALUE, KotlinBuiltIns.getInstance().getShortType());
|
checkBoundsAndAddSuperType(value, (long) Short.MIN_VALUE, (long) Short.MAX_VALUE, KotlinBuiltIns.getInstance().getShortType());
|
||||||
@@ -53,19 +55,7 @@ public class IntegerValueTypeConstructor extends NumberValueTypeConstructor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public String toString() {
|
||||||
if (this == o) return true;
|
return "IntegerValueType(" + value + ")";
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
IntegerValueTypeConstructor that = (IntegerValueTypeConstructor) o;
|
|
||||||
|
|
||||||
if (!supertypes.equals(that.supertypes)) return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return supertypes.hashCode();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user