-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Milestone
Description
scala> def f(x: { def clone(): AnyRef }) = x.clone()
<console>:5: error: method clone cannot be accessed in AnyRef{def clone(): AnyRef}
def f(x: { def clone(): AnyRef }) = x.clone()
^
The problem of course is that the access of clone() will be widened to public in any number of AnyRef subclasses, any of which could legally call the method if it would compile.
I can't figure any way to get this signature in. Type alias doesn't get us any closer despite accepting the declaration of a public method:
scala> type FakeClone = { def clone(): AnyRef }
defined type alias FakeClone
scala> def f(x: FakeClone) = x.clone()
<console>:6: error: method clone cannot be accessed in FakeClone
def f(x: FakeClone) = x.clone()
^