Skip to content

Overriding protected trait method in anonymous class keeps it protected #10091

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

Closed
scabug opened this issue Dec 5, 2016 · 1 comment
Closed

Comments

@scabug
Copy link

scabug commented Dec 5, 2016

Given: trait with implemented protected method
When: instantiate that trait overriding protected method with public access modifier
Expect: overridden method is public
Actual: overridden method is still protected

Code:

class Test {

  trait I {
    protected def func(): Unit = println("hello")
  }

  trait PI extends I {
    override def func(): Unit = super.func()
  }

  val i = new I {
    override def func(): Unit = super.func()
  }

  val pi = new PI {
  }

  i.func() //still protected: method func in trait I cannot be accessed in Test.this.I
  pi.func() //works

}
@scabug
Copy link
Author

scabug commented Dec 5, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10091?orig=1
Reporter: Sergey Alaev (salaev)
Affected Versions: 2.12.0
Duplicates #1352

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