diff --git a/sips/pending/_posts/2016-01-11-static-members.md b/sips/pending/_posts/2016-01-11-static-members.md index ac7a32a5c6..485ca635ad 100644 --- a/sips/pending/_posts/2016-01-11-static-members.md +++ b/sips/pending/_posts/2016-01-11-static-members.md @@ -30,7 +30,6 @@ There is no special syntax proposed to access these members, they are accessed a For example: -```scala {% highlight scala %} class Foo @@ -42,12 +41,10 @@ object Foo { println(Foo.x) println(Foo.bar(12)) {% endhighlight %} -``` Intuitively, the presence of the `@static` annotation ensures that a field/method is declared as a static member of the companion class. For the JVM, the above would therefore look to other Java code as if it had been declared with the following Java code: -```java {% highlight java %} class Foo { public static int x = 5; @@ -56,12 +53,10 @@ class Foo { } } {% endhighlight %} -``` In Scala.js, the `@static` annotation has no semantic effect in Scala objects, as they are not visible from JavaScript anyway (it could be used for optimizations). It has a semantic effect on Scala.js-defined JS classes, for example: -```scala {% highlight scala %} @ScalaJSDefined class Foo extends js.Object @@ -72,11 +67,9 @@ object Foo extends js.Object { @static def bar(y: Int): Int = x + y } {% endhighlight %} -``` would look to JavaScript code as if it had been declared with the following JavaScript code: -```javascript {% highlight javascript %} class Foo extends Object { static bar(y) { @@ -85,13 +78,11 @@ class Foo extends Object { } Foo.x = 5; // in ES6, there is no declarative syntax for static fields yet {% endhighlight %} -``` ## Comparison with mirror classes ## Scalac currently generates static forwarders for fields and methods in top-level objects: -```scala {% highlight scala %} object O { val d = 1 @@ -100,7 +91,6 @@ object O { } } {% endhighlight %} -``` Under the proposed scheme users will be able to opt-in to have the field `f` defined in the inner object `I` emited as a static field. In case `O.d` is annotated with `@static` the field will be crated as a static field `d` in `class O`.