Implicit conversions for numbers removed

This commit is contained in:
Andrey Breslav
2011-03-15 22:10:26 +03:00
parent dafa8f7230
commit 2a8de3d6a9
4 changed files with 388 additions and 220 deletions
+315 -127
View File
@@ -25,238 +25,426 @@ class Range<in T : Comparable<T>> {
}
class Double : Comparable<Double> {
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Double
fun plus(other : Long) : Double
fun plus(other : Int) : Double
fun plus(other : Short) : Double
fun plus(other : Byte) : Double
fun plus(other : Char) : Double
fun minus(other : Double) : Double
fun minus(other : Float) : Double
fun minus(other : Long) : Double
fun minus(other : Int) : Double
fun minus(other : Short) : Double
fun minus(other : Byte) : Double
fun minus(other : Char) : Double
fun times(other : Double) : Double
fun times(other : Float) : Double
fun times(other : Long) : Double
fun times(other : Int) : Double
fun times(other : Short) : Double
fun times(other : Byte) : Double
fun times(other : Char) : Double
fun div(other : Double) : Double
fun div(other : Float) : Double
fun div(other : Long) : Double
fun div(other : Int) : Double
fun div(other : Short) : Double
fun div(other : Byte) : Double
fun div(other : Char) : Double
fun mod(other : Double) : Double
fun mod(other : Float) : Double
fun mod(other : Long) : Double
fun mod(other : Int) : Double
fun mod(other : Short) : Double
fun mod(other : Byte) : Double
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Double>
fun rangeTo(other : Long) : Range<Double>
fun rangeTo(other : Int) : Range<Double>
fun rangeTo(other : Short) : Range<Double>
fun rangeTo(other : Byte) : Range<Double>
fun rangeTo(other : Char) : Range<Double>
fun inc() : Double
fun dec() : Double
}
class Float : Comparable<Float> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Float) : Float
fun plus(other : Long) : Float
fun plus(other : Int) : Float
fun plus(other : Short) : Float
fun plus(other : Byte) : Float
fun plus(other : Char) : Float
fun minus(other : Double) : Double
fun minus(other : Float) : Float
fun minus(other : Float) : Float
fun minus(other : Long) : Float
fun minus(other : Int) : Float
fun minus(other : Short) : Float
fun minus(other : Byte) : Float
fun minus(other : Char) : Float
fun times(other : Double) : Double
fun times(other : Float) : Float
fun times(other : Float) : Float
fun times(other : Long) : Float
fun times(other : Int) : Float
fun times(other : Short) : Float
fun times(other : Byte) : Float
fun times(other : Char) : Float
fun div(other : Double) : Double
fun div(other : Float) : Float
fun div(other : Float) : Float
fun div(other : Long) : Float
fun div(other : Int) : Float
fun div(other : Short) : Float
fun div(other : Byte) : Float
fun div(other : Char) : Float
fun mod(other : Double) : Double
fun mod(other : Float) : Float
fun mod(other : Float) : Float
fun mod(other : Long) : Float
fun mod(other : Int) : Float
fun mod(other : Short) : Float
fun mod(other : Byte) : Float
fun mod(other : Char) : Float
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Float>
fun rangeTo(other : Int) : Range<Float>
fun rangeTo(other : Short) : Range<Float>
fun rangeTo(other : Byte) : Range<Float>
fun rangeTo(other : Char) : Range<Float>
fun inc() : Float
fun dec() : Float
}
class Long : Comparable<Long> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Long
fun plus(other : Short) : Long
fun plus(other : Byte) : Long
fun plus(other : Char) : Long
fun minus(other : Double) : Double
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Long
fun minus(other : Short) : Long
fun minus(other : Byte) : Long
fun minus(other : Char) : Long
fun times(other : Double) : Double
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Long
fun times(other : Short) : Long
fun times(other : Byte) : Long
fun times(other : Char) : Long
fun div(other : Double) : Double
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Long
fun div(other : Short) : Long
fun div(other : Byte) : Long
fun div(other : Char) : Long
fun mod(other : Double) : Double
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Long
fun mod(other : Short) : Long
fun mod(other : Byte) : Long
fun mod(other : Char) : Long
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Long>
fun rangeTo(other : Short) : Range<Long>
fun rangeTo(other : Byte) : Range<Long>
fun rangeTo(other : Char) : Range<Long>
fun inc() : Long
fun dec() : Long
}
class Int : Comparable<Int> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
fun plus(other : Short) : Int
fun plus(other : Byte) : Int
fun plus(other : Char) : Int
fun minus(other : Double) : Double
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Int
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Int
fun minus(other : Short) : Int
fun minus(other : Byte) : Int
fun minus(other : Char) : Int
fun times(other : Double) : Double
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Int
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Int
fun times(other : Short) : Int
fun times(other : Byte) : Int
fun times(other : Char) : Int
fun div(other : Double) : Double
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Int
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Int
fun div(other : Short) : Int
fun div(other : Byte) : Int
fun div(other : Char) : Int
fun mod(other : Double) : Double
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Int
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Int
fun mod(other : Short) : Int
fun mod(other : Byte) : Int
fun mod(other : Char) : Int
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Int>
fun rangeTo(other : Byte) : Range<Int>
fun rangeTo(other : Char) : Range<Int>
fun inc() : Int
fun dec() : Int
}
class Char : Comparable<Char> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
fun plus(other : Char) : Char
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
fun plus(other : Short) : Int
fun plus(other : Byte) : Int
fun plus(other : Char) : Int
fun minus(other : Double) : Double
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Int
fun minus(other : Char) : Char
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Int
fun minus(other : Short) : Int
fun minus(other : Byte) : Int
fun minus(other : Char) : Int
fun times(other : Double) : Double
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Int
fun times(other : Char) : Char
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Int
fun times(other : Short) : Int
fun times(other : Byte) : Int
fun times(other : Char) : Int
fun div(other : Double) : Double
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Int
fun div(other : Char) : Char
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Int
fun div(other : Short) : Int
fun div(other : Byte) : Int
fun div(other : Char) : Int
fun mod(other : Double) : Double
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Int
fun mod(other : Char) : Char
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Int
fun mod(other : Short) : Int
fun mod(other : Byte) : Int
fun mod(other : Char) : Int
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Char) : Range<Char>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Int>
fun rangeTo(other : Byte) : Range<Int>
fun rangeTo(other : Char) : Range<Int>
fun inc() : Char
fun dec() : Char
}
class Short : Comparable<Char> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
fun plus(other : Short) : Short
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
fun plus(other : Short) : Int
fun plus(other : Byte) : Int
fun plus(other : Char) : Int
fun minus(other : Double) : Double
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Int
fun minus(other : Short) : Short
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Int
fun minus(other : Short) : Int
fun minus(other : Byte) : Int
fun minus(other : Char) : Int
fun times(other : Double) : Double
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Int
fun times(other : Short) : Short
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Int
fun times(other : Short) : Int
fun times(other : Byte) : Int
fun times(other : Char) : Int
fun div(other : Double) : Double
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Int
fun div(other : Short) : Short
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Int
fun div(other : Short) : Int
fun div(other : Byte) : Int
fun div(other : Char) : Int
fun mod(other : Double) : Double
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Int
fun mod(other : Short) : Short
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Int
fun mod(other : Short) : Int
fun mod(other : Byte) : Int
fun mod(other : Char) : Int
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Short>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Int>
fun rangeTo(other : Byte) : Range<Int>
fun rangeTo(other : Char) : Range<Int>
fun inc() : Short
fun dec() : Short
}
class Byte : Comparable<Char> {
fun compareTo(other : Double) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Long) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Float) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Int) : Int
fun compareTo(other : Short) : Int
fun compareTo(other : Byte) : Int
fun compareTo(other : Char) : Int
fun plus(other : Double) : Double
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
fun plus(other : Short) : Short
fun plus(other : Byte) : Byte
fun plus(other : Float) : Float
fun plus(other : Long) : Long
fun plus(other : Int) : Int
fun plus(other : Short) : Int
fun plus(other : Byte) : Int
fun plus(other : Char) : Int
fun minus(other : Double) : Double
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Int
fun minus(other : Short) : Short
fun minus(other : Byte) : Byte
fun minus(other : Float) : Float
fun minus(other : Long) : Long
fun minus(other : Int) : Int
fun minus(other : Short) : Int
fun minus(other : Byte) : Int
fun minus(other : Char) : Int
fun times(other : Double) : Double
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Int
fun times(other : Short) : Short
fun times(other : Byte) : Byte
fun times(other : Float) : Float
fun times(other : Long) : Long
fun times(other : Int) : Int
fun times(other : Short) : Int
fun times(other : Byte) : Int
fun times(other : Char) : Int
fun div(other : Double) : Double
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Int
fun div(other : Short) : Short
fun div(other : Byte) : Byte
fun div(other : Float) : Float
fun div(other : Long) : Long
fun div(other : Int) : Int
fun div(other : Short) : Int
fun div(other : Byte) : Int
fun div(other : Char) : Int
fun mod(other : Double) : Double
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Int
fun mod(other : Short) : Short
fun mod(other : Byte) : Byte
fun mod(other : Float) : Float
fun mod(other : Long) : Long
fun mod(other : Int) : Int
fun mod(other : Short) : Int
fun mod(other : Byte) : Int
fun mod(other : Char) : Int
fun rangeTo(other : Double) : Range<Double>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Short>
fun rangeTo(other : Byte) : Range<Byte>
fun rangeTo(other : Float) : Range<Float>
fun rangeTo(other : Long) : Range<Long>
fun rangeTo(other : Int) : Range<Int>
fun rangeTo(other : Short) : Range<Int>
fun rangeTo(other : Byte) : Range<Int>
fun rangeTo(other : Char) : Range<Int>
fun inc() : Byte
fun dec() : Byte
}
@@ -19,50 +19,50 @@ public class JetTypeChecker {
}
private Map<TypeConstructor, Set<TypeConstructor>> getConversionMap() {
if (conversionMap.size() == 0) {
addConversion(standardLibrary.getByte(),
standardLibrary.getShort(),
standardLibrary.getInt(),
standardLibrary.getLong(),
standardLibrary.getFloat(),
standardLibrary.getDouble());
addConversion(standardLibrary.getShort(),
standardLibrary.getInt(),
standardLibrary.getLong(),
standardLibrary.getFloat(),
standardLibrary.getDouble());
addConversion(standardLibrary.getChar(),
standardLibrary.getInt(),
standardLibrary.getLong(),
standardLibrary.getFloat(),
standardLibrary.getDouble());
addConversion(standardLibrary.getInt(),
standardLibrary.getLong(),
standardLibrary.getFloat(),
standardLibrary.getDouble());
addConversion(standardLibrary.getLong(),
standardLibrary.getFloat(),
standardLibrary.getDouble());
addConversion(standardLibrary.getFloat(),
standardLibrary.getDouble());
}
// if (conversionMap.size() == 0) {
// addConversion(standardLibrary.getByte(),
// standardLibrary.getShort(),
// standardLibrary.getInt(),
// standardLibrary.getLong(),
// standardLibrary.getFloat(),
// standardLibrary.getDouble());
//
// addConversion(standardLibrary.getShort(),
// standardLibrary.getInt(),
// standardLibrary.getLong(),
// standardLibrary.getFloat(),
// standardLibrary.getDouble());
//
// addConversion(standardLibrary.getChar(),
// standardLibrary.getInt(),
// standardLibrary.getLong(),
// standardLibrary.getFloat(),
// standardLibrary.getDouble());
//
// addConversion(standardLibrary.getInt(),
// standardLibrary.getLong(),
// standardLibrary.getFloat(),
// standardLibrary.getDouble());
//
// addConversion(standardLibrary.getLong(),
// standardLibrary.getFloat(),
// standardLibrary.getDouble());
//
// addConversion(standardLibrary.getFloat(),
// standardLibrary.getDouble());
// }
return conversionMap;
}
private void addConversion(ClassDescriptor actual, ClassDescriptor... convertedTo) {
TypeConstructor[] constructors = new TypeConstructor[convertedTo.length];
for (int i = 0, convertedToLength = convertedTo.length; i < convertedToLength; i++) {
ClassDescriptor classDescriptor = convertedTo[i];
constructors[i] = classDescriptor.getTypeConstructor();
}
conversionMap.put(actual.getTypeConstructor(), new HashSet<TypeConstructor>(Arrays.asList(constructors)));
}
// private void addConversion(ClassDescriptor actual, ClassDescriptor... convertedTo) {
// TypeConstructor[] constructors = new TypeConstructor[convertedTo.length];
// for (int i = 0, convertedToLength = convertedTo.length; i < convertedToLength; i++) {
// ClassDescriptor classDescriptor = convertedTo[i];
// constructors[i] = classDescriptor.getTypeConstructor();
// }
// conversionMap.put(actual.getTypeConstructor(), new HashSet<TypeConstructor>(Arrays.asList(constructors)));
// }
//
public JetType commonSupertype(Collection<JetType> types) {
Collection<JetType> typeSet = new HashSet<JetType>(types);
assert !typeSet.isEmpty();
@@ -274,23 +274,19 @@ public class JetTypeChecker {
handler.afterChildren(current);
}
public boolean isConvertibleTo(JetExpression expression, JetType type) {
throw new UnsupportedOperationException(); // TODO
}
public boolean isConvertibleTo(JetType actual, JetType expected) {
if (isSubtypeOf(actual, expected)) return true;
if (expected.getConstructor() == JetStandardClasses.getTuple(0).getTypeConstructor()) {
if (expected.getConstructor().equals(JetStandardClasses.getTuple(0).getTypeConstructor())) {
return true;
}
if (actual.getArguments().isEmpty()) {
TypeConstructor actualConstructor = actual.getConstructor();
TypeConstructor constructor = expected.getConstructor();
Set<TypeConstructor> convertibleTo = getConversionMap().get(actualConstructor);
if (convertibleTo != null) {
return convertibleTo.contains(constructor);
}
}
// if (actual.getArguments().isEmpty()) {
// TypeConstructor actualConstructor = actual.getConstructor();
// TypeConstructor constructor = expected.getConstructor();
// Set<TypeConstructor> convertibleTo = getConversionMap().get(actualConstructor);
// if (convertibleTo != null) {
// return convertibleTo.contains(constructor);
// }
// }
return false;
}
@@ -456,7 +456,9 @@ public class JetTypeInferrer {
public void visitNewExpression(JetNewExpression expression) {
// TODO : type argument inference
JetTypeReference typeReference = expression.getTypeReference();
result = typeResolver.resolveType(scope, typeReference);
if (typeReference != null) {
result = typeResolver.resolveType(scope, typeReference);
}
}
@Override
@@ -465,7 +467,7 @@ public class JetTypeInferrer {
JetExpression receiverExpression = expression.getReceiverExpression();
JetExpression selectorExpression = expression.getSelectorExpression();
JetType receiverType = getType(scope, receiverExpression, false);
if (receiverType != null) { // TODO : review
if (receiverType != null && selectorExpression != null) { // TODO : review
JetScope compositeScope = new ScopeWithReceiver(scope, receiverType);
result = getType(compositeScope, selectorExpression, false);
}
@@ -356,19 +356,19 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
public void testPlus() throws Exception {
assertType("1d.plus(1d)", "Double");
// assertType("1d.plus(1f)", "Double");
// assertType("1d.plus(1L)", "Double");
// assertType("1d.plus(1)", "Double");
assertType("1d.plus(1f)", "Double");
assertType("1d.plus(1L)", "Double");
assertType("1d.plus(1)", "Double");
assertType("1f.plus(1d)", "Double");
assertType("1f.plus(1f)", "Float");
// assertType("1f.plus(1L)", "Float");
// assertType("1f.plus(1)", "Float");
assertType("1f.plus(1L)", "Float");
assertType("1f.plus(1)", "Float");
assertType("1L.plus(1d)", "Double");
assertType("1L.plus(1f)", "Float");
assertType("1L.plus(1L)", "Long");
// assertType("1L.plus(1)", "Long");
assertType("1L.plus(1)", "Long");
assertType("1.plus(1d)", "Double");
assertType("1.plus(1f)", "Float");
@@ -379,20 +379,20 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertType("'1'.plus(1f)", "Float");
assertType("'1'.plus(1L)", "Long");
assertType("'1'.plus(1)", "Int");
assertType("'1'.plus('1')", "Char");
assertType("'1'.plus('1')", "Int");
// assertType("(1:Short).plus(1d)", "Double");
// assertType("(1:Short).plus(1f)", "Float");
// assertType("(1:Short).plus(1L)", "Long");
// assertType("(1:Short).plus(1)", "Int");
// assertType("(1:Short).plus(1:Short)", "Short");
//
// assertType("(1:Byte).plus(1d)", "Double");
// assertType("(1:Byte).plus(1f)", "Float");
// assertType("(1:Byte).plus(1L)", "Long");
// assertType("(1:Byte).plus(1)", "Int");
// assertType("(1:Byte).plus(1:Short)", "Short");
// assertType("(1:Byte).plus(1:Byte)", "Byte");
assertType("(1:Short).plus(1d)", "Double");
assertType("(1:Short).plus(1f)", "Float");
assertType("(1:Short).plus(1L)", "Long");
assertType("(1:Short).plus(1)", "Int");
assertType("(1:Short).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1d)", "Double");
assertType("(1:Byte).plus(1f)", "Float");
assertType("(1:Byte).plus(1L)", "Long");
assertType("(1:Byte).plus(1)", "Int");
assertType("(1:Byte).plus(1:Short)", "Int");
assertType("(1:Byte).plus(1:Byte)", "Int");
assertType("\"1\".plus(1d)", "String");
assertType("\"1\".plus(1f)", "String");
@@ -401,10 +401,6 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertType("\"1\".plus('1')", "String");
}
// assertConvertibleTo("1", JetStandardClasses.getByteType());
// public void testImplicitConversions() throws Exception {
// }
//
private void assertSubtype(String type1, String type2) {
assertSubtypingRelation(type1, type2, true);
}
@@ -432,20 +428,6 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
assertTrue(typeNode1 + " is " + modifier + "a subtype of " + typeNode2, result == expected);
}
private void assertConvertibleTo(String expression, JetType type) {
JetExpression jetExpression = JetChangeUtil.createExpression(getProject(), expression);
assertTrue(
expression + " must be convertible to " + type,
semanticServices.getTypeChecker().isConvertibleTo(jetExpression, type));
}
private void assertNotConvertibleTo(String expression, JetType type) {
JetExpression jetExpression = JetChangeUtil.createExpression(getProject(), expression);
assertFalse(
expression + " must not be convertible to " + type,
semanticServices.getTypeChecker().isConvertibleTo(jetExpression, type));
}
private void assertType(String expression, JetType expectedType) {
Project project = getProject();
JetExpression jetExpression = JetChangeUtil.createExpression(project, expression);