Aladdin - Scala Bugtracking
[#393] project: specification priority: low category: feature
submitter assigned to status date submitted
Michel Martin won't fix 2005-01-18 11:15:56.0
subject Classes for nested objects are not in the members of their owner
code
class C {
  object O;
}
what happened
The members of C contain only the value for O, not the class for O\
. This breaks the run-time types phase (I currently have a work-around for this problem, but it's a hack that I'\
d like to remove).
what expected The members of C should contain both the class and the instance for the object (as well as the accessor method, but it's already there).
[back to overview]
Changes of this bug report
Michel  edited on  2005-01-27 15:34:28.0

(Background: Martin told me orally that he is not sure this is a bug, because the class should in fact be invisible from outside, hence not part of the members).

I have found out that in one situation, the class is in fact part of the members: this happens for objects nested inside of functions, which are later lifted by LambdaLift. So the current behaviour is at least inconsistent, and either LambdaLift or the Analyzer should be changed.

To clarify what I mean, here are two examples. In this one, class Nested does not appear in the members of class Outer (that precisely what the original bug report was about):

class Outer {
  object Nested;
}

On the other hand, in this example class Nested does appear in the members of class Outer (to be precise, it's class Nested$0 lifted by LambdaLift which appears there):

class Outer {
  def f = {
    object Nested; ()
  }
}

It seems to me that if we want to be really consistent, then classes lifted by LambdaLift should not appear in the members of their host class. But this would cause a number of problems, as some classes would suddenly become invisible to a lot of phases. Maybe all these "invisible" classes should be made private, and renamed to unique names.

Martin  edited on  2006-03-30 18:33:06.0
Changed priority to low because it is not a problem right now for Scala 2. I am still now sure what is the correct way of doing this.
Martin  edited on  2006-05-28 21:59:03.0
I think this would be a major change of the spec. Right now I don'ty see sufficient reasons to undertake such changes. So I close the bug.