KT-837 Problem with equals conversion
This commit is contained in:
@@ -591,11 +591,12 @@ public class Converter {
|
||||
if (expression != null) {
|
||||
PsiType actualType = expression.getType();
|
||||
if (actualType != null) {
|
||||
if (Node.PRIMITIVE_TYPES.contains(actualType.getCanonicalText()) && (expression instanceof PsiReferenceExpression
|
||||
&& ((PsiReferenceExpression) expression).isQualified() || expression instanceof PsiMethodCallExpression)
|
||||
&& expressionToExpression(expression).toKotlin().contains("?."))
|
||||
conversion += ".sure()";
|
||||
if (isConversionNeeded(actualType, expectedType))
|
||||
conversion += getPrimitiveTypeConversion(expectedType.getCanonicalText());
|
||||
if (Node.PRIMITIVE_TYPES.contains(actualType.getCanonicalText()) && (expression instanceof PsiReferenceExpression && ((PsiReferenceExpression) expression).isQualified() ||
|
||||
expression instanceof PsiMethodCallExpression))
|
||||
conversion += ".sure()";
|
||||
}
|
||||
}
|
||||
return conversion;
|
||||
|
||||
@@ -347,15 +347,12 @@ public class StatementVisitor extends ElementVisitor {
|
||||
public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
|
||||
super.visitReturnStatement(statement);
|
||||
PsiExpression returnValue = statement.getReturnValue();
|
||||
String conversion = "";
|
||||
|
||||
PsiType methodReturnType = Converter.getMethodReturnType();
|
||||
if (returnValue != null && methodReturnType != null && isConversionNeeded(returnValue.getType(), methodReturnType)) {
|
||||
conversion = getPrimitiveTypeConversion(methodReturnType.getCanonicalText());
|
||||
}
|
||||
Expression expression = returnValue != null && methodReturnType != null ?
|
||||
createSureCallOnlyForChain(returnValue, methodReturnType) :
|
||||
expressionToExpression(returnValue);
|
||||
myResult = new ReturnStatement(
|
||||
expressionToExpression(returnValue),
|
||||
conversion
|
||||
expression
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
open class Test() {
|
||||
open fun getInt() : Int {
|
||||
var b : Byte = 10
|
||||
return (b).int
|
||||
return b.int
|
||||
}
|
||||
}
|
||||
@@ -8,5 +8,5 @@ var myContainer : Container? = Container()
|
||||
}
|
||||
}
|
||||
open class Test() {
|
||||
var b : Byte = One.myContainer?.myInt.byt.sure()
|
||||
var b : Byte = One.myContainer?.myInt.sure().byt
|
||||
}
|
||||
@@ -9,6 +9,6 @@ var myContainer : Container? = Container()
|
||||
}
|
||||
open class Test() {
|
||||
open fun test() : Unit {
|
||||
var b : Byte = One.myContainer?.myInt.byt.sure()
|
||||
var b : Byte = One.myContainer?.myInt.sure().byt
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.voltvoodoo.saplo4j.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Language implements Serializable {
|
||||
public static Language ENGLISH = new Language("en");
|
||||
public static Language SWEDISH = new Language("sv");
|
||||
|
||||
protected String code;
|
||||
private static final long serialVersionUID = -2442762969929206780L;
|
||||
|
||||
public Language(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public boolean equals(Language other) {
|
||||
return other.toString().equals(this.toString());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace com.voltvoodoo.saplo4j.model
|
||||
import java.io.Serializable
|
||||
public open class Language(code : String?) : Serializable {
|
||||
{
|
||||
this.$code = code
|
||||
}
|
||||
protected var code : String? = null
|
||||
open public fun equals(other : Language?) : Boolean {
|
||||
return other?.toString()?.equals(this.toString()).sure()
|
||||
}
|
||||
class object {
|
||||
public var ENGLISH : Language? = Language("en")
|
||||
public var SWEDISH : Language? = Language("sv")
|
||||
private val serialVersionUID : Long = (-2442762969929206780)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user