From 4a8edc03653cb0f6b6ed1cdea1779a19df20f8f5 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 4 Feb 2014 15:55:59 +0100 Subject: SI-8129 Make Object#== override Any#== And the same for != If we tried to declare these signatures in non-fictional classes, we would be chastised about collapsing into the "same signature after erasure". This will have an influence of typing, as the typechecking of arguments is sensitive to overloading: if multiple variants are feasible, the argument will be typechecked with a wildcard expected type. So people inspecting the types of the arguments to `==` before this change might have seen an interesting type for `if (true) x else y`, but now the `If` will have type `Any`, as we don't need to calculate the LUB. I've left a TODO to note that we should really make `Any#{==, !=}` non-final and include a final override in `AnyVal`. But I don't think that is particularly urgent. --- test/files/presentation/visibility.check | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'test/files/presentation/visibility.check') diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check index 217da34b9c..1ae1213f2d 100644 --- a/test/files/presentation/visibility.check +++ b/test/files/presentation/visibility.check @@ -3,7 +3,7 @@ reload: Completions.scala askTypeCompletion at Completions.scala(14,12) ================================================================================ [response] askTypeCompletion at (14,12) -retrieved 37 members +retrieved 35 members [inaccessible] private[this] def secretPrivateThis(): Unit def +(other: String): String def ->[B](y: B): (accessibility.Foo, B) @@ -19,10 +19,8 @@ def someTests(other: accessibility.Foo): Unit def toString(): String def →[B](y: B): (accessibility.Foo, B) final def !=(x$1: Any): Boolean -final def !=(x$1: AnyRef): Boolean final def ##(): Int final def ==(x$1: Any): Boolean -final def ==(x$1: AnyRef): Boolean final def asInstanceOf[T0]: T0 final def eq(x$1: AnyRef): Boolean final def isInstanceOf[T0]: Boolean @@ -43,7 +41,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(16,11) ================================================================================ [response] askTypeCompletion at (16,11) -retrieved 37 members +retrieved 35 members def +(other: String): String def ->[B](y: B): (accessibility.Foo, B) def ensuring(cond: Boolean): accessibility.Foo @@ -58,10 +56,8 @@ def someTests(other: accessibility.Foo): Unit def toString(): String def →[B](y: B): (accessibility.Foo, B) final def !=(x$1: Any): Boolean -final def !=(x$1: AnyRef): Boolean final def ##(): Int final def ==(x$1: Any): Boolean -final def ==(x$1: AnyRef): Boolean final def asInstanceOf[T0]: T0 final def eq(x$1: AnyRef): Boolean final def isInstanceOf[T0]: Boolean @@ -83,7 +79,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(22,11) ================================================================================ [response] askTypeCompletion at (22,11) -retrieved 37 members +retrieved 35 members [inaccessible] private def secretPrivate(): Unit def +(other: String): String def ->[B](y: B): (accessibility.AccessibilityChecks, B) @@ -100,10 +96,8 @@ def someTests: Unit def toString(): String def →[B](y: B): (accessibility.AccessibilityChecks, B) final def !=(x$1: Any): Boolean -final def !=(x$1: AnyRef): Boolean final def ##(): Int final def ==(x$1: Any): Boolean -final def ==(x$1: AnyRef): Boolean final def asInstanceOf[T0]: T0 final def eq(x$1: AnyRef): Boolean final def isInstanceOf[T0]: Boolean @@ -123,7 +117,7 @@ protected[package lang] def finalize(): Unit askTypeCompletion at Completions.scala(28,10) ================================================================================ [response] askTypeCompletion at (28,10) -retrieved 37 members +retrieved 35 members [inaccessible] private def secretPrivate(): Unit [inaccessible] private[this] def secretPrivateThis(): Unit [inaccessible] protected def secretProtected(): Unit @@ -143,10 +137,8 @@ def someTests(other: accessibility.Foo): Unit def toString(): String def →[B](y: B): (accessibility.Foo, B) final def !=(x$1: Any): Boolean -final def !=(x$1: AnyRef): Boolean final def ##(): Int final def ==(x$1: Any): Boolean -final def ==(x$1: AnyRef): Boolean final def asInstanceOf[T0]: T0 final def eq(x$1: AnyRef): Boolean final def isInstanceOf[T0]: Boolean @@ -163,7 +155,7 @@ protected[package accessibility] def secretProtectedInPackage(): Unit askTypeCompletion at Completions.scala(37,8) ================================================================================ [response] askTypeCompletion at (37,8) -retrieved 37 members +retrieved 35 members [inaccessible] private def secretPrivate(): Unit [inaccessible] private[this] def secretPrivateThis(): Unit [inaccessible] protected def secretProtected(): Unit @@ -184,10 +176,8 @@ def someTests(other: accessibility.Foo): Unit def toString(): String def →[B](y: B): (accessibility.Foo, B) final def !=(x$1: Any): Boolean -final def !=(x$1: AnyRef): Boolean final def ##(): Int final def ==(x$1: Any): Boolean -final def ==(x$1: AnyRef): Boolean final def asInstanceOf[T0]: T0 final def eq(x$1: AnyRef): Boolean final def isInstanceOf[T0]: Boolean -- cgit v1.2.3