java.lang.Object converted to Any?

This commit is contained in:
Sergey Ignatov
2011-11-04 15:03:08 +04:00
parent 72aa85cb95
commit 74230b70e5
5 changed files with 10 additions and 5 deletions
@@ -57,6 +57,7 @@ public class TypeVisitor extends PsiTypeVisitor<Type> implements Visitor {
@NotNull
private String getClassTypeName(@NotNull PsiClassType classType) {
String canonicalTypeStr = classType.getCanonicalText();
if (canonicalTypeStr.equals("java.lang.Object")) return "Any";
if (canonicalTypeStr.equals("java.lang.Byte")) return "Byte";
if (canonicalTypeStr.equals("java.lang.Character")) return "Char";
if (canonicalTypeStr.equals("java.lang.Double")) return "Double";
@@ -133,7 +133,7 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
protected String expressionToKotlin(String code) throws Exception {
String result = statementToKotlin("Object o =" + code + "}");
result = result.replaceFirst("var o : Object\\? =", "");
result = result.replaceFirst("var o : Any\\? =", "");
return prettify(result);
}
@@ -7,6 +7,10 @@ import org.jetbrains.jet.j2k.JetTestCaseBase;
* @author ignatov
*/
public class BoxedTypeTest extends JetTestCaseBase {
public void testObject() throws Exception {
Assert.assertEquals(statementToKotlin("Object i = 10;"), "var i : Any? = 10");
}
public void testBoolean() throws Exception {
Assert.assertEquals(statementToKotlin("Boolean i = 10;"), "var i : Boolean? = 10");
}
@@ -25,7 +25,7 @@ public class TypeParametersTest extends JetTestCaseBase {
Assert.assertEquals(
methodToSingleLineKotlin(
"<T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) {}"),
"fun max<T : Object?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>? { }"
"fun max<T : Any?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>? { }"
);
}
@@ -33,7 +33,7 @@ public class TypeParametersTest extends JetTestCaseBase {
Assert.assertEquals(
methodToSingleLineKotlin(
"<T extends Object & Comparable<? super T>, K extends Node & Collection<? super K>> T max(Collection<? extends T> coll) {}"),
"fun max<T : Object?, K : Node?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>?, K : Collection<in K?>? { }"
"fun max<T : Any?, K : Node?>(coll : Collection<out T?>?) : T? where T : Comparable<in T?>?, K : Collection<in K?>? { }"
);
}
@@ -10,14 +10,14 @@ public class VarArgTest extends JetTestCaseBase {
public void testEllipsisTypeSingleParams() throws Exception {
Assert.assertEquals(
methodToSingleLineKotlin("void pushAll(Object... objs) {}"),
"fun pushAll(vararg objs : Object?) : Unit { }"
"fun pushAll(vararg objs : Any?) : Unit { }"
);
}
public void testEllipsisTypeSeveralParams() throws Exception {
Assert.assertEquals(
methodToSingleLineKotlin("String format(String pattern, Object... arguments);"),
"fun format(pattern : String?, vararg arguments : Object?) : String?"
"fun format(pattern : String?, vararg arguments : Any?) : String?"
);
}
}