From 0e972acf8c013dd940cdb847fbf14dbcfd2545f2 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 3 Feb 2015 18:25:19 +0300 Subject: [PATCH] `==` turned into a safe-call --- .../codegen/intrinsics/IntrinsicMethods.java | 1 - .../org/jetbrains/kotlin/psi/JetPsiFactory.kt | 4 ++ .../jetbrains/kotlin/resolve/TypeResolver.kt | 3 +- .../BasicExpressionTypingVisitor.java | 24 ++++++++++-- compiler/testData/builtin-classes.txt | 1 - .../testData/cfg/conventions/equals.values | 16 ++++---- .../testData/cfg/conventions/notEqual.values | 16 ++++---- compiler/testData/cfg/tailCalls/sum.values | 38 +++++++++---------- .../absentErrorAboutInitializer.kt | 3 +- .../delegatedProperty/absentErrorAboutType.kt | 3 +- .../abstractDelegatedProperty.kt | 3 +- .../tests/delegatedProperty/backingField.kt | 3 +- .../delegatedPropertyOverridedInTrait.kt | 3 +- ...tedPropertyOverridedInTraitTypeMismatch.kt | 3 +- .../tests/delegatedProperty/genericGetter.kt | 5 ++- .../delegatedProperty/getterWithSubtype.kt | 3 +- .../tests/delegatedProperty/inTrait.kt | 3 +- .../incompleteTypeInference.kt | 3 +- .../tests/delegatedProperty/localVariable.kt | 5 ++- .../tests/delegatedProperty/missedSetter.kt | 3 +- .../delegatedProperty/propertyDefferedType.kt | 7 ++-- .../propertyDelegatedAmbiguity.kt | 11 ++---- .../propertyDelegatedIncomplete.kt | 7 ++-- .../propertyDelegatedMissing.kt | 3 +- .../propertyDelegatedPrivate.kt | 7 ++-- .../propertyDelegatedWrongArguments.kt | 15 +++----- .../publicDelegatedProperty.kt | 3 +- .../tests/delegatedProperty/recursiveType.kt | 5 ++- .../delegatedProperty/redundantGetter.kt | 3 +- .../delegatedProperty/redundantSetter.kt | 7 ++-- .../setterThisTypeMismatch.kt | 8 ++-- .../delegatedProperty/setterWithSupertype.kt | 8 ++-- .../tests/delegatedProperty/thisInDelegate.kt | 5 ++- .../tests/delegatedProperty/thisOfAnyType.kt | 8 ++-- .../typeMismatchForGetReturnType.kt | 3 +- .../typeMismatchForSetParameter.kt | 8 ++-- .../wrongCountOfParametersInGet.kt | 3 +- .../wrongCountOfParametersInSet.kt | 8 ++-- .../wrongSetterReturnType.kt | 4 +- .../tests/extensions/ExtensionFunctions.kt | 2 +- .../duplicateClass/collectionMethodStub.txt | 1 - .../diagnostics/tests/regressions/kt127.kt | 4 +- .../diagnostics/tests/regressions/kt127.txt | 1 - .../diagnostics/tests/regressions/kt860.txt | 1 - .../kotlin/codegen/FunctionGenTest.java | 2 +- core/builtins/native/kotlin/Library.kt | 7 ---- idea/testData/checker/ExtensionFunctions.kt | 2 +- .../expressions/conventions/equals.kt | 1 + .../expressions/conventions/equals.kt.match | 2 +- .../explicitEqualsMethodForPrimitives.kt | 2 +- 50 files changed, 149 insertions(+), 142 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java index 1352680dbfc..5517ae1f28d 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/intrinsics/IntrinsicMethods.java @@ -118,7 +118,6 @@ public class IntrinsicMethods { declareIntrinsicFunction("Cloneable", "clone", 0, CLONE); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KOTLIN_ANY_FQ_NAME, "toString", 0, TO_STRING); - intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KOTLIN_ANY_FQ_NAME, "equals", 1, EQUALS); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KOTLIN_ANY_FQ_NAME, "identityEquals", 1, IDENTITY_EQUALS); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KOTLIN_STRING_FQ_NAME, "plus", 1, STRING_PLUS); intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOfNulls", 1, new NewArray()); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt index d0a37e435ad..618d439861e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/JetPsiFactory.kt @@ -54,6 +54,10 @@ public class JetPsiFactory(private val project: Project) { return createParameterList("($text int x)").getParameters().first().getValOrVarNode()!! } + public fun createSafeCallNode(): ASTNode { + return (createExpression("a?.b") as JetSafeQualifiedExpression).getOperationTokenNode() + } + public fun createExpression(text: String): JetExpression { return createProperty("val x = $text").getInitializer()!! } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 98b3cc05674..19ca2983848 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.context.LazinessToken import org.jetbrains.kotlin.resolve.lazy.LazyEntity import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull +import org.jetbrains.kotlin.psi.debugText.getDebugText public class TypeResolver( private val annotationResolver: AnnotationResolver, @@ -237,7 +238,7 @@ public class TypeResolver( c.trace.report(UNSUPPORTED.on(element, "Self-types are not supported yet")) } }) - return result ?: type(ErrorUtils.createErrorType(typeElement?.getText() ?: "No type element")) + return result ?: type(ErrorUtils.createErrorType(typeElement?.getDebugText() ?: "No type element")) } private fun getScopeForTypeParameter(c: TypeResolutionContext, typeParameterDescriptor: TypeParameterDescriptor): JetScope { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index 8492938bcc1..96dc5970987 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -932,7 +932,6 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { ExpressionTypingUtils.getTypeInfoOrNullType(left, context, facade); return JetTypeInfo.create(components.builtIns.getBooleanType(), dataFlowInfo); } - ExpressionReceiver receiver = ExpressionTypingUtils.safeGetExpressionReceiver(facade, left, context); JetTypeInfo leftTypeInfo = getTypeInfoOrNullType(left, context, facade); @@ -946,16 +945,30 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { context.trace, "trace to resolve 'equals(Any?)' interpreting as of type Any? an expression:", right); traceInterpretingRightAsNullableAny.record(EXPRESSION_TYPE, right, components.builtIns.getNullableAnyType()); - Call call = CallMaker.makeCallWithExpressions(expression, receiver, null, operationSign, Collections.singletonList(right)); + // Nothing? has no members, and `equals()` would be unresolved on it + JetType leftType = leftTypeInfo.getType(); + if (leftType != null && KotlinBuiltIns.isNothingOrNullableNothing(leftType)) { + traceInterpretingRightAsNullableAny.record(EXPRESSION_TYPE, left, components.builtIns.getNullableAnyType()); + } + ExpressionTypingContext newContext = context.replaceBindingTrace(traceInterpretingRightAsNullableAny); + ExpressionReceiver receiver = ExpressionTypingUtils.safeGetExpressionReceiver(facade, left, newContext); + Call call = CallMaker.makeCallWithExpressions( + expression, + receiver, + // semantically, a call to `==` is a safe call + new JetPsiFactory(expression.getProject()).createSafeCallNode(), + operationSign, + Collections.singletonList(right) + ); OverloadResolutionResults resolutionResults = components.callResolver.resolveCallWithGivenName(newContext, call, operationSign, OperatorConventions.EQUALS); traceInterpretingRightAsNullableAny.commit(new TraceEntryFilter() { @Override public boolean accept(@Nullable WritableSlice slice, Object key) { - // the type of the right expression isn't 'Any?' actually - if (key == right && slice == EXPRESSION_TYPE) return false; + // the type of the right (and sometimes left) expression isn't 'Any?' actually + if ((key == right || key == left) && slice == EXPRESSION_TYPE) return false; // a hack due to KT-678 // without this line an smartcast is reported on the receiver (if it was previously checked for not-null) @@ -1154,6 +1167,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { else if (nullability == Nullability.NOT_NULL) { expressionIsAlways = !equality; } + else if (nullability == Nullability.IMPOSSIBLE) { + expressionIsAlways = false; + } else return; context.trace.report(SENSELESS_COMPARISON.on(expression, expression, expressionIsAlways)); diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index afde674b374..1e74eab1c83 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -1,7 +1,6 @@ package-fragment kotlin public fun arrayOfNulls(/*0*/ size: kotlin.Int): kotlin.Array -public fun kotlin.Any?.equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public fun kotlin.Any?.identityEquals(/*0*/ other: kotlin.Any?): kotlin.Boolean public fun kotlin.String?.plus(/*0*/ other: kotlin.Any?): kotlin.String public fun kotlin.Any?.toString(): kotlin.String diff --git a/compiler/testData/cfg/conventions/equals.values b/compiler/testData/cfg/conventions/equals.values index de40507fc65..3b22f76bb71 100644 --- a/compiler/testData/cfg/conventions/equals.values +++ b/compiler/testData/cfg/conventions/equals.values @@ -4,12 +4,12 @@ fun foo(a: Int, b: Int) { } } --------------------- - : Int NEW: magic[FAKE_INITIALIZER](a: Int) -> - : Int NEW: magic[FAKE_INITIALIZER](b: Int) -> -a : OR{{<: Any}, {<: Any}} NEW: r(a) -> -b : * NEW: r(b) -> -a == b : Boolean NEW: call(a == b, equals|, ) -> -{ } !: * -if (a == b) { } : * NEW: merge(if (a == b) { }|!) -> -{ if (a == b) { } } : * COPY + : Int NEW: magic[FAKE_INITIALIZER](a: Int) -> + : Int NEW: magic[FAKE_INITIALIZER](b: Int) -> +a : OR{*, *} NEW: r(a) -> +b : * NEW: r(b) -> +a == b : Boolean NEW: call(a == b, equals|, ) -> +{ } !: * +if (a == b) { } : * NEW: merge(if (a == b) { }|!) -> +{ if (a == b) { } } : * COPY ===================== diff --git a/compiler/testData/cfg/conventions/notEqual.values b/compiler/testData/cfg/conventions/notEqual.values index 5f7d31efe10..0fb6d1e532d 100644 --- a/compiler/testData/cfg/conventions/notEqual.values +++ b/compiler/testData/cfg/conventions/notEqual.values @@ -3,12 +3,12 @@ fun neq(a: Int, b: Int) { if (a != b) {} } --------------------- - : Int NEW: magic[FAKE_INITIALIZER](a: Int) -> - : Int NEW: magic[FAKE_INITIALIZER](b: Int) -> -a : OR{{<: Any}, {<: Any}} NEW: r(a) -> -b : * NEW: r(b) -> -a != b : Boolean NEW: call(a != b, equals|, ) -> -{} !: * -if (a != b) {} : * NEW: merge(if (a != b) {}|!) -> -{ if (a != b) {} } : * COPY + : Int NEW: magic[FAKE_INITIALIZER](a: Int) -> + : Int NEW: magic[FAKE_INITIALIZER](b: Int) -> +a : OR{*, *} NEW: r(a) -> +b : * NEW: r(b) -> +a != b : Boolean NEW: call(a != b, equals|, ) -> +{} !: * +if (a != b) {} : * NEW: merge(if (a != b) {}|!) -> +{ if (a != b) {} } : * COPY ===================== diff --git a/compiler/testData/cfg/tailCalls/sum.values b/compiler/testData/cfg/tailCalls/sum.values index 429b1f8d430..0970e6e57cf 100644 --- a/compiler/testData/cfg/tailCalls/sum.values +++ b/compiler/testData/cfg/tailCalls/sum.values @@ -4,23 +4,23 @@ tailRecursive fun sum(x: Long, sum: Long): Long { return sum(x - 1, sum + x) } --------------------- - : Long NEW: magic[FAKE_INITIALIZER](x: Long) -> - : Long NEW: magic[FAKE_INITIALIZER](sum: Long) -> -x : OR{{<: Any}, {<: Any}} NEW: r(x) -> -0 : {<: Number} NEW: r(0) -> -toLong() : * NEW: call(toLong(), toLong|) -> -0.toLong() : * COPY -x == 0.toLong() : Boolean NEW: call(x == 0.toLong(), equals|, ) -> -sum : Long NEW: r(sum) -> -return sum !: * -if (x == 0.toLong()) return sum : * NEW: merge(if (x == 0.toLong()) return sum|!) -> -x : Long NEW: r(x) -> -1 : Int NEW: r(1) -> -x - 1 : Long NEW: call(x - 1, minus|, ) -> -sum : Long NEW: r(sum) -> -x : Long NEW: r(x) -> -sum + x : Long NEW: call(sum + x, plus|, ) -> -sum(x - 1, sum + x) : Long NEW: call(sum(x - 1, sum + x), sum|, ) -> -return sum(x - 1, sum + x) !: * -{ if (x == 0.toLong()) return sum return sum(x - 1, sum + x) } !: * COPY + : Long NEW: magic[FAKE_INITIALIZER](x: Long) -> + : Long NEW: magic[FAKE_INITIALIZER](sum: Long) -> +x : OR{*, *} NEW: r(x) -> +0 : {<: Number} NEW: r(0) -> +toLong() : * NEW: call(toLong(), toLong|) -> +0.toLong() : * COPY +x == 0.toLong() : Boolean NEW: call(x == 0.toLong(), equals|, ) -> +sum : Long NEW: r(sum) -> +return sum !: * +if (x == 0.toLong()) return sum : * NEW: merge(if (x == 0.toLong()) return sum|!) -> +x : Long NEW: r(x) -> +1 : Int NEW: r(1) -> +x - 1 : Long NEW: call(x - 1, minus|, ) -> +sum : Long NEW: r(sum) -> +x : Long NEW: r(x) -> +sum + x : Long NEW: call(sum + x, plus|, ) -> +sum(x - 1, sum + x) : Long NEW: call(sum(x - 1, sum + x), sum|, ) -> +return sum(x - 1, sum + x) !: * +{ if (x == 0.toLong()) return sum return sum(x - 1, sum + x) } !: * COPY ===================== diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutInitializer.kt b/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutInitializer.kt index c4a8ceb461a..d56d33c1af0 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutInitializer.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutInitializer.kt @@ -1,8 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutType.kt index 876c6a2b393..760ab8e50fd 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/absentErrorAboutType.kt @@ -1,8 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/abstractDelegatedProperty.kt b/compiler/testData/diagnostics/tests/delegatedProperty/abstractDelegatedProperty.kt index 55f972067fb..0a1ca6f1e35 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/abstractDelegatedProperty.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/abstractDelegatedProperty.kt @@ -1,10 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + abstract class A { abstract val a: Int by Delegate() } class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/backingField.kt b/compiler/testData/diagnostics/tests/delegatedProperty/backingField.kt index 45a8e7a63a3..e0cec2e9e6a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/backingField.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/backingField.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + class B { val a: Int by Delegate() @@ -6,7 +8,6 @@ class B { class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTrait.kt b/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTrait.kt index 6c509dfb99a..4ec29930810 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTrait.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTrait.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + trait A { val prop: Int } @@ -12,7 +14,6 @@ fun foo() { class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTraitTypeMismatch.kt b/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTraitTypeMismatch.kt index 487c9246821..236edfde773 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTraitTypeMismatch.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/delegatedPropertyOverridedInTraitTypeMismatch.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + trait A { val prop: Int } @@ -12,7 +14,6 @@ fun foo() { class Delegate { fun get(t: Any?, p: PropertyMetadata): String { - t.equals(p) // to avoid UNUSED_PARAMETER warning return "" } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/genericGetter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/genericGetter.kt index 70d71499100..7ee6c7dc4de 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/genericGetter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/genericGetter.kt @@ -1,8 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a: Int by A(1) -class A(i: T) { +class A(i: T) { fun get(t: Any?, p: PropertyMetadata): T { - t.equals(p) // to avoid UNUSED_PARAMETER warning throw Exception() } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/getterWithSubtype.kt b/compiler/testData/diagnostics/tests/delegatedProperty/getterWithSubtype.kt index 93b071a60b9..756889d733a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/getterWithSubtype.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/getterWithSubtype.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + open class Base class Derived: Base() @@ -5,7 +7,6 @@ val a: Base by A() class A { fun get(t: Any?, p: PropertyMetadata): Derived { - t.equals(p) // to avoid UNUSED_PARAMETER warning return Derived() } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inTrait.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inTrait.kt index cf0d84e4168..fb10ae2726f 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/inTrait.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inTrait.kt @@ -1,10 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + trait T { val a: Int by Delegate() } class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt b/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt index 98b0efe3e83..fb0c7b38abc 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/incompleteTypeInference.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + class A class D { @@ -8,7 +10,6 @@ val cTopLevel: Int by IncorrectThis() class IncorrectThis { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/localVariable.kt b/compiler/testData/diagnostics/tests/delegatedProperty/localVariable.kt index 2091e93b649..7352e77f641 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/localVariable.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/localVariable.kt @@ -1,12 +1,13 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + class Local { fun foo() { - val a: Int by Delegate() + val a: Int by Delegate() } } class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/missedSetter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/missedSetter.kt index fb0eadce7e4..3efd4a7873b 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/missedSetter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/missedSetter.kt @@ -1,8 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + var a: Int by A() class A { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.kt index ce3cca3e744..088955a611d 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDefferedType.kt @@ -1,10 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + class B { val c by Delegate(ag) } class Delegate(val init: T) { - fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning - throw Exception() - } + fun get(t: Any?, p: PropertyMetadata): Int = null!! } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedAmbiguity.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedAmbiguity.kt index 0c0e737eb71..9c4bb73ae49 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedAmbiguity.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedAmbiguity.kt @@ -1,16 +1,13 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun propertyDelegated(p: PropertyMetadata) { - p.equals(p) - } + fun propertyDelegated(p: PropertyMetadata) {} - fun propertyDelegated(p: PropertyMetadata, s: String = "") { - p.equals(s) - } + fun propertyDelegated(p: PropertyMetadata, s: String = "") {} } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedIncomplete.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedIncomplete.kt index 85ad8005d42..0b8c29f0314 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedIncomplete.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedIncomplete.kt @@ -1,12 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun propertyDelegated(p: PropertyMetadata) { - p.equals(p) - } + fun propertyDelegated(p: PropertyMetadata) {} } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedMissing.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedMissing.kt index b57b29014ec..071c0ca7451 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedMissing.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedMissing.kt @@ -1,8 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedPrivate.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedPrivate.kt index fc4e108a60e..9fa1dd18cdd 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedPrivate.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedPrivate.kt @@ -1,12 +1,11 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - private fun propertyDelegated(p: PropertyMetadata) { - p.equals(p) - } + private fun propertyDelegated(p: PropertyMetadata) {} } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedWrongArguments.kt b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedWrongArguments.kt index 1a9516e4e8c..5dadd738407 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedWrongArguments.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/propertyDelegatedWrongArguments.kt @@ -1,22 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } fun propertyDelegated() {} - fun propertyDelegated(a: Int) { - a.equals(a) - } + fun propertyDelegated(a: Int) {} - fun propertyDelegated(a: String) { - a.equals(a) - } + fun propertyDelegated(a: String) {} - fun propertyDelegated(p: PropertyMetadata, a: Int) { - p.equals(a) - } + fun propertyDelegated(p: PropertyMetadata, a: Int) {} } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/publicDelegatedProperty.kt b/compiler/testData/diagnostics/tests/delegatedProperty/publicDelegatedProperty.kt index b29e03bb054..b1e06296861 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/publicDelegatedProperty.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/publicDelegatedProperty.kt @@ -1,8 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + public val a by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt index a6701806a31..68acb20bcc5 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/recursiveType.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a by a val b by Delegate(b) @@ -5,9 +7,8 @@ val b by Delegate(b) val c by d val d by c -class Delegate(i: Int) { +class Delegate(i: Int) { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/redundantGetter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/redundantGetter.kt index 2d4a883ffb7..e5b493cc00a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/redundantGetter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/redundantGetter.kt @@ -1,9 +1,10 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val a: Int by Delegate() get() = 1 class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/redundantSetter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/redundantSetter.kt index 0fd4a41b87f..7d9baba771e 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/redundantSetter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/redundantSetter.kt @@ -1,14 +1,13 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + var a: Int by Delegate() get() = 1 set(i) {} class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: PropertyMetadata, i: Int) { - t.equals(p) || i.equals(null) // to avoid UNUSED_PARAMETER warning - } + fun set(t: Any?, p: PropertyMetadata, i: Int) {} } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt b/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt index 458eb6d0d4e..ce3c7608672 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/setterThisTypeMismatch.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + class D { var c: Int by Delegate() } @@ -8,11 +10,7 @@ class A class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: A, p: PropertyMetadata, i: Int) { - t.equals(p) // to avoid UNUSED_PARAMETER warning - i.equals(null) - } + fun set(t: A, p: PropertyMetadata, i: Int) {} } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/setterWithSupertype.kt b/compiler/testData/diagnostics/tests/delegatedProperty/setterWithSupertype.kt index 3d2d00e3242..0c186aea2e9 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/setterWithSupertype.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/setterWithSupertype.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + open class Base class Derived: Base() @@ -5,13 +7,9 @@ var a: Derived by A() class A { fun get(t: Any?, p: PropertyMetadata): Derived { - t.equals(p) // to avoid UNUSED_PARAMETER warning return Derived() } - fun set(t: Any?, p: PropertyMetadata, i: Base) { - t.equals(p) // to avoid UNUSED_PARAMETER warning - i.equals(null) // to avoid UNUSED_PARAMETER warning - } + fun set(t: Any?, p: PropertyMetadata, i: Base) {} } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisInDelegate.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisInDelegate.kt index 4c8e7b57060..80a7b8d9679 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisInDelegate.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisInDelegate.kt @@ -1,12 +1,13 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val Int.a by Delegate(this) class A { val Int.a by Delegate(this) } -class Delegate(i: Int) { +class Delegate(i: Int) { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfAnyType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfAnyType.kt index d56376db4f0..1f1789bf64a 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/thisOfAnyType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/thisOfAnyType.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + class A { var a: Int by Delegate() } @@ -6,11 +8,7 @@ var aTopLevel: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: PropertyMetadata, a: Int) { - t.equals(p) // to avoid UNUSED_PARAMETER warning - a.equals(null) - } + fun set(t: Any?, p: PropertyMetadata, a: Int) {} } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt index 4fcbbc24737..be2f06d1161 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForGetReturnType.kt @@ -1,8 +1,9 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + val c: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): String { - t.equals(p) // to avoid UNUSED_PARAMETER warning return "" } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt index 0928ba015b8..7ea01f408ff 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/typeMismatchForSetParameter.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + class A { var a: Int by Delegate() } @@ -6,11 +8,7 @@ var aTopLevel: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: PropertyMetadata, i: String) { - t.equals(p) // to avoid UNUSED_PARAMETER warning - i.equals(null) - } + fun set(t: Any?, p: PropertyMetadata, i: String) {} } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.kt b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.kt index 520af500155..384a0fedf21 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInGet.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + class A { val a: Int by Delegate() } @@ -6,7 +8,6 @@ val aTopLevel: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata, a: Int): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return a } } diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInSet.kt b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInSet.kt index 2f013451201..39bddd0ac56 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInSet.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/wrongCountOfParametersInSet.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + class A { var a: Int by Delegate() } @@ -6,12 +8,8 @@ var aTopLevel: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } - fun set(t: Any?, p: PropertyMetadata, a: Int, c: Int) { - t.equals(p) // to avoid UNUSED_PARAMETER warning - c.equals(a) - } + fun set(t: Any?, p: PropertyMetadata, a: Int, c: Int) {} } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/wrongSetterReturnType.kt b/compiler/testData/diagnostics/tests/delegatedProperty/wrongSetterReturnType.kt index 0238a1c5560..fdee6cf5874 100644 --- a/compiler/testData/diagnostics/tests/delegatedProperty/wrongSetterReturnType.kt +++ b/compiler/testData/diagnostics/tests/delegatedProperty/wrongSetterReturnType.kt @@ -1,13 +1,13 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + var b: Int by Delegate() class Delegate { fun get(t: Any?, p: PropertyMetadata): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return 1 } fun set(t: Any?, p: PropertyMetadata, i: Int): Int { - t.equals(p) // to avoid UNUSED_PARAMETER warning return i } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt index 7c6bf288f21..465f51d0202 100644 --- a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt +++ b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt @@ -63,7 +63,7 @@ import outer.* command.foo - command.equals(null) + command.equals(null) command?.equals(null) command.equals1(null) command?.equals1(null) diff --git a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/collectionMethodStub.txt b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/collectionMethodStub.txt index c52a65af515..384cb0e6cd1 100644 --- a/compiler/testData/diagnostics/tests/multimodule/duplicateClass/collectionMethodStub.txt +++ b/compiler/testData/diagnostics/tests/multimodule/duplicateClass/collectionMethodStub.txt @@ -12,7 +12,6 @@ internal final class C : kotlin.MutableIterator { package kotlin { public fun arrayOfNulls(/*0*/ size: kotlin.Int): kotlin.Array - public fun kotlin.Any?.equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public fun kotlin.Any?.identityEquals(/*0*/ other: kotlin.Any?): kotlin.Boolean public fun kotlin.String?.plus(/*0*/ other: kotlin.Any?): kotlin.String public fun kotlin.Any?.toString(): kotlin.String diff --git a/compiler/testData/diagnostics/tests/regressions/kt127.kt b/compiler/testData/diagnostics/tests/regressions/kt127.kt index 6db510b9cf8..2f562c64e0e 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt127.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt127.kt @@ -2,7 +2,6 @@ class Foo() {} -fun Any.equals(other : Any?) : Boolean = true fun Any?.equals1(other : Any?) : Boolean = true fun main(args: Array) { @@ -14,5 +13,6 @@ fun main(args: Array) { // .equals(null) => 1; // must be resolved // ?.equals(null) => 1 // same here // } - command.equals(null) + command.equals1(null) + command?.equals(null) } diff --git a/compiler/testData/diagnostics/tests/regressions/kt127.txt b/compiler/testData/diagnostics/tests/regressions/kt127.txt index 6a1696affd5..6818f0cfa6a 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt127.txt +++ b/compiler/testData/diagnostics/tests/regressions/kt127.txt @@ -1,7 +1,6 @@ package internal fun main(/*0*/ args: kotlin.Array): kotlin.Unit -internal fun kotlin.Any.equals(/*0*/ other: kotlin.Any?): kotlin.Boolean internal fun kotlin.Any?.equals1(/*0*/ other: kotlin.Any?): kotlin.Boolean internal final class Foo { diff --git a/compiler/testData/diagnostics/tests/regressions/kt860.txt b/compiler/testData/diagnostics/tests/regressions/kt860.txt index dc438ce3336..88a5b0e78db 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt860.txt +++ b/compiler/testData/diagnostics/tests/regressions/kt860.txt @@ -2,7 +2,6 @@ package package kotlin { public fun arrayOfNulls(/*0*/ size: kotlin.Int): kotlin.Array - public fun kotlin.Any?.equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public fun kotlin.Any?.identityEquals(/*0*/ other: kotlin.Any?): kotlin.Boolean public fun kotlin.String?.plus(/*0*/ other: kotlin.Any?): kotlin.String public fun kotlin.Any?.toString(): kotlin.String diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/FunctionGenTest.java b/compiler/tests/org/jetbrains/kotlin/codegen/FunctionGenTest.java index 1457f131e73..de9a043e702 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/FunctionGenTest.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/FunctionGenTest.java @@ -30,7 +30,7 @@ public class FunctionGenTest extends CodegenTestCase { } public void testAnyEqualsNullable() throws InvocationTargetException, IllegalAccessException { - loadText("fun foo(x: Any?) = x.equals(\"lala\")"); + loadText("fun foo(x: Any?) = x?.equals(\"lala\")"); Method foo = generateFunction(); assertTrue((Boolean) foo.invoke(null, "lala")); assertFalse((Boolean) foo.invoke(null, "mama")); diff --git a/core/builtins/native/kotlin/Library.kt b/core/builtins/native/kotlin/Library.kt index 2d1a9d4adbe..fc8b3d1ee75 100644 --- a/core/builtins/native/kotlin/Library.kt +++ b/core/builtins/native/kotlin/Library.kt @@ -22,13 +22,6 @@ package kotlin */ public fun Any?.identityEquals(other: Any?): Boolean // = this === other -/** - * Returns true if the receiver and the [other] object are "equal" to each other, or if they are - * both null. - * @see Any.equals - */ -public fun Any?.equals(other: Any?): Boolean - /** * Returns a string representation of the object. Can be called with a null receiver, in which case * it returns the string "null". diff --git a/idea/testData/checker/ExtensionFunctions.kt b/idea/testData/checker/ExtensionFunctions.kt index 3f4cf4ae19f..a4005739317 100644 --- a/idea/testData/checker/ExtensionFunctions.kt +++ b/idea/testData/checker/ExtensionFunctions.kt @@ -58,7 +58,7 @@ fun Int.foo() = this command.foo - command.equals(null) + command.equals(null) command?.equals(null) command.equals1(null) command?.equals1(null) diff --git a/idea/testData/unifier/equivalence/expressions/conventions/equals.kt b/idea/testData/unifier/equivalence/expressions/conventions/equals.kt index 6f6868902c0..a0fb9fc3902 100644 --- a/idea/testData/unifier/equivalence/expressions/conventions/equals.kt +++ b/idea/testData/unifier/equivalence/expressions/conventions/equals.kt @@ -1,5 +1,6 @@ val a = 1 == 2 val b = 1.equals(2) +val b1 = 1?.equals(2) val c = 2.equals(1) val d = 1 === 2 val e = 1 != 2 diff --git a/idea/testData/unifier/equivalence/expressions/conventions/equals.kt.match b/idea/testData/unifier/equivalence/expressions/conventions/equals.kt.match index 3b19de2b4be..6687df49be3 100644 --- a/idea/testData/unifier/equivalence/expressions/conventions/equals.kt.match +++ b/idea/testData/unifier/equivalence/expressions/conventions/equals.kt.match @@ -1,3 +1,3 @@ 1 == 2 -1.equals(2) \ No newline at end of file +1?.equals(2) \ No newline at end of file diff --git a/js/js.translator/testData/expression/equals/cases/explicitEqualsMethodForPrimitives.kt b/js/js.translator/testData/expression/equals/cases/explicitEqualsMethodForPrimitives.kt index f1cd5e93748..cfd966333ac 100644 --- a/js/js.translator/testData/expression/equals/cases/explicitEqualsMethodForPrimitives.kt +++ b/js/js.translator/testData/expression/equals/cases/explicitEqualsMethodForPrimitives.kt @@ -7,7 +7,7 @@ fun box(): Boolean { if (!(a equals 2.0)) return false val c = "a" if (!("a" equals c)) return false - if (!(null equals null)) return false + if (!((null : Any?)?.equals(null) ?: true)) return false val d = 5.6 if (!(d.toShort() equals 5.toShort())) return false if (!(d.toByte() equals 5.toByte())) return false