java.lang.Object converted to Any?
This commit is contained in:
@@ -57,6 +57,7 @@ public class TypeVisitor extends PsiTypeVisitor<Type> implements Visitor {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private String getClassTypeName(@NotNull PsiClassType classType) {
|
private String getClassTypeName(@NotNull PsiClassType classType) {
|
||||||
String canonicalTypeStr = classType.getCanonicalText();
|
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.Byte")) return "Byte";
|
||||||
if (canonicalTypeStr.equals("java.lang.Character")) return "Char";
|
if (canonicalTypeStr.equals("java.lang.Character")) return "Char";
|
||||||
if (canonicalTypeStr.equals("java.lang.Double")) return "Double";
|
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 {
|
protected String expressionToKotlin(String code) throws Exception {
|
||||||
String result = statementToKotlin("Object o =" + code + "}");
|
String result = statementToKotlin("Object o =" + code + "}");
|
||||||
result = result.replaceFirst("var o : Object\\? =", "");
|
result = result.replaceFirst("var o : Any\\? =", "");
|
||||||
return prettify(result);
|
return prettify(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import org.jetbrains.jet.j2k.JetTestCaseBase;
|
|||||||
* @author ignatov
|
* @author ignatov
|
||||||
*/
|
*/
|
||||||
public class BoxedTypeTest extends JetTestCaseBase {
|
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 {
|
public void testBoolean() throws Exception {
|
||||||
Assert.assertEquals(statementToKotlin("Boolean i = 10;"), "var i : Boolean? = 10");
|
Assert.assertEquals(statementToKotlin("Boolean i = 10;"), "var i : Boolean? = 10");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class TypeParametersTest extends JetTestCaseBase {
|
|||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
methodToSingleLineKotlin(
|
methodToSingleLineKotlin(
|
||||||
"<T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) {}"),
|
"<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(
|
Assert.assertEquals(
|
||||||
methodToSingleLineKotlin(
|
methodToSingleLineKotlin(
|
||||||
"<T extends Object & Comparable<? super T>, K extends Node & Collection<? super K>> T max(Collection<? extends T> coll) {}"),
|
"<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 {
|
public void testEllipsisTypeSingleParams() throws Exception {
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
methodToSingleLineKotlin("void pushAll(Object... objs) {}"),
|
methodToSingleLineKotlin("void pushAll(Object... objs) {}"),
|
||||||
"fun pushAll(vararg objs : Object?) : Unit { }"
|
"fun pushAll(vararg objs : Any?) : Unit { }"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEllipsisTypeSeveralParams() throws Exception {
|
public void testEllipsisTypeSeveralParams() throws Exception {
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
methodToSingleLineKotlin("String format(String pattern, Object... arguments);"),
|
methodToSingleLineKotlin("String format(String pattern, Object... arguments);"),
|
||||||
"fun format(pattern : String?, vararg arguments : Object?) : String?"
|
"fun format(pattern : String?, vararg arguments : Any?) : String?"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user