Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Widening 'protected' to 'public' members does not work #6760

Open
scabug opened this issue Dec 4, 2012 · 2 comments
Open

Widening 'protected' to 'public' members does not work #6760

scabug opened this issue Dec 4, 2012 · 2 comments

Comments

@scabug
Copy link

scabug commented Dec 4, 2012

I tried hard to find a ticket for this, as I'd be surprised not to have one already. I found related tickets #1352 and #1994, but not exactly this one.

See related IDE ticket #1000758

// WithClone.java
package test;

public abstract class WithClone {
  public abstract Object clone();
}
// Use.scala
import test.WithClone

class Foo {
 def test(x: WithClone) {
   x.clone() 
 }
}

results in

se.scala:5: error: method clone in class Object cannot be accessed in test.WithClone
 Access to protected method clone not permitted because
 prefix type test.WithClone does not conform to
 class Foo where the access take place
   x.clone() 
     ^
one error found
@scabug
Copy link
Author

scabug commented Dec 4, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6760?orig=1
Reporter: @dragos
Affected Versions: 2.8.0, 2.9.0, 2.10.0

@scabug
Copy link
Author

scabug commented Jun 3, 2013

@retronym said:
In Scala concrete members always override abstract members.

scala> class Derived { def clone: AnyRef }
<console>:7: error: overriding method clone in class Derived of type ()AnyRef;
 method clone in class Object of type ()Object has weaker access privileges; it should be public;
 (Note that method clone in class Derived of type ()AnyRef is abstract,
  and is therefore overridden by concrete method clone in class Object of type ()Object)
       class Derived { def clone: AnyRef }
             ^

Here's a quick attempt to use Java rules for Java defined methods:

https://github.com/retronym/scala/compare/ticket/6760

I still need to exercise it with some more tests and run it past Martin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant