From 2a8de3d6a9ee42ca5d72b978729858c08d26313e Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 15 Mar 2011 22:10:26 +0300 Subject: [PATCH] Implicit conversions for numbers removed --- idea/src/jet/lang/Library.jet | 442 +++++++++++++----- .../jet/lang/types/JetTypeChecker.java | 104 ++--- .../jet/lang/types/JetTypeInferrer.java | 6 +- .../jet/types/JetTypeCheckerTest.java | 56 +-- 4 files changed, 388 insertions(+), 220 deletions(-) diff --git a/idea/src/jet/lang/Library.jet b/idea/src/jet/lang/Library.jet index acd9e67621e..8dea9481b04 100644 --- a/idea/src/jet/lang/Library.jet +++ b/idea/src/jet/lang/Library.jet @@ -25,238 +25,426 @@ class Range> { } class Double : Comparable { + 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 + fun rangeTo(other : Float) : Range + fun rangeTo(other : Long) : Range + fun rangeTo(other : Int) : Range + fun rangeTo(other : Short) : Range + fun rangeTo(other : Byte) : Range + fun rangeTo(other : Char) : Range + + fun inc() : Double + fun dec() : Double } class Float : Comparable { 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 - fun rangeTo(other : Float) : Range + fun rangeTo(other : Float) : Range + fun rangeTo(other : Long) : Range + fun rangeTo(other : Int) : Range + fun rangeTo(other : Short) : Range + fun rangeTo(other : Byte) : Range + fun rangeTo(other : Char) : Range + + fun inc() : Float + fun dec() : Float } class Long : Comparable { 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 - fun rangeTo(other : Float) : Range - fun rangeTo(other : Long) : Range + fun rangeTo(other : Float) : Range + fun rangeTo(other : Long) : Range + fun rangeTo(other : Int) : Range + fun rangeTo(other : Short) : Range + fun rangeTo(other : Byte) : Range + fun rangeTo(other : Char) : Range + + fun inc() : Long + fun dec() : Long } class Int : Comparable { 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 - fun rangeTo(other : Float) : Range - fun rangeTo(other : Long) : Range - fun rangeTo(other : Int) : Range + fun rangeTo(other : Float) : Range + fun rangeTo(other : Long) : Range + fun rangeTo(other : Int) : Range + fun rangeTo(other : Short) : Range + fun rangeTo(other : Byte) : Range + fun rangeTo(other : Char) : Range + + fun inc() : Int + fun dec() : Int } class Char : Comparable { 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 - fun rangeTo(other : Float) : Range - fun rangeTo(other : Long) : Range - fun rangeTo(other : Int) : Range - fun rangeTo(other : Char) : Range + fun rangeTo(other : Float) : Range + fun rangeTo(other : Long) : Range + fun rangeTo(other : Int) : Range + fun rangeTo(other : Short) : Range + fun rangeTo(other : Byte) : Range + fun rangeTo(other : Char) : Range + + fun inc() : Char + fun dec() : Char } class Short : Comparable { 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 - fun rangeTo(other : Float) : Range - fun rangeTo(other : Long) : Range - fun rangeTo(other : Int) : Range - fun rangeTo(other : Short) : Range + fun rangeTo(other : Float) : Range + fun rangeTo(other : Long) : Range + fun rangeTo(other : Int) : Range + fun rangeTo(other : Short) : Range + fun rangeTo(other : Byte) : Range + fun rangeTo(other : Char) : Range + + fun inc() : Short + fun dec() : Short } class Byte : Comparable { 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 - fun rangeTo(other : Float) : Range - fun rangeTo(other : Long) : Range - fun rangeTo(other : Int) : Range - fun rangeTo(other : Short) : Range - fun rangeTo(other : Byte) : Range + fun rangeTo(other : Float) : Range + fun rangeTo(other : Long) : Range + fun rangeTo(other : Int) : Range + fun rangeTo(other : Short) : Range + fun rangeTo(other : Byte) : Range + fun rangeTo(other : Char) : Range + + fun inc() : Byte + fun dec() : Byte } \ No newline at end of file diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java index ce9865c2816..d3ceea6aa68 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeChecker.java @@ -19,50 +19,50 @@ public class JetTypeChecker { } private Map> 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(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(Arrays.asList(constructors))); +// } +// public JetType commonSupertype(Collection types) { Collection typeSet = new HashSet(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 convertibleTo = getConversionMap().get(actualConstructor); - if (convertibleTo != null) { - return convertibleTo.contains(constructor); - } - } +// if (actual.getArguments().isEmpty()) { +// TypeConstructor actualConstructor = actual.getConstructor(); +// TypeConstructor constructor = expected.getConstructor(); +// Set convertibleTo = getConversionMap().get(actualConstructor); +// if (convertibleTo != null) { +// return convertibleTo.contains(constructor); +// } +// } return false; } diff --git a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java index 9368a2e06c1..73a9599ff2a 100644 --- a/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java +++ b/idea/src/org/jetbrains/jet/lang/types/JetTypeInferrer.java @@ -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); } diff --git a/idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index 86c05c728db..0693ca6afc9 100644 --- a/idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/idea/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -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);