Do we need to enhance @static?


#1

We know that @static was proposed in SIP 25, and it has been implemented in Dotty.
Currently, when an object member is all annotated with @static, the compiler still generates a corresponding class file for it.These objects have no practical use in most cases, and I think we should allow users to somehow prevent the compiler from generating them.For example, we can add new usage for @static:

class Test 

@static
object Test {
  @static
  def f: Int = 100
}

Or we can go one step further. When an object is annotated with @static , all its members are treated as being annotated with @static , which may help us reduce a lot of duplicate work.
Preventing the compiler from generating useless objects can help us reduce the output file size, make Dotty-generated bytecode more controllable, and be more friendly to other JVM languages.


#2

No one is interested in this proposal?
Allowing annotation of objects as @static has the additional advantage of being able to avoid object inheritance from the Any to redundant methods,.


#3

emmm that’s a good idea.