Drop identityEquals from builtins, compiler and tests.
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.intrinsics
|
||||
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
import org.jetbrains.kotlin.codegen.ExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.StackValue
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.KtBinaryExpression
|
||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE
|
||||
|
||||
class IdentityEquals : IntrinsicMethod() {
|
||||
override fun toCallable(method: CallableMethod): Callable =
|
||||
object : IntrinsicCallable(method) {
|
||||
override fun invokeMethodWithArguments(
|
||||
resolvedCall: ResolvedCall<*>,
|
||||
receiver: StackValue,
|
||||
codegen: ExpressionCodegen
|
||||
): StackValue {
|
||||
val element = resolvedCall.call.callElement
|
||||
val left: StackValue
|
||||
val right: StackValue
|
||||
if (element is KtCallExpression) {
|
||||
left = StackValue.receiver(resolvedCall, receiver, codegen, this)
|
||||
right = codegen.gen(resolvedCall.valueArgumentsByIndex!!.single().arguments.single().getArgumentExpression())
|
||||
}
|
||||
else {
|
||||
element as KtBinaryExpression
|
||||
left = codegen.gen(element.left)
|
||||
right = codegen.gen(element.right)
|
||||
}
|
||||
return StackValue.cmp(KtTokens.EQEQEQ, OBJECT_TYPE, left, right)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,6 @@ public class IntrinsicMethods {
|
||||
|
||||
private static final IntrinsicMethod ARRAY_SIZE = new ArraySize();
|
||||
private static final Equals EQUALS = new Equals();
|
||||
private static final IdentityEquals IDENTITY_EQUALS = new IdentityEquals();
|
||||
private static final IteratorNext ITERATOR_NEXT = new IteratorNext();
|
||||
private static final ArraySet ARRAY_SET = new ArraySet();
|
||||
private static final ArrayGet ARRAY_GET = new ArrayGet();
|
||||
@@ -127,7 +126,6 @@ public class IntrinsicMethods {
|
||||
declareIntrinsicFunction(FQ_NAMES.cloneable, "clone", 0, CLONE);
|
||||
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.any, "toString", 0, TO_STRING);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.any, "identityEquals", 1, IDENTITY_EQUALS);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.string, "plus", 1, STRING_PLUS);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOfNulls", 1, new NewArray());
|
||||
|
||||
|
||||
-1
@@ -1109,7 +1109,6 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
result = visitEquality(expression, context, operationSign, left, right);
|
||||
}
|
||||
else if (OperatorConventions.IDENTITY_EQUALS_OPERATIONS.contains(operationType)) {
|
||||
context.trace.record(REFERENCE_TARGET, operationSign, components.builtIns.getIdentityEquals());
|
||||
ensureNonemptyIntersectionOfOperandTypes(expression, context);
|
||||
// TODO : Check comparison pointlessness
|
||||
result = TypeInfoFactoryKt.createTypeInfo(components.builtIns.getBooleanType(), context);
|
||||
|
||||
@@ -2,7 +2,6 @@ class Test {
|
||||
fun check(a: Any?): String {
|
||||
if (this === a) return "Fail 1"
|
||||
if (!(this !== a)) return "Fail 2"
|
||||
if (this.identityEquals(a)) return "Fail 3"
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ fun box(): String {
|
||||
val r = object : Runnable {
|
||||
override fun run() {}
|
||||
}
|
||||
return if (foo(r).identityEquals(r)) "OK" else "Fail"
|
||||
return if (foo(r) === r) "OK" else "Fail"
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ fun box(): String {
|
||||
val r = object : Runnable {
|
||||
override fun run() {}
|
||||
}
|
||||
return if (foo(r).identityEquals(r)) "OK" else "Fail"
|
||||
return if (foo(r) === r) "OK" else "Fail"
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ class Foo {
|
||||
fun box() : String {
|
||||
val a = Foo()
|
||||
val b = Foo()
|
||||
if (!a.identityEquals(a)) return "fail 1"
|
||||
if (!b.identityEquals(b)) return "fail 2"
|
||||
if (b.identityEquals(a)) return "fail 3"
|
||||
if (a.identityEquals(b)) return "fail 4"
|
||||
if (a !== a) return "fail 1"
|
||||
if (b !== b) return "fail 2"
|
||||
if (b === a) return "fail 3"
|
||||
if (a === b) return "fail 4"
|
||||
if( a !=b ) return "fail5"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ fun box(): String {
|
||||
val a = A(42)
|
||||
val b = a.clone()
|
||||
if (b != a) return "Fail equals"
|
||||
if (b.identityEquals(a)) return "Fail identity"
|
||||
if (b === a) return "Fail identity"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -6,6 +6,6 @@ fun box(): String {
|
||||
val a = A(42)
|
||||
val b = a.clone()
|
||||
if (a != b) return "Fail equals"
|
||||
if (a.identityEquals(b)) return "Fail identity"
|
||||
if (a === b) return "Fail identity"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ fun box(): String {
|
||||
val a = A(42)
|
||||
val b = a.clone()
|
||||
if (a == b) return "Fail: $a == $b"
|
||||
if (a.identityEquals(b)) return "Fail: $a identityEquals $b"
|
||||
if (a === b) return "Fail: $a === $b"
|
||||
if (b.x != 239) return "Fail: b.x = ${b.x}"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ fun box(): String {
|
||||
a.add("prosper")
|
||||
val b = a.clone()
|
||||
if (a != b) return "Fail equals"
|
||||
if (a.identityEquals(b)) return "Fail identity"
|
||||
if (a === b) return "Fail identity"
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ fun box(): String {
|
||||
|
||||
if (c.s != d.s) return "Fail s: ${d.s}"
|
||||
if (c.l != d.l) return "Fail l: ${d.l}"
|
||||
if (c.l.identityEquals(d.l)) return "Fail list identity"
|
||||
if (c.identityEquals(d)) return "Fail identity"
|
||||
if (c.l === d.l) return "Fail list identity"
|
||||
if (c === d) return "Fail identity"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,6 +6,6 @@ fun box(): String {
|
||||
val a = A("OK")
|
||||
val b = a.externalClone()
|
||||
if (a != b) return "Fail equals"
|
||||
if (a.identityEquals(b)) return "Fail identity"
|
||||
if (a === b) return "Fail identity"
|
||||
return b.s
|
||||
}
|
||||
|
||||
@@ -13,23 +13,23 @@ fun box(): String {
|
||||
val a = original
|
||||
|
||||
a += 1
|
||||
if (!(a.identityEquals(original))) return "Fail 1: $a !== $original"
|
||||
if (a !== original) return "Fail 1: $a !== $original"
|
||||
if (a.x != 1) return "Fail 2: ${a.x} != 1"
|
||||
|
||||
a -= 2
|
||||
if (!(a.identityEquals(original))) return "Fail 3: $a !== $original"
|
||||
if (a !== original) return "Fail 3: $a !== $original"
|
||||
if (a.x != -1) return "Fail 4: ${a.x} != -1"
|
||||
|
||||
a *= -10
|
||||
if (!(a.identityEquals(original))) return "Fail 5: $a !== $original"
|
||||
if (a !== original) return "Fail 5: $a !== $original"
|
||||
if (a.x != 10) return "Fail 6: ${a.x} != 10"
|
||||
|
||||
a /= 3
|
||||
if (!(a.identityEquals(original))) return "Fail 7: $a !== $original"
|
||||
if (a !== original) return "Fail 7: $a !== $original"
|
||||
if (a.x != 3) return "Fail 8: ${a.x} != 3"
|
||||
|
||||
a %= 2
|
||||
if (!(a.identityEquals(original))) return "Fail 9: $a !== $original"
|
||||
if (a !== original) return "Fail 9: $a !== $original"
|
||||
if (a.x != 1) return "Fail 10: ${a.x} != 1"
|
||||
|
||||
return "OK"
|
||||
|
||||
@@ -9,12 +9,5 @@ fun box(): String {
|
||||
val x2 = l[0] === l[0]
|
||||
if (!x2) return "Fail 2: $x"
|
||||
|
||||
val y = l[0].identityEquals(1000)
|
||||
if (y) return "Fail (y): $y"
|
||||
val y1 = l[0].identityEquals(1)
|
||||
if (y1) return "Fail (y1): $y"
|
||||
val y2 = l[0].identityEquals(l[0])
|
||||
if (!y2) return "Fail (y2): $y"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
fun box() : String {
|
||||
val a = "lala"
|
||||
if(!a.identityEquals(a)) return "fail 1"
|
||||
if(a.identityEquals(a)) return "OK"
|
||||
if(a !== a) return "fail 1"
|
||||
if(a === a) return "OK"
|
||||
return "fail 2"
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
val f : (Any) -> String = { it.toString() }
|
||||
|
||||
fun box() : String {
|
||||
if(!(f.identityEquals(f))) return "fail 1"
|
||||
if(!(f === f)) return "fail 1"
|
||||
if(!(f == f)) return "fail 2"
|
||||
if(!(f.equals(f))) return "fail 3"
|
||||
return "OK"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
package test
|
||||
|
||||
inline fun <T> doSmth(a: T) : Boolean {
|
||||
return a.identityEquals(a)
|
||||
return a === a
|
||||
}
|
||||
@@ -4,12 +4,12 @@ fun box(): String {
|
||||
val s = arrayOf("live", "long")
|
||||
val t: Array<String> = s.clone()
|
||||
if (!equals(s, t)) return "Fail string"
|
||||
if (s.identityEquals(t)) return "Fail string identity"
|
||||
if (s === t) return "Fail string identity"
|
||||
|
||||
val ss = arrayOf(s, s)
|
||||
val tt: Array<Array<String>> = ss.clone()
|
||||
if (!equals(ss, tt)) return "Fail string[]"
|
||||
if (ss.identityEquals(tt)) return "Fail string[] identity"
|
||||
if (ss === tt) return "Fail string[] identity"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -3,35 +3,35 @@ import java.util.Arrays.equals
|
||||
fun box(): String {
|
||||
val i = intArrayOf(1, 2)
|
||||
if (!equals(i, i.clone())) return "Fail int"
|
||||
if (i.clone().identityEquals(i)) return "Fail int identity"
|
||||
if (i.clone() === i) return "Fail int identity"
|
||||
|
||||
val j = longArrayOf(1L, 2L)
|
||||
if (!equals(j, j.clone())) return "Fail long"
|
||||
if (j.clone().identityEquals(j)) return "Fail long identity"
|
||||
if (j.clone() === j) return "Fail long identity"
|
||||
|
||||
val s = shortArrayOf(1.toShort(), 2.toShort())
|
||||
if (!equals(s, s.clone())) return "Fail short"
|
||||
if (s.clone().identityEquals(s)) return "Fail short identity"
|
||||
if (s.clone() === s) return "Fail short identity"
|
||||
|
||||
val b = byteArrayOf(1.toByte(), 2.toByte())
|
||||
if (!equals(b, b.clone())) return "Fail byte"
|
||||
if (b.clone().identityEquals(b)) return "Fail byte identity"
|
||||
if (b.clone() === b) return "Fail byte identity"
|
||||
|
||||
val c = charArrayOf('a', 'b')
|
||||
if (!equals(c, c.clone())) return "Fail char"
|
||||
if (c.clone().identityEquals(c)) return "Fail char identity"
|
||||
if (c.clone() === c) return "Fail char identity"
|
||||
|
||||
val d = doubleArrayOf(1.0, -1.0)
|
||||
if (!equals(d, d.clone())) return "Fail double"
|
||||
if (d.clone().identityEquals(d)) return "Fail double identity"
|
||||
if (d.clone() === d) return "Fail double identity"
|
||||
|
||||
val f = floatArrayOf(1f, -1f)
|
||||
if (!equals(f, f.clone())) return "Fail float"
|
||||
if (f.clone().identityEquals(f)) return "Fail float identity"
|
||||
if (f.clone() === f) return "Fail float identity"
|
||||
|
||||
val z = booleanArrayOf(true, false)
|
||||
if (!equals(z, z.clone())) return "Fail boolean"
|
||||
if (z.clone().identityEquals(z)) return "Fail boolean identity"
|
||||
if (z.clone() === z) return "Fail boolean identity"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ fun box() : String {
|
||||
|
||||
val y: Int? = 1000
|
||||
val z: Int? = 1000
|
||||
val res = y.identityEquals(z)
|
||||
val res = y === z
|
||||
|
||||
val c1: Any = if (1 == 1) 0 else "abc"
|
||||
val c2: Any = if (1 != 1) 0 else "abc"
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ fun box(): String {
|
||||
}
|
||||
}
|
||||
catch (caught: Throwable) {
|
||||
if (!(caught.identityEquals(e))) return "Fail: $caught"
|
||||
if (caught !== e) return "Fail: $caught"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
|
||||
@@ -8,7 +8,7 @@ fun box(): String {
|
||||
}
|
||||
}
|
||||
catch (caught: Throwable) {
|
||||
if (!(caught.identityEquals(e))) return "Fail: $caught"
|
||||
if (caught !== e) return "Fail: $caught"
|
||||
// If monitorexit didn't happen (a finally block failed), this assertion would fail
|
||||
assertThatThreadDoesNotOwnMonitor(obj)
|
||||
}
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ fun foo() {
|
||||
|
||||
val y: Int? = 7
|
||||
val z: Int? = 8
|
||||
val res = y.identityEquals(z)
|
||||
val res = y === z
|
||||
|
||||
val c1: Any = if (1 == 1) 0 else "abc"
|
||||
val c2: Any = if (1 != 1) 0 else "abc"
|
||||
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
// No supertype at all
|
||||
|
||||
fun Any.extension(<!UNUSED_PARAMETER!>arg<!>: Any?) {}
|
||||
|
||||
class A1 {
|
||||
fun test() {
|
||||
<!SUPER_CANT_BE_EXTENSION_RECEIVER!>super<!>.<!DEPRECATION!>identityEquals<!>(null) // Call to an extension function
|
||||
<!SUPER_CANT_BE_EXTENSION_RECEIVER!>super<!>.extension(null) // Call to an extension function
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -1,5 +1,7 @@
|
||||
package
|
||||
|
||||
public fun kotlin.Any.extension(/*0*/ arg: kotlin.Any?): kotlin.Unit
|
||||
|
||||
public final class A1 {
|
||||
public constructor A1()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
|
||||
Reference in New Issue
Block a user