Skip to content

Commit 3bdef03

Browse files
committed
Merge pull request scala#4772 from vjovanov/documentation/universal
Fixing signatures of universal methods on `Any` and `AnyRef`.
2 parents 3d15ba0 + 88ed763 commit 3bdef03

File tree

2 files changed

+8
-17
lines changed

2 files changed

+8
-17
lines changed

src/library-aux/scala/Any.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ abstract class Any {
7777
*
7878
* @return a class object corresponding to the runtime type of the receiver.
7979
*/
80-
def getClass(): Class[_]
80+
final def getClass(): Class[_] = sys.error("getClass")
8181

8282
/** Test two objects for equality.
8383
* The expression `x == that` is equivalent to `if (x eq null) that eq null else x.equals(that)`.
@@ -116,7 +116,7 @@ abstract class Any {
116116
*
117117
* @return `true` if the receiver object is an instance of erasure of type `T0`; `false` otherwise.
118118
*/
119-
def isInstanceOf[T0]: Boolean = sys.error("isInstanceOf")
119+
final def isInstanceOf[T0]: Boolean = sys.error("isInstanceOf")
120120

121121
/** Cast the receiver object to be of type `T0`.
122122
*
@@ -129,5 +129,5 @@ abstract class Any {
129129
* @throws ClassCastException if the receiver object is not an instance of the erasure of type `T0`.
130130
* @return the receiver object.
131131
*/
132-
def asInstanceOf[T0]: T0 = sys.error("asInstanceOf")
132+
final def asInstanceOf[T0]: T0 = sys.error("asInstanceOf")
133133
}

src/library-aux/scala/AnyRef.scala

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,33 +100,24 @@ trait AnyRef extends Any {
100100
*/
101101
protected def finalize(): Unit
102102

103-
/** A representation that corresponds to the dynamic class of the receiver object.
104-
*
105-
* The nature of the representation is platform dependent.
106-
*
107-
* @note not specified by SLS as a member of AnyRef
108-
* @return a representation that corresponds to the dynamic class of the receiver object.
109-
*/
110-
def getClass(): Class[_]
111-
112103
/** Wakes up a single thread that is waiting on the receiver object's monitor.
113104
*
114105
* @note not specified by SLS as a member of AnyRef
115106
*/
116-
def notify(): Unit
107+
final def notify(): Unit
117108

118109
/** Wakes up all threads that are waiting on the receiver object's monitor.
119110
*
120111
* @note not specified by SLS as a member of AnyRef
121112
*/
122-
def notifyAll(): Unit
113+
final def notifyAll(): Unit
123114

124115
/** Causes the current Thread to wait until another Thread invokes
125116
* the notify() or notifyAll() methods.
126117
*
127118
* @note not specified by SLS as a member of AnyRef
128119
*/
129-
def wait (): Unit
130-
def wait (timeout: Long, nanos: Int): Unit
131-
def wait (timeout: Long): Unit
120+
final def wait (): Unit
121+
final def wait (timeout: Long, nanos: Int): Unit
122+
final def wait (timeout: Long): Unit
132123
}

0 commit comments

Comments
 (0)