Skip to content

Commit 28f6c3f

Browse files
Merge pull request #3444 from dotty-staging/fix-#3442
Fix #3442: Make `wait`, `notify` and `notifyAll` final
2 parents 42577bb + d32f223 commit 28f6c3f

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,11 @@ class Definitions {
277277
pt => MethodType(List(pt.paramRefs(0)), pt.paramRefs(0)), Final)
278278
lazy val Object_clone = enterMethod(ObjectClass, nme.clone_, MethodType(Nil, ObjectType), Protected)
279279
lazy val Object_finalize = enterMethod(ObjectClass, nme.finalize_, MethodType(Nil, UnitType), Protected)
280-
lazy val Object_notify = enterMethod(ObjectClass, nme.notify_, MethodType(Nil, UnitType))
281-
lazy val Object_notifyAll = enterMethod(ObjectClass, nme.notifyAll_, MethodType(Nil, UnitType))
282-
lazy val Object_wait = enterMethod(ObjectClass, nme.wait_, MethodType(Nil, UnitType))
283-
lazy val Object_waitL = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: Nil, UnitType))
284-
lazy val Object_waitLI = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: IntType :: Nil, UnitType))
280+
lazy val Object_notify = enterMethod(ObjectClass, nme.notify_, MethodType(Nil, UnitType), Final)
281+
lazy val Object_notifyAll = enterMethod(ObjectClass, nme.notifyAll_, MethodType(Nil, UnitType), Final)
282+
lazy val Object_wait = enterMethod(ObjectClass, nme.wait_, MethodType(Nil, UnitType), Final)
283+
lazy val Object_waitL = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: Nil, UnitType), Final)
284+
lazy val Object_waitLI = enterMethod(ObjectClass, nme.wait_, MethodType(LongType :: IntType :: Nil, UnitType), Final)
285285

286286
def ObjectMethods = List(Object_eq, Object_ne, Object_synchronized, Object_clone,
287287
Object_finalize, Object_notify, Object_notifyAll, Object_wait, Object_waitL, Object_waitLI)

tests/neg/i3442.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Test {
2+
// Any
3+
override def getClass(): Class[_] = ??? // error
4+
override def ==(that: Any): Boolean = ??? // error
5+
override def != (that: Any): Boolean = ??? // error
6+
override def ##(): Int = ??? // error
7+
override def isInstanceOf[T0]: Boolean = ??? // error
8+
override def asInstanceOf[T0]: T0 = ??? // error
9+
10+
// AnyRef
11+
override def eq(that: AnyRef): Boolean = ??? // error
12+
override def ne(that: AnyRef): Boolean = ??? // error
13+
override def notify(): Unit = ??? // error
14+
override def notifyAll(): Unit = ??? // error
15+
override def wait(): Unit = ??? // error
16+
override def wait(timeout: Long, nanos: Int): Unit = ??? // error
17+
override def wait(timeout: Long): Unit = ??? // error
18+
}

0 commit comments

Comments
 (0)