-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
scala/scala
#8835Milestone
Description
reproduction steps
- pk1/A.scala
package pk1
class A {
protected def f(): Unit = print("A")
}
- Main.scala
import pk1.A
trait B { self: A =>
override def f(): Unit = {
print("B")
self.f()
}
}
class C extends A with B
object Main {
def main(args: Array[String]): Unit = {
new C().f()
}
}
problem
- The code above run successfully
[info] running Main
BA[success]...
- But when remove the
protected
modifier fromA.f
=>
[info] running Main
BBB...//many Bs
[error] java.lang.StackOverflowError
...
[error] at scala.Predef$.print(Predef.scala:385)
[error] at B.f(Main.scala:5)
[error] at B.f$(Main.scala:4)
[error] at C.f(Main.scala:9)
[error] at B.f(Main.scala:6)
[error] at B.f$(Main.scala:4)
[error] at C.f(Main.scala:9)
...
- similar (StackOverflowError) if we move
A
frompkg1
to default package (same package as B)
expectation
IDK :)