Commit 7b375de
authored
Kotlin: explicit accessors for static properties (#1782)
---------- Motivation ----------
Java generator in Gluecodium generates getter/setter methods for static properties.
When such Java code is accessed from Kotlin the methods should be represented as
Kotlin synthetic properties (according to the documentation of Kotlin language).
However, it turns out that such static properties can be also accessed via getter and setter
static functions. Such usage was identified to be working.
Therefore, in order to allow seamless replacement of Java generated code with Kotlin generated
code for Kotlin apps the Kotlin generated code must also allow getting/setting static properties
via getter/setter functions.
---------- Implemented solution ----------
Kotlin generator produces additional extension methods for companion object to allow getting and
setting static properties. The generated methods are annotated as JvmSynthetic to ensure that
they are not visible in Java (because such feature is Kotlin-specific).
Moreover, the value passed to file:JvmName() is adjusted to avoid compilation problems. That name
is used only when we have global functions or properties. Such entities are compiled to the class with
specified name. Because we used the same name as the element defined for given file, when extensions
are defined we would end up with two classes with the same name -- this was adjusted.
Signed-off-by: Patryk Wrobel <[email protected]>1 parent 0ce8de3 commit 7b375de
File tree
218 files changed
+412
-214
lines changed- .github/workflows
- functional-tests/functional/android-kotlin/src/test/kotlin/com/here/android/test
- gluecodium/src
- main
- java/com/here/gluecodium/generator/kotlin
- resources/templates/kotlin
- test/resources/smoke
- attributes/output/android-kotlin/com/example/smoke
- basic_types/output/android-kotlin/com/example/smoke
- comments/output/android-kotlin/com/example/smoke
- constants/output/android-kotlin/com/example/smoke
- constructors/output/android-kotlin/com/example/smoke
- dates/output/android-kotlin/com/example/smoke
- defaults_const/output/android-kotlin/com/example/smoke
- defaults/output/android-kotlin/com/example/smoke
- duplicate_names/output/android-kotlin/com/example/smoke
- durations/output/android-kotlin/com/example/smoke
- enums/output/android-kotlin/com/example/smoke
- equatable/output/android-kotlin/com/example/smoke
- errors/output/android-kotlin/com/example/smoke
- escaped_names/output/android-kotlin/com/example/package
- external_types/output/android-kotlin/com/example
- kotlinsmoke
- smoke
- field_constructors/output/android-kotlin/com/example/smoke
- generic_types/output/android-kotlin/com/example/smoke
- instances/output/android-kotlin/com/example/smoke
- internal_fields/output/android-kotlin/com/example/smoke
- lambdas/output/android-kotlin/com/example/smoke
- listeners/output/android-kotlin/com/example/smoke
- locales/output/android-kotlin/com/example/smoke
- method_overloads/output/android-kotlin/com/example/smoke
- multiple_inheritance/output/android-kotlin/com/example/smoke
- name_rules/output/android-kotlin/com/example/namerules
- nesting/output/android-kotlin/com/example/smoke
- no_cache/output/android-kotlin/com/example/smoke
- nullable/output/android-kotlin/com/example/smoke
- packages/output/android-kotlin/com/example
- smokeoff
- smoke/off
- platform_names/output/android-kotlin/com/example/smoke
- properties/output/android-kotlin/com/example/smoke
- serialization/output/android-kotlin/com/example/smoke
- skip/output/android-kotlin/com/example/smoke
- structs/output/android-kotlin/com/example/smoke
- typedefs/output/android-kotlin/com/example/smoke
- visibility_attribute/output/android-kotlin/com/example/smoke
- visibility_platform/output/android-kotlin/com/example/smoke
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
218 files changed
+412
-214
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
| 286 | + | |
| 287 | + | |
286 | 288 | | |
287 | 289 | | |
288 | 290 | | |
| |||
291 | 293 | | |
292 | 294 | | |
293 | 295 | | |
| 296 | + | |
| 297 | + | |
294 | 298 | | |
295 | 299 | | |
296 | 300 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
functional-tests/functional/android-kotlin/src/test/kotlin/com/here/android/test/AttributesTest.kt
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
62 | 68 | | |
63 | 69 | | |
64 | 70 | | |
| |||
83 | 89 | | |
84 | 90 | | |
85 | 91 | | |
| 92 | + | |
86 | 93 | | |
87 | 94 | | |
88 | 95 | | |
| |||
93 | 100 | | |
94 | 101 | | |
95 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
96 | 106 | | |
97 | 107 | | |
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
63 | 94 | | |
Lines changed: 13 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
0 commit comments