Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kotlin statics and static extensions #347

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor corrections from PR feedback
  • Loading branch information
elizarov committed Apr 3, 2023
commit 65ea046489a0e4972f4b6cce589c93dce575f107
11 changes: 5 additions & 6 deletions proposals/statics.md
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ fun Namespace.static.ext() {

### Static extensions resolution and import

Static extensions can be called in several ways. One way is using making a qualified class with
Static extensions can be called in several ways. One way is using making a qualified call with
`<ClassName>.<extensionName>` as in, for example, `Color.parse(s)`. Similarly to the regular extensions, the
corresponding static extensions has to be imported in order for this call to be resolved.

Expand Down Expand Up @@ -1289,7 +1289,8 @@ Get compiled as the following equivalent Java code:

```java
public class Outer {
public static int getX() { return 0; }
private static int x = 0;
public static int getX() { return x; }
public static void foo(int x) {}
public static ext(int $this$ext) {}
}
Expand Down Expand Up @@ -1317,7 +1318,8 @@ Get compiled as the following equivalent Java code:

```java
public class Namespace {
public static int getProperty() { return 42; }
private static int property = 42;
public static int getProperty() { return property; }
public static void doSomething() {}
}
```
Expand Down Expand Up @@ -1384,9 +1386,6 @@ public class Color {

> Note: It means that adding/removing Kotlin `const` modifier is not a binary compatible change on JVM.

Private static constants in interfaces have the same problem on JVM 1.8 as other private static members.
See [Static members of classes and interfaces on JVM](#static-members-of-classes-and-interfaces-on-jvm).

### Static extensions on JVM

On JVM [Static extensions](#static-extensions) get compiled as the corresponding static or member functions of
Expand Down