Type aliasing Java classes with statics

后端 未结 2 591

Suppose MyClass is a class defined in Java, and has many static as well as non-static members. I tried to alias this class (and associated companion object) in a Sc

2条回答
  •  执念已碎
    2021-02-15 07:31

    it's not possible with Java's static methods, as these don't belong to any interface.

    Update 5 years later: PR 5131 mentions:

    We used to disable generation of static forwarders when a object had a trait as a companion, as one could not add methods with bodies to an interface in JVM 6.

    The JVM lifted this restriction to support default methods in interfaces, so we can lift the restriction on static forwarders, too.

    Fixes scala-dev issue 59

    See commit 41c9a17 by Jason Zaugg (retronym).

提交回复
热议问题