Compare arrays via equals (not Arrays.equals) in data classes
This commit is contained in:
@@ -503,18 +503,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
Type otherPropertyType = genPropertyOnStack(iv, context, propertyDescriptor, 2);
|
||||
StackValue.coerce(otherPropertyType, asmType, iv);
|
||||
|
||||
if (asmType.getSort() == Type.ARRAY) {
|
||||
Type elementType = correctElementType(asmType);
|
||||
if (elementType.getSort() == Type.OBJECT || elementType.getSort() == Type.ARRAY) {
|
||||
iv.invokestatic("java/util/Arrays", "equals", "([Ljava/lang/Object;[Ljava/lang/Object;)Z", false);
|
||||
}
|
||||
else {
|
||||
iv.invokestatic("java/util/Arrays", "equals",
|
||||
"(" + asmType.getDescriptor() + asmType.getDescriptor() + ")Z", false);
|
||||
}
|
||||
iv.ifeq(ne);
|
||||
}
|
||||
else if (asmType.getSort() == Type.FLOAT) {
|
||||
if (asmType.getSort() == Type.FLOAT) {
|
||||
iv.invokestatic("java/lang/Float", "compare", "(FF)I", false);
|
||||
iv.ifne(ne);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
data class A(val v: Array<Int>)
|
||||
|
||||
fun box() : String {
|
||||
if(A(arrayOf(0,1,2)) != A(arrayOf(0,1,2))) return "fail"
|
||||
val myArray = arrayOf(0, 1, 2)
|
||||
if(A(myArray) == A(arrayOf(0, 1, 2))) return "fail"
|
||||
if(A(myArray) != A(myArray)) return "fail 2"
|
||||
return "OK"
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
data class A(val v: IntArray)
|
||||
|
||||
fun box() : String {
|
||||
if(A(intArrayOf(0,1,2)) != A(intArrayOf(0,1,2))) return "fail"
|
||||
val myArray = intArrayOf(0, 1, 2)
|
||||
if(A(myArray) == A(intArrayOf(0, 1, 2))) return "fail"
|
||||
if(A(myArray) != A(myArray)) return "fail 2"
|
||||
return "OK"
|
||||
}
|
||||
+1
-1
@@ -73,7 +73,7 @@ public abstract class DeprecatedSymbolUsageFixBase(
|
||||
if (descriptor is CallableDescriptor &&
|
||||
descriptor.valueParameters.any { it.hasDefaultValue() && OptionalParametersHelper.defaultParameterValue(it, project) == null }) return null
|
||||
|
||||
return ReplaceWith(pattern, *imports.toTypedArray())
|
||||
return ReplaceWith(pattern, imports)
|
||||
}
|
||||
|
||||
data class Data(
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
|
||||
data class ReplaceWith(val pattern: String, vararg val imports: String)
|
||||
data class ReplaceWith(val pattern: String, val imports: List<String>)
|
||||
|
||||
object ReplaceWithAnnotationAnalyzer {
|
||||
public val PARAMETER_USAGE_KEY: Key<Name> = Key("PARAMETER_USAGE")
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public class DeprecatedSymbolUsageFixSpecialTest : JetLightCodeInsightFixtureTes
|
||||
val element = getFile().findElementAt(offset)
|
||||
val nameExpression = element!!.parents.firstIsInstance<JetSimpleNameExpression>()
|
||||
getProject().executeWriteCommand("") {
|
||||
DeprecatedSymbolUsageFix(nameExpression, ReplaceWith(pattern)).invoke(getProject(), getEditor(), getFile())
|
||||
DeprecatedSymbolUsageFix(nameExpression, ReplaceWith(pattern, emptyList())).invoke(getProject(), getEditor(), getFile())
|
||||
}
|
||||
|
||||
myFixture.checkResultByFile("$testPath.after")
|
||||
|
||||
Reference in New Issue
Block a user