Aladdin - Scala Bugtracking
[#792] project: compiler priority: low category: bug
submitter assigned to status date submitted
Burak Iulian fixed 2006-11-01 15:30:46.0
subject java nested classes once more
code
===nest.java===
public class nest {
        static class rest {
                public static rest test = new rest();
        }
}
===lest.java===
object lest {

  val r = nest.rest
  val s = nest$rest //ugly

  val x = s.test
  val y:nest$rest = nest$rest.test
  val z:nest#rest = null
}
what happened
$javac -d . nest.java
$scalac -d .  lest.scala
lest.scala:3 error: value rest is not a member of object nest
  val r = nest.rest
              ^
error: error while loading nest$rest, class file './nest$rest.class' is broken
(class nest$rest not found.)
lest.scala:4 error: object nest$rest is not a value
  val s = nest$rest
          ^
lest.scala:8 error: type rest is not a member of nest
  val z:nest#rest = null
            ^
lest.scala:7 error: value test is not a member of object nest$rest
  val y:nest$rest = nest$rest.test
                             ^
5 errors found
what expected Some way to access nest.rest.test. rest could be considered as both type nest # rest and as value nest.rest. (should test additionally be declared static in Java? I never now, please fix this bug report if it does not make sense)
[back to overview]
Changes of this bug report
Martin  edited on  2006-11-01 16:30:55.0
Burak, how hearles sof you to drop another bug in my lap now that have have fixed almost all the others :-). Seriously, I think this one is for Iulian.
Burak  edited on  2006-11-01 17:11:49.0
Iulian  edited on  2006-11-02 12:16:04.0
Yeah, it should be static. Now, you can access such members as in Java, by typing 'nest.rest.test'. Even though the inner static class appears as a value, it is not (so you cannot assign it or pass it around), just like packages.
Note that if there are fields with the same name as the inner class, they shadow it, so there would be no way to access its static members. Java behaves the same.