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

private members create mixin order dependency #7699

Closed
scabug opened this issue Jul 27, 2013 · 5 comments
Closed

private members create mixin order dependency #7699

scabug opened this issue Jul 27, 2013 · 5 comments

Comments

@scabug
Copy link

scabug commented Jul 27, 2013

Not only does it fail, but there is nothing which can be done in Y2 (e.g. overriding to resolve the ambiguity, even though neither m should even be inherited in Y2, let alone overridable) to make it compile. This is among the consequences of refusing to fix #2568.

package s {
  trait B1 { private val m = "B1" }
  trait B2 { private[s] val m = "B2" }
}
class Y1 extends s.B1 with s.B2  // compiles
class Y2 extends s.B2 with s.B1  // fails

// ./a.scala:6: error: overriding value m in trait B2 of type String;
//  value m in trait B1 of type String has weaker access privileges; it should not be private
// class Y2 extends s.B2 with s.B1  // fails
//       ^
// one error found
@scabug
Copy link
Author

scabug commented Jul 27, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7699?orig=1
Reporter: @paulp
See #2568, #7475

@scabug
Copy link
Author

scabug commented Jul 27, 2013

@paulp said:
Note that if both are private, it compiles. If both are private[s], it fails, but at least it fails understandably and in a way which can be resolved (though the failure to compile is still a bug if the specification is supposed to have any relevance.)

./a.scala:5: error: class Y1 inherits conflicting members:
  value m in trait B1 of type String  and
  value m in trait B2 of type String
(Note: this can be resolved by declaring an override in class Y1.)
class Y1 extends s.B1 with s.B2  // compiles
      ^

@scabug
Copy link
Author

scabug commented Jul 28, 2013

@retronym said:
Possibly related to #7475

@scabug
Copy link
Author

scabug commented Jul 28, 2013

@paulp said:
They are related, but what's at issue here is that we don't mangle package-private or object-private members at all, which means they are not private. In #7475 it is attempting to do the right thing by mangling the private member, but the implementation has bugs -- whereas here we are not even trying to do the right thing.

package s {
  object o {
    trait A {
      private[this] val m1 = 1
      private       val m2 = 2
      private[A]    val m3 = 3
      private[o]    val m4 = 4
      private[s]    val m5 = 5
    }
    // Here is what that produces:
    // public abstract int s$o$A$$m1();
    // public abstract int s$o$A$$m2();
    // public abstract int s$o$A$$m3();
    // public abstract int m4();
    // public abstract int m5();
  }
}

@scabug
Copy link
Author

scabug commented Jan 27, 2014

@adriaanm said:
Duplicate of #261

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