Aladdin - Scala Bugtracking
[#419] project: compiler priority: medium category: bug
submitter assigned to status date submitted
Burak Martin won't fix 2005-04-12 15:27:41.0
subject traits with variables (?!)
code
trait Bar {
  class Config {}
  var config: Config; // aha, traits can have variables?
}

object Foo with Bar {

  class FooConfig extends Config;
  var config = new FooConfig() // or not

}

what happened
test1.scala:6: object creation impossible, since variable config_= in trait Bar is not defined
(Note that variables need to be initialized to be defined)
object Foo with Bar {
       ^
one error found
what expected either disallow variables in traits, or fix initialization.
[back to overview]
Changes of this bug report
Burak  edited on  2005-04-12 15:29:31.0
The problem appears also if Bar is an abstract class...
Martin  edited on  2006-03-30 17:50:26.0
The problem is that config in class Foo has type FooConfig. It therefore does not override config of type Config in trait Bar. I agree the error message is confusing, but this is hard to change.