trait D {
  private val x = "xxxx should appear twice"
  private object xxxx { Console.println(x) }
  def get_xxxx: AnyRef = xxxx

  private val z = "zzzz should appear twice"
  private lazy val zzzz = new ZZZZ
  class ZZZZ { Console.println(z) }
  def get_zzzz: AnyRef = zzzz
}

trait E extends D {
  def f(): Unit = {
    val y = "yyyy should appear twice"
    object yyyy {
      val x1 = get_xxxx
      val z1 = get_zzzz
      Console.println(y)
    }
    yyyy
  }
}
class C extends E {}
object Test extends D {
  object E
  def main(args : Array[String]): Unit = {
    new C().f()
    new C().f()
  }
}

trait D {
  private val x = "xxxx should appear twice"
  object xxxx { Console.println(x) }
  def get_xxxx: AnyRef = xxxx

  private val z = "zzzz should appear twice"
  lazy val zzzz = new ZZZZ
  class ZZZZ { Console.println(z) }
  def get_zzzz: AnyRef = zzzz
}

trait E extends D {
  def f(): Unit = {
    val y = "yyyy should appear twice"
    object yyyy {
      val x1 = get_xxxx
      val z1 = get_zzzz
      Console.println(y)
    }
    yyyy
  }
}
class C extends E {}
object Test extends D {
  object E
  def main(args : Array[String]): Unit = {
    new C().f()
    new C().f()
  }
}

--- 
+++ 
@@ -1,10 +1,10 @@
 trait D {
   private val x = "xxxx should appear twice"
-  object xxxx { Console.println(x) }
+  private object xxxx { Console.println(x) }
   def get_xxxx: AnyRef = xxxx
 
   private val z = "zzzz should appear twice"
-  lazy val zzzz = new ZZZZ
+  private lazy val zzzz = new ZZZZ
   class ZZZZ { Console.println(z) }
   def get_zzzz: AnyRef = zzzz
 }
Put back private modifier in test
